Explorar o código

Add refresh parameter to load api (#430)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
groot %!s(int64=2) %!d(string=hai) anos
pai
achega
149abc9330

+ 4 - 4
docker-compose.yml

@@ -14,7 +14,7 @@ services:
 
   minio:
     container_name: milvus-javasdk-test-minio
-    image: minio/minio:RELEASE.2020-12-03T00-03-10Z
+    image: minio/minio:RELEASE.2022-03-17T06-34-49Z
     ports:
       - "9000:9000"
     environment:
@@ -31,7 +31,7 @@ services:
 
   standalone:
     container_name: milvus-javasdk-test-standalone
-    image: milvusdb/milvus:master-20221122-f76ea292
+    image: milvusdb/milvus:master-20230119-e96af4e5
     command: ["milvus", "run", "standalone"]
     environment:
       ETCD_ENDPOINTS: etcd:2379
@@ -58,7 +58,7 @@ services:
 
   minioslave:
     container_name: milvus-javasdk-test-minio-slave
-    image: minio/minio:RELEASE.2020-12-03T00-03-10Z
+    image: minio/minio:RELEASE.2022-03-17T06-34-49Z
     ports:
       - "9001:9000"
     environment:
@@ -75,7 +75,7 @@ services:
 
   standaloneslave:
     container_name: milvus-javasdk-test-slave-standalone
-    image: milvusdb/milvus:master-20221122-f76ea292
+    image: milvusdb/milvus:master-20230119-e96af4e5
     command: ["milvus", "run", "standalone"]
     environment:
       ETCD_ENDPOINTS: etcdslave:2379

+ 2 - 0
src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java

@@ -492,6 +492,7 @@ public abstract class AbstractMilvusGrpcClient implements MilvusClient {
             LoadCollectionRequest loadCollectionRequest = LoadCollectionRequest.newBuilder()
                     .setCollectionName(requestParam.getCollectionName())
                     .setReplicaNumber(requestParam.getReplicaNumber())
+                    .setRefresh(requestParam.isRefresh())
                     .build();
 
             Status response = blockingStub().loadCollection(loadCollectionRequest);
@@ -809,6 +810,7 @@ public abstract class AbstractMilvusGrpcClient implements MilvusClient {
                     .setCollectionName(requestParam.getCollectionName())
                     .setReplicaNumber(requestParam.getReplicaNumber())
                     .addAllPartitionNames(requestParam.getPartitionNames())
+                    .setRefresh(requestParam.isRefresh())
                     .build();
 
             Status response = blockingStub().loadPartitions(loadPartitionsRequest);

+ 23 - 0
src/main/java/io/milvus/param/collection/LoadCollectionParam.java

@@ -38,6 +38,7 @@ public class LoadCollectionParam {
     private final long syncLoadWaitingInterval;
     private final long syncLoadWaitingTimeout;
     private final int replicaNumber;
+    private final boolean refresh;
 
     public LoadCollectionParam(@NonNull Builder builder) {
         this.collectionName = builder.collectionName;
@@ -45,6 +46,7 @@ public class LoadCollectionParam {
         this.syncLoadWaitingInterval = builder.syncLoadWaitingInterval;
         this.syncLoadWaitingTimeout = builder.syncLoadWaitingTimeout;
         this.replicaNumber = builder.replicaNumber;
+        this.refresh = builder.refresh;
     }
 
     public static Builder newBuilder() {
@@ -75,6 +77,12 @@ public class LoadCollectionParam {
         //   The replica number to load, default by 1
         private Integer replicaNumber = 1;
 
+        // refresh:
+        //   This flag must be set to FALSE when first time call the loadCollection().
+        //   After loading a collection, call loadCollection() again with refresh=TRUE,
+        //   the server will look for new segments that are not loaded yet and tries to load them up.
+        private Boolean refresh = Boolean.FALSE;
+
         private Builder() {
         }
 
@@ -140,6 +148,21 @@ public class LoadCollectionParam {
             return this;
         }
 
+        /**
+         * Whether to enable refresh mode.
+         * Refresh mode renews the segment list of this collection before loading.
+         * This flag must be set to FALSE when first time call the loadCollection().
+         * After loading a collection, call loadCollection() again with refresh=TRUE,
+         * the server will look for new segments that are not loaded yet and tries to load them up.
+         *
+         * @param refresh <code>Boolean.TRUE</code> is refresh mode, <code>Boolean.FALSE</code> is not
+         * @return <code>Builder</code>
+         */
+        public Builder withRefresh(@NonNull Boolean refresh) {
+            this.refresh = refresh;
+            return this;
+        }
+
         /**
          * Verifies parameters and creates a new {@link LoadCollectionParam} instance.
          *

+ 23 - 0
src/main/java/io/milvus/param/partition/LoadPartitionsParam.java

@@ -41,6 +41,7 @@ public class LoadPartitionsParam {
     private final long syncLoadWaitingInterval;
     private final long syncLoadWaitingTimeout;
     private final int replicaNumber;
+    private final boolean refresh;
 
     private LoadPartitionsParam(@NonNull Builder builder) {
         this.collectionName = builder.collectionName;
@@ -49,6 +50,7 @@ public class LoadPartitionsParam {
         this.syncLoadWaitingInterval = builder.syncLoadWaitingInterval;
         this.syncLoadWaitingTimeout = builder.syncLoadWaitingTimeout;
         this.replicaNumber = builder.replicaNumber;
+        this.refresh = builder.refresh;
     }
 
     public static Builder newBuilder() {
@@ -80,6 +82,12 @@ public class LoadPartitionsParam {
         //   The replica number to load, default by 1
         private Integer replicaNumber = 1;
 
+        // refresh:
+        //   This flag must be set to FALSE when first time call the loadPartitions().
+        //   After loading a partition, call loadPartitions() again with refresh=TRUE,
+        //   the server will look for new segments that are not loaded yet and tries to load them up.
+        private Boolean refresh = Boolean.FALSE;
+
         private Builder() {
         }
 
@@ -169,6 +177,21 @@ public class LoadPartitionsParam {
             return this;
         }
 
+        /**
+         * Whether to enable refresh mode.
+         * Refresh mode renews the segment list of this collection before loading.
+         * This flag must be set to FALSE when first time call the loadPartitions().
+         * After loading a collection, call loadPartitions() again with refresh=TRUE,
+         * the server will look for new segments that are not loaded yet and tries to load them up.
+         *
+         * @param refresh <code>Boolean.TRUE</code> is refresh mode, <code>Boolean.FALSE</code> is not
+         * @return <code>Builder</code>
+         */
+        public Builder withRefresh(@NonNull Boolean refresh) {
+            this.refresh = refresh;
+            return this;
+        }
+
         /**
          * Verifies parameters and creates a new {@link LoadPartitionsParam} instance.
          *

+ 1 - 1
src/main/milvus-proto

@@ -1 +1 @@
-Subproject commit 44f59db22b27cc55e4168c8e53b6e781c010a713
+Subproject commit 4ebfc4f769740e30bacd2952f982fc84c6b05af3