diff --git a/sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java b/sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java index a1d894fa4..be3582e3e 100644 --- a/sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java +++ b/sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java @@ -290,7 +290,6 @@ public void useDatabase(@NonNull String dbName) throws InterruptedException { public void createDatabase(CreateDatabaseReq request) { retry(()-> databaseService.createDatabase(this.getRpcStub(), request)); } - /** * Drops a database. Note that this method drops all data in the database. * @param request drop database request @@ -298,7 +297,6 @@ public void createDatabase(CreateDatabaseReq request) { public void dropDatabase(DropDatabaseReq request) { retry(()-> databaseService.dropDatabase(this.getRpcStub(), request)); } - /** * List all databases. * @return List of String database names @@ -306,15 +304,32 @@ public void dropDatabase(DropDatabaseReq request) { public ListDatabasesResp listDatabases() { return retry(()-> databaseService.listDatabases(this.getRpcStub())); } - /** * Alter database with key value pair. (Available from Milvus v2.4.4) + * Deprecated, replaced by alterDatabaseProperties from v2.5.2, to keep consistence with other SDKs * @param request alter database request */ + @Deprecated public void alterDatabase(AlterDatabaseReq request) { - retry(()-> databaseService.alterDatabase(this.getRpcStub(), request)); + alterDatabaseProperties(AlterDatabasePropertiesReq.builder() + .databaseName(request.getDatabaseName()) + .properties(request.getProperties()) + .build()); + } + /** + * Alter a database's properties (Available from Milvus v2.5.2) + * @param request alter database properties request + */ + public void alterDatabaseProperties(AlterDatabasePropertiesReq request) { + retry(()-> databaseService.alterDatabaseProperties(this.getRpcStub(), request)); + } + /** + * drop a database's properties (Available from Milvus v2.5.2) + * @param request alter database properties request + */ + public void dropDatabaseProperties(DropDatabasePropertiesReq request) { + retry(()-> databaseService.dropDatabaseProperties(this.getRpcStub(), request)); } - /** * Show detail of database base, such as replica number and resource groups. (Available from Milvus v2.4.4) * @param request describe database request @@ -341,7 +356,6 @@ public void createCollection(CreateCollectionReq request) { public CreateCollectionReq.CollectionSchema createSchema() { return collectionService.createSchema(); } - /** * list milvus collections * @@ -350,7 +364,6 @@ public CreateCollectionReq.CollectionSchema createSchema() { public ListCollectionsResp listCollections() { return retry(()-> collectionService.listCollections(this.getRpcStub())); } - /** * Drops a collection in Milvus. * @@ -361,11 +374,32 @@ public void dropCollection(DropCollectionReq request) { } /** * Alter a collection in Milvus. + * Deprecated, replaced by alterCollectionProperties from v2.5.2, to keep consistence with other SDKs * * @param request alter collection request */ + @Deprecated public void alterCollection(AlterCollectionReq request) { - retry(()-> collectionService.alterCollection(this.getRpcStub(), request)); + alterCollectionProperties(AlterCollectionPropertiesReq.builder() + .collectionName(request.getCollectionName()) + .databaseName(request.getDatabaseName()) + .properties(request.getProperties()) + .build()); + } + /** + * Alter a collection's properties (Available from Milvus v2.5.2). + * + * @param request alter collection properties request + */ + public void alterCollectionProperties(AlterCollectionPropertiesReq request) { + retry(()-> collectionService.alterCollectionProperties(this.getRpcStub(), request)); + } + /** + * drop a collection's properties (Available from Milvus v2.5.2) + * @param request drop collection properties request + */ + public void dropCollectionProperties(DropCollectionPropertiesReq request) { + retry(()-> collectionService.dropCollectionProperties(this.getRpcStub(), request)); } /** * Checks whether a collection exists in Milvus. @@ -447,11 +481,33 @@ public void dropIndex(DropIndexReq request) { } /** * Alter an index in Milvus. + * Deprecated, replaced by alterIndexProperties from v2.5.2, to keep consistence with other SDKs * * @param request alter index request */ + @Deprecated public void alterIndex(AlterIndexReq request) { - retry(()->indexService.alterIndex(this.getRpcStub(), request)); + alterIndexProperties(AlterIndexPropertiesReq.builder() + .collectionName(request.getCollectionName()) + .databaseName(request.getDatabaseName()) + .indexName(request.getIndexName()) + .properties(request.getProperties()) + .build()); + } + /** + * Alter an index's properties (Available from Milvus v2.5.2) + * + * @param request alter index request + */ + public void alterIndexProperties(AlterIndexPropertiesReq request) { + retry(()->indexService.alterIndexProperties(this.getRpcStub(), request)); + } + /** + * drop an index's properties (Available from Milvus v2.5.2) + * @param request drop index properties request + */ + public void dropIndexProperties(DropIndexPropertiesReq request) { + retry(()-> indexService.dropIndexProperties(this.getRpcStub(), request)); } /** * Checks whether an index exists for a specified field in a collection in Milvus. @@ -462,7 +518,6 @@ public void alterIndex(AlterIndexReq request) { public DescribeIndexResp describeIndex(DescribeIndexReq request) { return retry(()->indexService.describeIndex(this.getRpcStub(), request)); } - /** * Lists all indexes in a collection in Milvus. * @@ -472,8 +527,8 @@ public DescribeIndexResp describeIndex(DescribeIndexReq request) { public List listIndexes(ListIndexesReq request) { return retry(()->indexService.listIndexes(this.getRpcStub(), request)); } - // Vector Operations + // Vector Operations /** * Inserts vectors into a collection in Milvus. * @@ -615,8 +670,8 @@ public void loadPartitions(LoadPartitionsReq request) { public void releasePartitions(ReleasePartitionsReq request) { retry(()->partitionService.releasePartitions(this.getRpcStub(), request)); } - // rbac operations - // user operations + + // RBAC operations /** * list users * diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionService.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionService.java index 0153539f1..b67d1b08e 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionService.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionService.java @@ -186,9 +186,10 @@ public Void dropCollection(MilvusServiceGrpc.MilvusServiceBlockingStub blockingS return null; } - public Void alterCollection(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, AlterCollectionReq request) { - String title = String.format("AlterCollectionRequest collectionName:%s", request.getCollectionName()); - AlterCollectionRequest.Builder builder = AlterCollectionRequest.newBuilder(); + public Void alterCollectionProperties(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, AlterCollectionPropertiesReq request) { + String title = String.format("AlterCollectionPropertiesReq collectionName:%s", request.getCollectionName()); + AlterCollectionRequest.Builder builder = AlterCollectionRequest.newBuilder() + .setCollectionName(request.getCollectionName()); List propertiesList = ParamUtils.AssembleKvPair(request.getProperties()); if (CollectionUtils.isNotEmpty(propertiesList)) { propertiesList.forEach(builder::addProperties); @@ -197,11 +198,22 @@ public Void alterCollection(MilvusServiceGrpc.MilvusServiceBlockingStub blocking builder.setDbName(request.getDatabaseName()); } - AlterCollectionRequest alterCollectionRequest = builder + Status response = blockingStub.alterCollection(builder.build()); + rpcUtils.handleResponse(title, response); + + return null; + } + + public Void dropCollectionProperties(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, DropCollectionPropertiesReq request) { + String title = String.format("DropCollectionPropertiesReq collectionName:%s", request.getCollectionName()); + AlterCollectionRequest.Builder builder = AlterCollectionRequest.newBuilder() .setCollectionName(request.getCollectionName()) - .build(); + .addAllDeleteKeys(request.getPropertyKeys()); + if (StringUtils.isNotEmpty(request.getDatabaseName())) { + builder.setDbName(request.getDatabaseName()); + } - Status response = blockingStub.alterCollection(alterCollectionRequest); + Status response = blockingStub.alterCollection(builder.build()); rpcUtils.handleResponse(title, response); return null; diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionPropertiesReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionPropertiesReq.java new file mode 100644 index 000000000..5ae09dc80 --- /dev/null +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionPropertiesReq.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.milvus.v2.service.collection.request; + +import lombok.Builder; +import lombok.Data; +import lombok.experimental.SuperBuilder; + +import java.util.HashMap; +import java.util.Map; + +@Data +@SuperBuilder +public class AlterCollectionPropertiesReq { + private String collectionName; + private String databaseName; + @Builder.Default + private final Map properties = new HashMap<>(); + + + public static abstract class AlterCollectionPropertiesReqBuilder> { + public B property(String key, String value) { + if(null == this.properties$value ){ + this.properties$value = new HashMap<>(); + } + this.properties$value.put(key, value); + this.properties$set = true; + return self(); + } + } +} diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionReq.java index a193b0a5a..a12420199 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionReq.java @@ -9,6 +9,7 @@ @Data @SuperBuilder +@Deprecated public class AlterCollectionReq { private String collectionName; private String databaseName; diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DropCollectionPropertiesReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DropCollectionPropertiesReq.java new file mode 100644 index 000000000..be6a033a5 --- /dev/null +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DropCollectionPropertiesReq.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.milvus.v2.service.collection.request; + +import lombok.Builder; +import lombok.Data; +import lombok.experimental.SuperBuilder; + +import java.util.ArrayList; +import java.util.List; + +@Data +@SuperBuilder +public class DropCollectionPropertiesReq { + private String collectionName; + private String databaseName; + + @Builder.Default + private List propertyKeys = new ArrayList<>(); +} diff --git a/sdk-core/src/main/java/io/milvus/v2/service/database/DatabaseService.java b/sdk-core/src/main/java/io/milvus/v2/service/database/DatabaseService.java index 123928372..6c2a65d31 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/database/DatabaseService.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/database/DatabaseService.java @@ -22,7 +22,6 @@ import io.milvus.grpc.*; import io.milvus.param.ParamUtils; import io.milvus.v2.service.BaseService; -import io.milvus.v2.service.collection.response.ListCollectionsResp; import io.milvus.v2.service.database.request.*; import io.milvus.v2.service.database.response.*; import org.apache.commons.collections4.CollectionUtils; @@ -66,8 +65,8 @@ public ListDatabasesResp listDatabases(MilvusServiceGrpc.MilvusServiceBlockingSt return listDatabasesResp; } - public Void alterDatabase(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, AlterDatabaseReq request) { - String title = String.format("AlterDatabaseRequest databaseName:%s", request.getDatabaseName()); + public Void alterDatabaseProperties(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, AlterDatabasePropertiesReq request) { + String title = String.format("AlterDatabasePropertiesReq databaseName:%s", request.getDatabaseName()); AlterDatabaseRequest.Builder builder = AlterDatabaseRequest.newBuilder() .setDbName(request.getDatabaseName()); List propertiesList = ParamUtils.AssembleKvPair(request.getProperties()); @@ -80,6 +79,17 @@ public Void alterDatabase(MilvusServiceGrpc.MilvusServiceBlockingStub blockingSt return null; } + public Void dropDatabaseProperties(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, DropDatabasePropertiesReq request) { + String title = String.format("DropDatabasePropertiesReq databaseName:%s", request.getDatabaseName()); + AlterDatabaseRequest.Builder builder = AlterDatabaseRequest.newBuilder() + .setDbName(request.getDatabaseName()) + .addAllDeleteKeys(request.getPropertyKeys()); + + Status response = blockingStub.alterDatabase(builder.build()); + rpcUtils.handleResponse(title, response); + return null; + } + public DescribeDatabaseResp describeDatabase(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, DescribeDatabaseReq request) { String title = String.format("DescribeDatabaseRequest databaseName:%s", request.getDatabaseName()); DescribeDatabaseRequest rpcRequest = DescribeDatabaseRequest.newBuilder() diff --git a/sdk-core/src/main/java/io/milvus/v2/service/database/request/AlterDatabasePropertiesReq.java b/sdk-core/src/main/java/io/milvus/v2/service/database/request/AlterDatabasePropertiesReq.java new file mode 100644 index 000000000..bd28d066c --- /dev/null +++ b/sdk-core/src/main/java/io/milvus/v2/service/database/request/AlterDatabasePropertiesReq.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.milvus.v2.service.database.request; + +import lombok.Builder; +import lombok.Data; +import lombok.experimental.SuperBuilder; + +import java.util.HashMap; +import java.util.Map; + +@Data +@SuperBuilder +public class AlterDatabasePropertiesReq { + private String databaseName; + @Builder.Default + private Map properties = new HashMap<>(); + + public static abstract class AlterDatabasePropertiesReqBuilder> { + public B property(String key, String value) { + if(null == this.properties$value ){ + this.properties$value = new HashMap<>(); + } + this.properties$value.put(key, value); + this.properties$set = true; + return self(); + } + } +} diff --git a/sdk-core/src/main/java/io/milvus/v2/service/database/request/AlterDatabaseReq.java b/sdk-core/src/main/java/io/milvus/v2/service/database/request/AlterDatabaseReq.java index 2f454a4c5..48e8e104a 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/database/request/AlterDatabaseReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/database/request/AlterDatabaseReq.java @@ -28,6 +28,7 @@ @Data @SuperBuilder +@Deprecated public class AlterDatabaseReq { private String databaseName; @Builder.Default diff --git a/sdk-core/src/main/java/io/milvus/v2/service/database/request/DropDatabasePropertiesReq.java b/sdk-core/src/main/java/io/milvus/v2/service/database/request/DropDatabasePropertiesReq.java new file mode 100644 index 000000000..73db379fb --- /dev/null +++ b/sdk-core/src/main/java/io/milvus/v2/service/database/request/DropDatabasePropertiesReq.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.milvus.v2.service.database.request; + + +import lombok.Builder; +import lombok.Data; +import lombok.experimental.SuperBuilder; + +import java.util.ArrayList; +import java.util.List; + +@Data +@SuperBuilder +public class DropDatabasePropertiesReq { + private String databaseName; + @Builder.Default + private List propertyKeys = new ArrayList<>(); +} diff --git a/sdk-core/src/main/java/io/milvus/v2/service/index/IndexService.java b/sdk-core/src/main/java/io/milvus/v2/service/index/IndexService.java index 139689aa6..8ffbd7a83 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/index/IndexService.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/index/IndexService.java @@ -93,10 +93,13 @@ public Void dropIndex(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, return null; } - public Void alterIndex(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, AlterIndexReq request) { - String title = String.format("AlterIndexRequest collectionName:%s, indexName:%s", + public Void alterIndexProperties(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, AlterIndexPropertiesReq request) { + String title = String.format("AlterIndexPropertiesReq collectionName:%s, indexName:%s", request.getCollectionName(), request.getIndexName()); - AlterIndexRequest.Builder builder = AlterIndexRequest.newBuilder(); + AlterIndexRequest.Builder builder = AlterIndexRequest.newBuilder() + .setCollectionName(request.getCollectionName()) + .setIndexName(request.getIndexName()); + List propertiesList = ParamUtils.AssembleKvPair(request.getProperties()); if (CollectionUtils.isNotEmpty(propertiesList)) { propertiesList.forEach(builder::addExtraParams); @@ -105,12 +108,25 @@ public Void alterIndex(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, builder.setDbName(request.getDatabaseName()); } - AlterIndexRequest alterIndexRequest = builder + Status response = blockingStub.alterIndex(builder.build()); + rpcUtils.handleResponse(title, response); + + return null; + } + + public Void dropIndexProperties(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, DropIndexPropertiesReq request) { + String title = String.format("DropIndexPropertiesReq collectionName:%s, indexName:%s", + request.getCollectionName(), request.getIndexName()); + AlterIndexRequest.Builder builder = AlterIndexRequest.newBuilder() .setCollectionName(request.getCollectionName()) .setIndexName(request.getIndexName()) - .build(); + .addAllDeleteKeys(request.getPropertyKeys()); + + if (StringUtils.isNotEmpty(request.getDatabaseName())) { + builder.setDbName(request.getDatabaseName()); + } - Status response = blockingStub.alterIndex(alterIndexRequest); + Status response = blockingStub.alterIndex(builder.build()); rpcUtils.handleResponse(title, response); return null; diff --git a/sdk-core/src/main/java/io/milvus/v2/service/index/request/AlterIndexPropertiesReq.java b/sdk-core/src/main/java/io/milvus/v2/service/index/request/AlterIndexPropertiesReq.java new file mode 100644 index 000000000..bf889cc92 --- /dev/null +++ b/sdk-core/src/main/java/io/milvus/v2/service/index/request/AlterIndexPropertiesReq.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.milvus.v2.service.index.request; + +import lombok.Builder; +import lombok.Data; +import lombok.experimental.SuperBuilder; + +import java.util.HashMap; +import java.util.Map; + +@Data +@SuperBuilder +public class AlterIndexPropertiesReq { + private String collectionName; + private String databaseName; + private String indexName; + @Builder.Default + private Map properties = new HashMap<>(); + + + public static abstract class AlterIndexPropertiesReqBuilder> { + public B property(String key, String value) { + if(null == this.properties$value ){ + this.properties$value = new HashMap<>(); + } + this.properties$value.put(key, value); + this.properties$set = true; + return self(); + } + } +} diff --git a/sdk-core/src/main/java/io/milvus/v2/service/index/request/AlterIndexReq.java b/sdk-core/src/main/java/io/milvus/v2/service/index/request/AlterIndexReq.java index 39f20f530..5cb268e67 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/index/request/AlterIndexReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/index/request/AlterIndexReq.java @@ -1,6 +1,5 @@ package io.milvus.v2.service.index.request; -import io.milvus.param.Constant; import lombok.Builder; import lombok.Data; import lombok.experimental.SuperBuilder; @@ -10,6 +9,7 @@ @Data @SuperBuilder +@Deprecated public class AlterIndexReq { private String collectionName; private String databaseName; diff --git a/sdk-core/src/main/java/io/milvus/v2/service/index/request/DropIndexPropertiesReq.java b/sdk-core/src/main/java/io/milvus/v2/service/index/request/DropIndexPropertiesReq.java new file mode 100644 index 000000000..df646430b --- /dev/null +++ b/sdk-core/src/main/java/io/milvus/v2/service/index/request/DropIndexPropertiesReq.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.milvus.v2.service.index.request; + +import lombok.Builder; +import lombok.Data; +import lombok.experimental.SuperBuilder; + +import java.util.ArrayList; +import java.util.List; + +@Data +@SuperBuilder +public class DropIndexPropertiesReq { + private String collectionName; + private String databaseName; + private String indexName; + + @Builder.Default + private List propertyKeys = new ArrayList<>(); +} diff --git a/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java b/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java index d75140630..3caecafff 100644 --- a/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java +++ b/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java @@ -75,7 +75,7 @@ class MilvusClientV2DockerTest { private static final TestUtils utils = new TestUtils(DIMENSION); @Container - private static final MilvusContainer milvus = new MilvusContainer("milvusdb/milvus:v2.5.0-beta"); + private static final MilvusContainer milvus = new MilvusContainer("milvusdb/milvus:master-20241218-5394f478-amd64"); @BeforeAll public static void setUp() { @@ -1125,10 +1125,11 @@ void testIndex() { .collectionName(randomCollectionName) .build()); + // collection alter properties Map properties = new HashMap<>(); properties.put(Constant.TTL_SECONDS, "10"); properties.put(Constant.MMAP_ENABLED, "true"); - client.alterCollection(AlterCollectionReq.builder() + client.alterCollectionProperties(AlterCollectionPropertiesReq.builder() .collectionName(randomCollectionName) .properties(properties) .property("prop", "val") @@ -1144,6 +1145,17 @@ void testIndex() { Assertions.assertEquals("true", collProps.get(Constant.MMAP_ENABLED)); Assertions.assertEquals("val", collProps.get("prop")); + client.dropCollectionProperties(DropCollectionPropertiesReq.builder() + .collectionName(randomCollectionName) + .propertyKeys(Collections.singletonList("prop")) + .build()); + descCollResp = client.describeCollection(DescribeCollectionReq.builder() + .collectionName(randomCollectionName) + .build()); + collProps = descCollResp.getProperties(); + Assertions.assertFalse(collProps.containsKey("prop")); + + // index alter properties DescribeIndexResp descResp = client.describeIndex(DescribeIndexReq.builder() .collectionName(randomCollectionName) .fieldName("vector") @@ -1160,7 +1172,7 @@ void testIndex() { properties.clear(); properties.put(Constant.MMAP_ENABLED, "false"); - client.alterIndex(AlterIndexReq.builder() + client.alterIndexProperties(AlterIndexPropertiesReq.builder() .collectionName(randomCollectionName) .indexName(desc.getIndexName()) .properties(properties) @@ -1175,6 +1187,20 @@ void testIndex() { Assertions.assertTrue(indexProps.containsKey(Constant.MMAP_ENABLED)); Assertions.assertEquals("false", indexProps.get(Constant.MMAP_ENABLED)); + client.dropIndexProperties(DropIndexPropertiesReq.builder() + .collectionName(randomCollectionName) + .indexName(desc.getIndexName()) + .propertyKeys(Collections.singletonList(Constant.MMAP_ENABLED)) + .build()); + descResp = client.describeIndex(DescribeIndexReq.builder() + .collectionName(randomCollectionName) + .fieldName("vector") + .build()); + desc = descResp.getIndexDescByFieldName("vector"); + indexProps = desc.getProperties(); + Assertions.assertFalse(indexProps.containsKey(Constant.MMAP_ENABLED)); + + // drop index client.dropIndex(DropIndexReq.builder() .collectionName(randomCollectionName) .fieldName("vector") @@ -1499,10 +1525,10 @@ void testDatabase() { // alter the database properties.put(Constant.DATABASE_REPLICA_NUMBER, "10"); - properties.put("prop", "val"); - client.alterDatabase(AlterDatabaseReq.builder() + client.alterDatabaseProperties(AlterDatabasePropertiesReq.builder() .databaseName(tempDatabaseName) .properties(properties) + .property("prop", "val") .build()); descDBResp = client.describeDatabase(DescribeDatabaseReq.builder() .databaseName(tempDatabaseName) @@ -1513,6 +1539,17 @@ void testDatabase() { Assertions.assertTrue(propertiesResp.containsKey("prop")); Assertions.assertEquals("val", propertiesResp.get("prop")); + // drop property + client.dropDatabaseProperties(DropDatabasePropertiesReq.builder() + .databaseName(tempDatabaseName) + .propertyKeys(Collections.singletonList("prop")) + .build()); + descDBResp = client.describeDatabase(DescribeDatabaseReq.builder() + .databaseName(tempDatabaseName) + .build()); + propertiesResp = descDBResp.getProperties(); + Assertions.assertFalse(propertiesResp.containsKey("prop")); + // switch to the new database Assertions.assertDoesNotThrow(()->client.useDatabase(tempDatabaseName));