فهرست منبع

Change default shard number (#551)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
groot 1 سال پیش
والد
کامیت
633ac23dd3

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

@@ -75,7 +75,6 @@ public class Constant {
     // high level api
     public static final String VECTOR_FIELD_NAME_DEFAULT  = "vector";
     public static final String PRIMARY_FIELD_NAME_DEFAULT = "id";
-    public static final int SHARD_NUMBER_DEFAULT = 2;
     public static final String VECTOR_INDEX_NAME_DEFAULT  = "vector_idx";
     public static final Long LIMIT_DEFAULT = 100L;
     public static final Long OFFSET_DEFAULT = 0L;

+ 3 - 2
src/main/java/io/milvus/param/bulkinsert/ListBulkInsertTasksParam.java

@@ -46,7 +46,7 @@ public class ListBulkInsertTasksParam {
      * Builder for {@link ListBulkInsertTasksParam} class.
      */
     public static final class Builder {
-        private String collectionName;
+        private String collectionName = ""; // empty string will list all tasks in the server side
 
         // The limit count of returned tasks, list all tasks if the value is 0
         // default by 0
@@ -57,6 +57,7 @@ public class ListBulkInsertTasksParam {
 
         /**
          * Sets the target collection name, list all tasks if the name is empty.
+         * Default value is an empty string.
          *
          * @param collectionName collection name
          * @return <code>Builder</code>
@@ -68,7 +69,7 @@ public class ListBulkInsertTasksParam {
 
         /**
          * Specify limit count of returned tasks, list all tasks if the value is 0.
-         * default value is 0
+         * Default value is 0
          *
          * @param limit limit number
          * @return <code>Builder</code>

+ 6 - 4
src/main/java/io/milvus/param/collection/CreateCollectionParam.java

@@ -65,7 +65,7 @@ public class CreateCollectionParam {
      */
     public static final class Builder {
         private String collectionName;
-        private int shardsNum = 2;
+        private int shardsNum = 0; // default to 0, let server decide the value
         private String description = "";
         private final List<FieldType> fieldTypes = new ArrayList<>();
         private int partitionsNum = 0;
@@ -99,7 +99,9 @@ public class CreateCollectionParam {
         }
 
         /**
-         * Sets the shards number. The number must be greater than zero. The default value is 2.
+         * Sets the shards number. The number must be greater or equal to zero.
+         * The default value is 0, which means letting the server decide the value.
+         * The server set this value to 1 if user didn't specify it.
          *
          * @param shardsNum shards number to distribute insert data into multiple data nodes and query nodes.
          * @return <code>Builder</code>
@@ -189,8 +191,8 @@ public class CreateCollectionParam {
         public CreateCollectionParam build() throws ParamException {
             ParamUtils.CheckNullEmptyString(collectionName, "Collection name");
 
-            if (shardsNum <= 0) {
-                throw new ParamException("ShardNum must be larger than 0");
+            if (shardsNum < 0) {
+                throw new ParamException("ShardNum must be larger or equal to 0");
             }
 
             if (fieldTypes.isEmpty()) {

+ 0 - 1
src/main/java/io/milvus/param/highlevel/collection/CreateSimpleCollectionParam.java

@@ -246,7 +246,6 @@ public class CreateSimpleCollectionParam {
             );
             CreateCollectionParam createCollectionParam = CreateCollectionParam.newBuilder()
                     .withCollectionName(collectionName)
-                    .withShardsNum(Constant.SHARD_NUMBER_DEFAULT)
                     .withDescription(description)
                     .withFieldTypes(fieldTypes)
                     .withConsistencyLevel(consistencyLevel)

+ 1 - 1
src/test/java/io/milvus/client/MilvusServiceClientTest.java

@@ -372,7 +372,7 @@ class MilvusServiceClientTest {
                 CreateCollectionParam
                         .newBuilder()
                         .withCollectionName("collection1")
-                        .withShardsNum(0)
+                        .withShardsNum(-1)
                         .addFieldType(fieldType1)
                         .build()
         );