Browse Source

Consistency level can be default (#521)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
groot 2 years ago
parent
commit
8bf2bf4af6

+ 1 - 1
src/main/java/io/milvus/common/clientenum/ConsistencyLevelEnum.java

@@ -6,7 +6,7 @@ public enum ConsistencyLevelEnum {
 
 
     STRONG("Strong", 0),
     STRONG("Strong", 0),
     // Session level is not allowed here because no ORM is implemented
     // Session level is not allowed here because no ORM is implemented
-    SESSION("Session", 1),
+//    SESSION("Session", 1),
     BOUNDED("Bounded", 2),
     BOUNDED("Bounded", 2),
     EVENTUALLY("Eventually",3),
     EVENTUALLY("Eventually",3),
     ;
     ;

+ 11 - 1
src/main/java/io/milvus/param/ParamUtils.java

@@ -471,6 +471,11 @@ public class ParamUtils {
         builder.setTravelTimestamp(requestParam.getTravelTimestamp());
         builder.setTravelTimestamp(requestParam.getTravelTimestamp());
         builder.setGuaranteeTimestamp(guaranteeTimestamp);
         builder.setGuaranteeTimestamp(guaranteeTimestamp);
 
 
+        // a new parameter from v2.2.9, if user didn't specify consistency level, set this parameter to true
+        if (requestParam.getConsistencyLevel() == null) {
+            builder.setUseDefaultConsistency(true);
+        }
+
         return builder.build();
         return builder.build();
     }
     }
 
 
@@ -485,6 +490,11 @@ public class ParamUtils {
                 .setTravelTimestamp(requestParam.getTravelTimestamp())
                 .setTravelTimestamp(requestParam.getTravelTimestamp())
                 .setGuaranteeTimestamp(guaranteeTimestamp);
                 .setGuaranteeTimestamp(guaranteeTimestamp);
 
 
+        // a new parameter from v2.2.9, if user didn't specify consistency level, set this parameter to true
+        if (requestParam.getConsistencyLevel() == null) {
+            builder.setUseDefaultConsistency(true);
+        }
+
         // set offset and limit value.
         // set offset and limit value.
         // directly pass the two values, the server will verify them.
         // directly pass the two values, the server will verify them.
         long offset = requestParam.getOffset();
         long offset = requestParam.getOffset();
@@ -515,7 +525,7 @@ public class ParamUtils {
     private static long getGuaranteeTimestamp(ConsistencyLevelEnum consistencyLevel,
     private static long getGuaranteeTimestamp(ConsistencyLevelEnum consistencyLevel,
                                               long guaranteeTimestamp, Long gracefulTime){
                                               long guaranteeTimestamp, Long gracefulTime){
         if(consistencyLevel == null){
         if(consistencyLevel == null){
-            return guaranteeTimestamp;
+            return 1L;
         }
         }
         switch (consistencyLevel){
         switch (consistencyLevel){
             case STRONG:
             case STRONG:

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

@@ -69,7 +69,7 @@ public class CreateCollectionParam {
         private String description = "";
         private String description = "";
         private final List<FieldType> fieldTypes = new ArrayList<>();
         private final List<FieldType> fieldTypes = new ArrayList<>();
         private int partitionsNum = 0;
         private int partitionsNum = 0;
-        private ConsistencyLevelEnum consistencyLevel = ConsistencyLevelEnum.SESSION;
+        private ConsistencyLevelEnum consistencyLevel = ConsistencyLevelEnum.BOUNDED;
         private String databaseName;
         private String databaseName;
 
 
         private boolean enableDynamicField;
         private boolean enableDynamicField;

+ 4 - 0
src/main/java/io/milvus/param/dml/InsertParam.java

@@ -139,6 +139,10 @@ public class InsertParam {
 
 
             int count = 0;
             int count = 0;
             if (CollectionUtils.isNotEmpty(fields)) {
             if (CollectionUtils.isNotEmpty(fields)) {
+                if (fields.get(0) == null) {
+                    throw new ParamException("Field cannot be null." +
+                            " If the field is auto-id, just ignore it from withFields()");
+                }
                 count = fields.get(0).getValues().size();
                 count = fields.get(0).getValues().size();
                 checkFields(count);
                 checkFields(count);
             } else {
             } else {

+ 1 - 1
src/main/java/io/milvus/param/dml/QueryParam.java

@@ -76,7 +76,7 @@ public class QueryParam {
         private Long travelTimestamp = 0L;
         private Long travelTimestamp = 0L;
         private Long gracefulTime = 5000L;
         private Long gracefulTime = 5000L;
         private Long guaranteeTimestamp = Constant.GUARANTEE_EVENTUALLY_TS;
         private Long guaranteeTimestamp = Constant.GUARANTEE_EVENTUALLY_TS;
-        private ConsistencyLevelEnum consistencyLevel;
+        private ConsistencyLevelEnum consistencyLevel = null;
         private Long offset = 0L;
         private Long offset = 0L;
         private Long limit = 0L;
         private Long limit = 0L;
         private Boolean ignoreGrowing = Boolean.FALSE;
         private Boolean ignoreGrowing = Boolean.FALSE;

+ 1 - 1
src/main/java/io/milvus/param/dml/SearchParam.java

@@ -94,7 +94,7 @@ public class SearchParam {
         private Long travelTimestamp = 0L;
         private Long travelTimestamp = 0L;
         private Long guaranteeTimestamp = Constant.GUARANTEE_EVENTUALLY_TS;
         private Long guaranteeTimestamp = Constant.GUARANTEE_EVENTUALLY_TS;
         private Long gracefulTime = 5000L;
         private Long gracefulTime = 5000L;
-        private ConsistencyLevelEnum consistencyLevel;
+        private ConsistencyLevelEnum consistencyLevel = null;
         private Boolean ignoreGrowing = Boolean.FALSE;
         private Boolean ignoreGrowing = Boolean.FALSE;
 
 
        Builder() {
        Builder() {

+ 1 - 1
src/main/milvus-proto

@@ -1 +1 @@
-Subproject commit 2975bfe7a190d38d1d44d9f1379483e93b1fbb4a
+Subproject commit 96b086f03faffd024b73929cfe8ef10e32414f1d