Ver código fonte

Bulkload response changed (#314)

Signed-off-by: groot <yihua.mo@zilliz.com>
groot 2 anos atrás
pai
commit
573af9c04c

+ 1 - 1
docker-compose.yml

@@ -31,7 +31,7 @@ services:
 
   standalone:
     container_name: milvus-javasdk-test-standalone
-    image: milvusdb/milvus-dev:master-20220607-b5c11a21
+    image: milvusdb/milvus-dev:master-20220615-ea5041ae
     command: ["milvus", "run", "standalone"]
     environment:
       ETCD_ENDPOINTS: etcd:2379

+ 2 - 0
src/main/java/io/milvus/param/Constant.java

@@ -37,6 +37,8 @@ public class Constant {
     public static final String BUCKET = "bucket";
     public static final String FAILED_REASON = "failed_reason";
     public static final String IMPORT_FILES = "files";
+    public static final String IMPORT_COLLECTION = "collection";
+    public static final String IMPORT_PARTITION = "partition";
     public static final String DEFAULT_INDEX_NAME = "_default_idx";
 
     // max value for waiting loading collection/partition interval, unit: millisecond

+ 45 - 9
src/main/java/io/milvus/response/GetBulkloadStateWrapper.java

@@ -1,11 +1,14 @@
 package io.milvus.response;
 
+import io.milvus.exception.IllegalResponseException;
+import io.milvus.exception.MilvusException;
 import io.milvus.grpc.GetImportStateResponse;
 import io.milvus.grpc.ImportState;
 import io.milvus.grpc.KeyValuePair;
 import io.milvus.param.Constant;
 import lombok.NonNull;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -33,7 +36,22 @@ public class GetBulkloadStateWrapper {
      * @return List&lt;Long&gt; ID array returned by bulk load task
      */
     public List<Long> getAutoGeneratedIDs() {
-        return response.getIdListList();
+        // the id list of response is id ranges
+        // for example, if the response return [1, 100, 200, 250]
+        // the full id list should be [1, 2, 3 ... , 99, 100, 200, 201, 202 ... , 249, 250]
+        List<Long> ranges = response.getIdListList();
+        if (ranges.size()%2 != 0) {
+            throw new IllegalResponseException("The bulkload state response id range list is illegal");
+        }
+        List<Long> ids = new ArrayList<>();
+        for (int i = 0; i < ranges.size()/2; i++) {
+            Long begin = ranges.get(i*2);
+            Long end = ranges.get(i*2+1);
+            for (long j = begin; j <= end; j++) {
+                ids.add(j);
+            }
+        }
+        return ids;
     }
 
     /**
@@ -73,21 +91,39 @@ public class GetBulkloadStateWrapper {
     }
 
     /**
-     * A flag indicating (heuristically) whether import data are queryable (i.e. loaded in query nodes).
+     * Gets target collection name of the bulk load task.
+     *
+     * @return String target collection name
+     */
+    public String getCollectionName() {
+        return getInfo(Constant.IMPORT_COLLECTION);
+    }
+
+    /**
+     * Gets target partition name of the bulk load task.
+     *
+     * @return String target partition name
+     */
+    public String getPartitionName() {
+        return getInfo(Constant.IMPORT_PARTITION);
+    }
+
+    /**
+     * A flag indicating whether import data are queryable (i.e. loaded in query nodes).
      *
-     * @return boolean whether import data are queryable(heuristically)
+     * @return boolean whether import data are queryable
      */
-    public boolean HeuristicQueryable() {
-        return response.getHeuristicDataQueryable();
+    public boolean queryable() {
+        return response.getDataQueryable();
     }
 
     /**
-     * A flag indicating (heuristically) whether import data are indexed.
+     * A flag indicating whether import data are indexed.
      *
-     * @return boolean whether import data are queryable(heuristically)
+     * @return boolean whether import data are queryable
      */
-    public boolean HeuristicIndexed() {
-        return response.getHeuristicDataQueryable();
+    public boolean indexed() {
+        return response.getDataIndexed();
     }
 
     private String getInfo(@NonNull String key) {

+ 1 - 1
src/main/milvus-proto

@@ -1 +1 @@
-Subproject commit 92cb0e17d8c79add055f59aab78dd20dbe87565a
+Subproject commit df5c6a9fd317e0df9d0241f1a9c0715e5d8d2562

+ 21 - 8
src/test/java/io/milvus/client/MilvusServiceClientTest.java

@@ -2674,14 +2674,16 @@ class MilvusServiceClientTest {
     @Test
     void testGetBulkloadStateWrapper() {
         long count = 1000;
-        long id = 88;
         ImportState state = ImportState.ImportStarted;
         String reason = "unexpected error";
         String files = "1.json";
+        String collection = "c1";
+        String partition = "p1";
         GetImportStateResponse reso = GetImportStateResponse.newBuilder()
                 .setState(state)
                 .setRowCount(count)
-                .addIdList(id)
+                .addIdList(0)
+                .addIdList(99)
                 .addInfos(KeyValuePair.newBuilder()
                         .setKey(Constant.FAILED_REASON)
                         .setValue(reason)
@@ -2690,18 +2692,29 @@ class MilvusServiceClientTest {
                         .setKey(Constant.IMPORT_FILES)
                         .setValue(files)
                         .build())
-                .setHeuristicDataQueryable(false)
-                .setHeuristicDataIndexed(false)
+                .addInfos(KeyValuePair.newBuilder()
+                        .setKey(Constant.IMPORT_COLLECTION)
+                        .setValue(collection)
+                        .build())
+                .addInfos(KeyValuePair.newBuilder()
+                        .setKey(Constant.IMPORT_PARTITION)
+                        .setValue(partition)
+                        .build())
+                .setDataQueryable(false)
+                .setDataIndexed(false)
                 .build();
 
         GetBulkloadStateWrapper wrapper = new GetBulkloadStateWrapper(reso);
         assertEquals(count, wrapper.getImportedCount());
-        assertEquals(1, wrapper.getAutoGeneratedIDs().size());
-        assertEquals(id, wrapper.getAutoGeneratedIDs().get(0));
+        assertEquals(100, wrapper.getAutoGeneratedIDs().size());
+        assertEquals(0, wrapper.getAutoGeneratedIDs().get(0));
+        assertEquals(99, wrapper.getAutoGeneratedIDs().get(99));
         assertEquals(reason, wrapper.getFailedReason());
         assertEquals(files, wrapper.getFiles());
-        assertEquals(false, wrapper.HeuristicQueryable());
-        assertEquals(false, wrapper.HeuristicIndexed());
+        assertEquals(collection, wrapper.getCollectionName());
+        assertEquals(partition, wrapper.getPartitionName());
+        assertEquals(false, wrapper.queryable());
+        assertEquals(false, wrapper.indexed());
 
         assertFalse(wrapper.toString().isEmpty());
     }