Browse Source

Use google-java-format

Signed-off-by: sahuang <xiaohai.xu@zilliz.com>
sahuang 4 years ago
parent
commit
ce311b3475
29 changed files with 1048 additions and 819 deletions
  1. 4 3
      README.md
  2. 2 2
      examples/pom.xml
  3. 1 1
      examples/src/main/java/MilvusBasicExample.java
  4. 1 1
      examples/src/main/java/MilvusIndexExample.java
  5. 41 40
      src/main/java/io/milvus/client/CollectionMapping.java
  6. 6 6
      src/main/java/io/milvus/client/CompactParam.java
  7. 6 5
      src/main/java/io/milvus/client/ConnectParam.java
  8. 1 3
      src/main/java/io/milvus/client/DataType.java
  9. 12 15
      src/main/java/io/milvus/client/Index.java
  10. 34 25
      src/main/java/io/milvus/client/InsertParam.java
  11. 50 29
      src/main/java/io/milvus/client/LoggingAdapter.java
  12. 36 39
      src/main/java/io/milvus/client/MilvusClient.java
  13. 286 197
      src/main/java/io/milvus/client/MilvusGrpcClient.java
  14. 51 49
      src/main/java/io/milvus/client/SearchParam.java
  15. 19 13
      src/main/java/io/milvus/client/SearchResult.java
  16. 14 12
      src/main/java/io/milvus/client/dsl/BoolQuery.java
  17. 11 8
      src/main/java/io/milvus/client/dsl/MilvusService.java
  18. 1 2
      src/main/java/io/milvus/client/dsl/Query.java
  19. 7 5
      src/main/java/io/milvus/client/dsl/RangeQuery.java
  20. 10 8
      src/main/java/io/milvus/client/dsl/Schema.java
  21. 1 2
      src/main/java/io/milvus/client/dsl/TermQuery.java
  22. 40 23
      src/main/java/io/milvus/client/dsl/VectorQuery.java
  23. 1 1
      src/main/java/io/milvus/client/exception/InvalidDsl.java
  24. 2 2
      src/main/java/io/milvus/client/exception/MilvusException.java
  25. 2 2
      src/main/java/io/milvus/client/exception/ServerSideMilvusException.java
  26. 5 4
      src/main/java/io/milvus/client/exception/UnsupportedServerVersion.java
  27. 217 202
      src/test/java/io/milvus/client/MilvusGrpcClientTest.java
  28. 6 7
      src/test/java/io/milvus/client/StaticNameResolverProvider.java
  29. 181 113
      src/test/java/io/milvus/client/dsl/SearchDslTest.java

+ 4 - 3
README.md

@@ -15,6 +15,7 @@ The following table shows compatibilities between Milvus and Java SDK.
 
 | Milvus version | Java SDK version |
 | :------------: | :--------------: |
+|     0.11.1     |    0.9.2         |
 |     0.11.0     |    0.9.1         |
 |     0.10.3     |    0.8.5         |
 |     0.10.2     |    0.8.4         |
@@ -35,19 +36,19 @@ You can use **Apache Maven** or **Gradle**/**Grails** to download the SDK.
         <dependency>
             <groupId>io.milvus</groupId>
             <artifactId>milvus-sdk-java</artifactId>
-            <version>0.9.1</version>
+            <version>0.9.2</version>
         </dependency>
        ```
 
    - Gradle/Grails
 
         ```gradle
-        compile 'io.milvus:milvus-sdk-java:0.9.1'
+        compile 'io.milvus:milvus-sdk-java:0.9.2'
         ```
 
 ### Examples
 
-Please refer to [examples](https://github.com/milvus-io/milvus-sdk-java/tree/0.9.1/examples) folder for Java SDK examples.
+Please refer to [examples](https://github.com/milvus-io/milvus-sdk-java/tree/0.9.2/examples) folder for Java SDK examples.
 
 ### Documentation
 

+ 2 - 2
examples/pom.xml

@@ -25,7 +25,7 @@
 
     <groupId>io.milvus</groupId>
     <artifactId>milvus-sdk-java-examples</artifactId>
-    <version>0.9.1</version>
+    <version>0.9.2</version>
     <build>
         <plugins>
             <plugin>
@@ -63,7 +63,7 @@
         <dependency>
             <groupId>io.milvus</groupId>
             <artifactId>milvus-sdk-java</artifactId>
-            <version>0.9.1</version>
+            <version>0.9.2-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>

+ 1 - 1
examples/src/main/java/MilvusBasicExample.java

@@ -39,7 +39,7 @@ import java.util.stream.DoubleStream;
 import org.json.JSONObject;
 
 /**
- * This is a simple example demonstrating how to use Milvus Java SDK v0.9.1. For detailed API
+ * This is a simple example demonstrating how to use Milvus Java SDK v0.9.2. For detailed API
  * documentation, please refer to
  * https://milvus-io.github.io/milvus-sdk-java/javadoc/io/milvus/client/package-summary.html You can
  * also find more information on https://milvus.io/docs/overview.md

+ 1 - 1
examples/src/main/java/MilvusIndexExample.java

@@ -41,7 +41,7 @@ import java.util.stream.DoubleStream;
 import org.json.JSONObject;
 
 /**
- * This is an example of Milvus Java SDK v0.9.1. In particular, we demonstrate how we can build and
+ * This is an example of Milvus Java SDK v0.9.2. In particular, we demonstrate how we can build and
  * search by index in Milvus.
  *
  * <p>We will be using `films.csv` as our dataset. There are 4 columns in the file, namely `id`,

+ 41 - 40
src/main/java/io/milvus/client/CollectionMapping.java

@@ -23,23 +23,15 @@ import com.google.common.collect.ImmutableMap;
 import io.milvus.grpc.FieldParam;
 import io.milvus.grpc.KeyValuePair;
 import io.milvus.grpc.Mapping;
-import org.json.JSONObject;
-
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
+import org.json.JSONObject;
 
 /** Represents a collection mapping */
 public class CollectionMapping {
   private final Mapping.Builder builder;
 
-  /**
-   * @param collectionName collection name
-   */
-  public static CollectionMapping create(String collectionName) {
-    return new CollectionMapping(collectionName);
-  }
-
   CollectionMapping(Mapping mapping) {
     this.builder = mapping.toBuilder();
   }
@@ -49,6 +41,11 @@ public class CollectionMapping {
     builder.setCollectionName(collectionName);
   }
 
+  /** @param collectionName collection name */
+  public static CollectionMapping create(String collectionName) {
+    return new CollectionMapping(collectionName);
+  }
+
   /**
    * add a scalar field
    *
@@ -70,55 +67,59 @@ public class CollectionMapping {
    * @return this CollectionMapping
    */
   public CollectionMapping addVectorField(String name, DataType type, int dimension) {
-    FieldParam field = FieldParam.newBuilder()
-        .setName(name)
-        .setTypeValue(type.getVal())
-        .addExtraParams(KeyValuePair.newBuilder()
-            .setKey(MilvusClient.extraParamKey)
-            .setValue(new JSONObject().put("dim", dimension).toString())
-            .build())
-        .build();
+    FieldParam field =
+        FieldParam.newBuilder()
+            .setName(name)
+            .setTypeValue(type.getVal())
+            .addExtraParams(
+                KeyValuePair.newBuilder()
+                    .setKey(MilvusClient.extraParamKey)
+                    .setValue(new JSONObject().put("dim", dimension).toString())
+                    .build())
+            .build();
     builder.addFields(field);
     return this;
   }
 
   public List<Map<String, Object>> getFields() {
     return builder.getFieldsList().stream()
-        .map(f -> {
-          ImmutableMap.Builder<String, Object> builder = ImmutableMap
-              .<String, Object>builder()
-              .put("name", f.getName())
-              .put("type", DataType.valueOf(f.getType().getNumber()));
-          String paramsInJson = getParamsInJson(f.getExtraParamsList());
-          if (paramsInJson != null) {
-            builder.put(MilvusClient.extraParamKey, paramsInJson);
-          }
-          return builder.build();
-        })
+        .map(
+            f -> {
+              ImmutableMap.Builder<String, Object> builder =
+                  ImmutableMap.<String, Object>builder()
+                      .put("name", f.getName())
+                      .put("type", DataType.valueOf(f.getType().getNumber()));
+              String paramsInJson = getParamsInJson(f.getExtraParamsList());
+              if (paramsInJson != null) {
+                builder.put(MilvusClient.extraParamKey, paramsInJson);
+              }
+              return builder.build();
+            })
         .collect(Collectors.toList());
   }
 
+  public String getParamsInJson() {
+    return getParamsInJson(builder.getExtraParamsList());
+  }
+
   /**
    * Set extra params in json string
    *
-   * @param paramsInJson Two optional parameters can be included. "segment_row_limit" is default
-   *                     to 100,000. Merge will be triggered if more than this number of entities
-   *                     are inserted into collection. "auto_id" is default to <code>true</code>.
-   *                     Entity ids will be auto-generated by Milvus if set to true.
+   * @param paramsInJson Two optional parameters can be included. "segment_row_limit" is default to
+   *     100,000. Merge will be triggered if more than this number of entities are inserted into
+   *     collection. "auto_id" is default to <code>true</code>. Entity ids will be auto-generated by
+   *     Milvus if set to true.
    * @return this CollectionMapping
    */
   public CollectionMapping setParamsInJson(String paramsInJson) {
-    builder.addExtraParams(KeyValuePair.newBuilder()
-        .setKey(MilvusClient.extraParamKey)
-        .setValue(paramsInJson)
-        .build());
+    builder.addExtraParams(
+        KeyValuePair.newBuilder()
+            .setKey(MilvusClient.extraParamKey)
+            .setValue(paramsInJson)
+            .build());
     return this;
   }
 
-  public String getParamsInJson() {
-    return getParamsInJson(builder.getExtraParamsList());
-  }
-
   public String getCollectionName() {
     return builder.getCollectionName();
   }

+ 6 - 6
src/main/java/io/milvus/client/CompactParam.java

@@ -21,18 +21,18 @@ package io.milvus.client;
 
 /** Contains parameters for <code>compact</code> */
 public class CompactParam {
-  private io.milvus.grpc.CompactParam.Builder builder;
-
-  /** @param collectionName collection to compact */
-  public static CompactParam create(String collectionName) {
-    return new CompactParam(collectionName);
-  }
+  private final io.milvus.grpc.CompactParam.Builder builder;
 
   private CompactParam(String collectionName) {
     builder = io.milvus.grpc.CompactParam.newBuilder();
     builder.setCollectionName(collectionName).setThreshold(0.2);
   }
 
+  /** @param collectionName collection to compact */
+  public static CompactParam create(String collectionName) {
+    return new CompactParam(collectionName);
+  }
+
   /**
    * Optional. Default to 0.2. Segment will compact if and only if the percentage of entities
    * deleted exceeds the threshold.

+ 6 - 5
src/main/java/io/milvus/client/ConnectParam.java

@@ -20,9 +20,8 @@
 package io.milvus.client;
 
 import io.grpc.ManagedChannelBuilder;
-
-import javax.annotation.Nonnull;
 import java.util.concurrent.TimeUnit;
+import javax.annotation.Nonnull;
 
 /** Contains parameters for connecting to Milvus server */
 public class ConnectParam {
@@ -35,7 +34,10 @@ public class ConnectParam {
   private final long idleTimeoutNanos;
 
   private ConnectParam(@Nonnull Builder builder) {
-    this.target = builder.target != null ? builder.target : String.format("dns:///%s:%d", builder.host, builder.port);
+    this.target =
+        builder.target != null
+            ? builder.target
+            : String.format("dns:///%s:%d", builder.host, builder.port);
     this.defaultLoadBalancingPolicy = builder.defaultLoadBalancingPolicy;
     this.connectTimeoutNanos = builder.connectTimeoutNanos;
     this.keepAliveTimeNanos = builder.keepAliveTimeNanos;
@@ -90,7 +92,6 @@ public class ConnectParam {
      *
      * @param target a GRPC target string
      * @return <code>Builder</code>
-     *
      * @see ManagedChannelBuilder#forTarget(String)
      */
     public Builder withTarget(@Nonnull String target) {
@@ -175,7 +176,7 @@ public class ConnectParam {
      * expires without any read activity on the connection, the connection is considered dead. An
      * unreasonably small value might be increased. Defaults to 20 seconds.
      *
-     * <p>This value should be at least multiple times the RTT to allow for lost packets.</p>
+     * <p>This value should be at least multiple times the RTT to allow for lost packets.
      *
      * @see <a
      *     href="https://grpc.github.io/grpc-java/javadoc/io/grpc/ManagedChannelBuilder.html#keepAliveTimeout-long-java.util.concurrent.TimeUnit-">

+ 1 - 3
src/main/java/io/milvus/client/DataType.java

@@ -22,9 +22,7 @@ package io.milvus.client;
 import java.util.Arrays;
 import java.util.Optional;
 
-/**
- * Represents available data types.
- */
+/** Represents available data types. */
 public enum DataType {
   NONE(0),
   BOOL(1),

+ 12 - 15
src/main/java/io/milvus/client/Index.java

@@ -21,18 +21,23 @@ package io.milvus.client;
 
 import io.milvus.grpc.IndexParam;
 import io.milvus.grpc.KeyValuePair;
-
-import javax.annotation.Nonnull;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
 
-/** Represents an index containing <code>fieldName</code>, <code>indexName</code> and
- * <code>paramsInJson</code>, which contains index_type, params etc.
+/**
+ * Represents an index containing <code>fieldName</code>, <code>indexName</code> and <code>
+ * paramsInJson</code>, which contains index_type, params etc.
  */
 public class Index {
   private final IndexParam.Builder builder;
 
+  private Index(String collectionName, String fieldName) {
+    this.builder =
+        IndexParam.newBuilder().setCollectionName(collectionName).setFieldName(fieldName);
+  }
+
   /**
    * @param collectionName collection to create index for
    * @param fieldName name of the field on which index is built.
@@ -41,12 +46,6 @@ public class Index {
     return new Index(collectionName, fieldName);
   }
 
-  private Index(String collectionName, String fieldName) {
-    this.builder = IndexParam.newBuilder()
-        .setCollectionName(collectionName)
-        .setFieldName(fieldName);
-  }
-
   public String getCollectionName() {
     return builder.getCollectionName();
   }
@@ -88,10 +87,7 @@ public class Index {
 
   private Index addParam(String key, Object value) {
     builder.addExtraParams(
-        KeyValuePair.newBuilder()
-            .setKey(key)
-            .setValue(String.valueOf(value))
-            .build());
+        KeyValuePair.newBuilder().setKey(key).setValue(String.valueOf(value)).build());
     return this;
   }
 
@@ -112,6 +108,7 @@ public class Index {
   }
 
   private Map<String, String> toMap(List<KeyValuePair> extraParams) {
-    return extraParams.stream().collect(Collectors.toMap(KeyValuePair::getKey, KeyValuePair::getValue));
+    return extraParams.stream()
+        .collect(Collectors.toMap(KeyValuePair::getKey, KeyValuePair::getValue));
   }
 }

+ 34 - 25
src/main/java/io/milvus/client/InsertParam.java

@@ -25,28 +25,27 @@ import io.milvus.grpc.AttrRecord;
 import io.milvus.grpc.FieldValue;
 import io.milvus.grpc.VectorRecord;
 import io.milvus.grpc.VectorRowRecord;
-
 import java.nio.ByteBuffer;
 import java.util.List;
 import java.util.stream.Collectors;
 
 /** Contains parameters for <code>insert</code> */
 public class InsertParam {
-  private io.milvus.grpc.InsertParam.Builder builder;
-
-  /** @param collectionName collection to insert entities to */
-  public static InsertParam create(String collectionName) {
-    return new InsertParam(collectionName);
-  }
+  private final io.milvus.grpc.InsertParam.Builder builder;
 
   private InsertParam(String collectionName) {
     this.builder = io.milvus.grpc.InsertParam.newBuilder();
     builder.setCollectionName(collectionName);
   }
 
+  /** @param collectionName collection to insert entities to */
+  public static InsertParam create(String collectionName) {
+    return new InsertParam(collectionName);
+  }
+
   /**
-   * Optional. Only needed when entity ids are not auto-generated by milvus.
-   * This is specified when creating collection.
+   * Optional. Only needed when entity ids are not auto-generated by milvus. This is specified when
+   * creating collection.
    *
    * @param entityIds a <code>List</code> of ids associated with the entities to insert.
    */
@@ -57,6 +56,7 @@ public class InsertParam {
 
   /**
    * Insert into a scalar field.
+   *
    * @param name field name
    * @param type field DataType
    * @param values the field values
@@ -79,16 +79,18 @@ public class InsertParam {
       default:
         throw new UnsupportedDataType("Unsupported data type: " + type.name());
     }
-    builder.addFields(FieldValue.newBuilder()
-        .setFieldName(name)
-        .setTypeValue(type.getVal())
-        .setAttrRecord(record.build())
-        .build());
+    builder.addFields(
+        FieldValue.newBuilder()
+            .setFieldName(name)
+            .setTypeValue(type.getVal())
+            .setAttrRecord(record.build())
+            .build());
     return this;
   }
 
   /**
    * Insert into a vector field.
+   *
    * @param name field name
    * @param type field DataType
    * @param values vectors
@@ -98,24 +100,31 @@ public class InsertParam {
     switch (type) {
       case VECTOR_FLOAT:
         record.addAllRecords(
-            ((List<List<Float>>) values).stream()
-                .map(row -> VectorRowRecord.newBuilder().addAllFloatData(row).build())
-                .collect(Collectors.toList()));
+            ((List<List<Float>>) values)
+                .stream()
+                    .map(row -> VectorRowRecord.newBuilder().addAllFloatData(row).build())
+                    .collect(Collectors.toList()));
         break;
       case VECTOR_BINARY:
         record.addAllRecords(
-            ((List<ByteBuffer>) values).stream()
-                .map(row -> VectorRowRecord.newBuilder().setBinaryData(ByteString.copyFrom(row.slice())).build())
-                .collect(Collectors.toList()));
+            ((List<ByteBuffer>) values)
+                .stream()
+                    .map(
+                        row ->
+                            VectorRowRecord.newBuilder()
+                                .setBinaryData(ByteString.copyFrom(row.slice()))
+                                .build())
+                    .collect(Collectors.toList()));
         break;
       default:
         throw new UnsupportedDataType("Unsupported data type: " + type.name());
     }
-    builder.addFields(FieldValue.newBuilder()
-        .setFieldName(name)
-        .setTypeValue(type.getVal())
-        .setVectorRecord(record.build())
-        .build());
+    builder.addFields(
+        FieldValue.newBuilder()
+            .setFieldName(name)
+            .setTypeValue(type.getVal())
+            .setVectorRecord(record.build())
+            .build());
     return this;
   }
 

+ 50 - 29
src/main/java/io/milvus/client/LoggingAdapter.java

@@ -4,35 +4,51 @@ import com.google.protobuf.Descriptors;
 import com.google.protobuf.MessageOrBuilder;
 import com.google.protobuf.TextFormat;
 import io.grpc.MethodDescriptor;
-import org.slf4j.Logger;
-
 import java.util.List;
 import java.util.concurrent.atomic.AtomicLong;
+import org.slf4j.Logger;
 
 public class LoggingAdapter {
   public static final LoggingAdapter DEFAULT_LOGGING_ADAPTER = new LoggingAdapter();
   private static final AtomicLong traceId = new AtomicLong(0);
 
-  protected LoggingAdapter() {
-  }
+  protected LoggingAdapter() {}
 
   protected String getTraceId() {
     return Long.toHexString(traceId.getAndIncrement());
   }
 
-  protected void logRequest(Logger logger, String traceId, MethodDescriptor method, Object message) {
+  protected void logRequest(
+      Logger logger, String traceId, MethodDescriptor method, Object message) {
     if (logger.isTraceEnabled()) {
-      logger.trace("TraceId: {}, Method: {}, Request: {}", traceId, method.getFullMethodName(), trace(message));
+      logger.trace(
+          "TraceId: {}, Method: {}, Request: {}",
+          traceId,
+          method.getFullMethodName(),
+          trace(message));
     } else if (logger.isInfoEnabled()) {
-      logger.info("TraceId: {}, Method: {}, Request: {}", traceId, method.getFullMethodName(), info(message));
+      logger.info(
+          "TraceId: {}, Method: {}, Request: {}",
+          traceId,
+          method.getFullMethodName(),
+          info(message));
     }
   }
 
-  protected void logResponse(Logger logger, String traceId, MethodDescriptor method, Object message) {
+  protected void logResponse(
+      Logger logger, String traceId, MethodDescriptor method, Object message) {
     if (logger.isTraceEnabled()) {
-      logger.trace("TraceId: {}, Method: {}, Response: {}", traceId, method.getFullMethodName(), trace(message));
+      logger.trace(
+          "TraceId: {}, Method: {}, Response: {}",
+          traceId,
+          method.getFullMethodName(),
+          trace(message));
     } else if (logger.isInfoEnabled()) {
-      logger.info("TraceId: {}, Method: {}, Response: {}", traceId, method.getFullMethodName(), info(message));
+      logger.info(
+          "TraceId: {}, Method: {}, Response: {}",
+          traceId,
+          method.getFullMethodName(),
+          info(message));
     }
   }
 
@@ -55,25 +71,30 @@ public class LoggingAdapter {
 
   protected void write(MessageOrBuilder message, StringBuilder output) {
     output.append(" { ");
-    message.getAllFields().entrySet().stream().forEach(e -> {
-      if (e.getKey().isRepeated()) {
-        output.append(e.getKey().getName())
-            .append(" [ ")
-            .append(((List<?>) e.getValue()).size())
-            .append(" items ], ");
-      } else if (e.getKey().isMapField()) {
-        output.append(e.getKey().getName())
-            .append(" { ")
-            .append(((List<?>) e.getValue()).size())
-            .append(" entries }, ");
-      } else if (e.getKey().getJavaType() == Descriptors.FieldDescriptor.JavaType.MESSAGE) {
-        output.append(e.getKey().getName());
-        write((MessageOrBuilder) e.getValue(), output);
-      } else {
-        output.append(TextFormat.printer().shortDebugString(e.getKey(), e.getValue()))
-            .append(", ");
-      }
-    });
+    message.getAllFields().entrySet().stream()
+        .forEach(
+            e -> {
+              if (e.getKey().isRepeated()) {
+                output
+                    .append(e.getKey().getName())
+                    .append(" [ ")
+                    .append(((List<?>) e.getValue()).size())
+                    .append(" items ], ");
+              } else if (e.getKey().isMapField()) {
+                output
+                    .append(e.getKey().getName())
+                    .append(" { ")
+                    .append(((List<?>) e.getValue()).size())
+                    .append(" entries }, ");
+              } else if (e.getKey().getJavaType() == Descriptors.FieldDescriptor.JavaType.MESSAGE) {
+                output.append(e.getKey().getName());
+                write((MessageOrBuilder) e.getValue(), output);
+              } else {
+                output
+                    .append(TextFormat.printer().shortDebugString(e.getKey(), e.getValue()))
+                    .append(", ");
+              }
+            });
     output.setLength(output.length() - 2);
     output.append(" } ");
   }

+ 36 - 39
src/main/java/io/milvus/client/MilvusClient.java

@@ -20,8 +20,6 @@
 package io.milvus.client;
 
 import com.google.common.util.concurrent.ListenableFuture;
-import org.apache.commons.lang3.exception.ExceptionUtils;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.List;
@@ -29,27 +27,28 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Supplier;
+import org.apache.commons.lang3.exception.ExceptionUtils;
 
 /** The Milvus Client Interface */
 public interface MilvusClient extends AutoCloseable {
 
   String extraParamKey = "params";
 
-  String clientVersion = new Supplier<String>() {
-
-    @Override
-    public String get() {
-      Properties properties = new Properties();
-      try (InputStream inputStream =
-               MilvusClient.class.getClassLoader()
-                   .getResourceAsStream("milvus-client.properties")) {
-        properties.load(inputStream);
-      } catch (IOException ex) {
-        ExceptionUtils.wrapAndThrow(ex);
-      }
-      return properties.getProperty("version");
-    }
-  }.get();
+  String clientVersion =
+      new Supplier<String>() {
+
+        @Override
+        public String get() {
+          Properties properties = new Properties();
+          try (InputStream inputStream =
+              MilvusClient.class.getClassLoader().getResourceAsStream("milvus-client.properties")) {
+            properties.load(inputStream);
+          } catch (IOException ex) {
+            ExceptionUtils.wrapAndThrow(ex);
+          }
+          return properties.getProperty("version");
+        }
+      }.get();
 
   String target();
 
@@ -58,20 +57,17 @@ public interface MilvusClient extends AutoCloseable {
     return clientVersion;
   }
 
-  /**
-   * Close this MilvusClient. Wait at most 1 minute for graceful shutdown.
-   */
+  /** Close this MilvusClient. Wait at most 1 minute for graceful shutdown. */
   default void close() {
     close(TimeUnit.MINUTES.toSeconds(1));
   }
 
-  /**
-   * Close this MilvusClient. Wait at most `maxWaitSeconds` for graceful shutdown.
-   */
+  /** Close this MilvusClient. Wait at most `maxWaitSeconds` for graceful shutdown. */
   void close(long maxWaitSeconds);
 
   /**
    * Milvus service with timeout support.
+   *
    * @param timeout the desired timeout
    * @param timeoutUnit unit for timeout
    */
@@ -81,7 +77,7 @@ public interface MilvusClient extends AutoCloseable {
    * Creates collection specified by <code>collectionMapping</code>
    *
    * @param collectionMapping the <code>CollectionMapping</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * CollectionMapping collectionMapping = CollectionMapping
@@ -119,7 +115,7 @@ public interface MilvusClient extends AutoCloseable {
    * Creates index specified by <code>index</code>
    *
    * @param index the <code>Index</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * Index index = Index.create(collectionName, "float_vec")
@@ -137,7 +133,7 @@ public interface MilvusClient extends AutoCloseable {
    * Creates index specified by <code>index</code> asynchronously
    *
    * @param index the <code>Index</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * Index index = Index.create(collectionName, "float_vec")
@@ -190,7 +186,7 @@ public interface MilvusClient extends AutoCloseable {
    * Inserts data specified by <code>insertParam</code>
    *
    * @param insertParam the <code>InsertParam</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * InsertParam insertParam = InsertParam
@@ -211,7 +207,7 @@ public interface MilvusClient extends AutoCloseable {
    * Inserts data specified by <code>insertParam</code> asynchronously
    *
    * @param insertParam the <code>InsertParam</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * InsertParam insertParam = InsertParam
@@ -223,7 +219,8 @@ public interface MilvusClient extends AutoCloseable {
    * </code>
    * </pre>
    *
-   * @return a <code>ListenableFuture</code> object which holds the list of ids of the inserted entities.
+   * @return a <code>ListenableFuture</code> object which holds the list of ids of the inserted
+   *     entities.
    * @see InsertParam
    * @see ListenableFuture
    */
@@ -233,7 +230,7 @@ public interface MilvusClient extends AutoCloseable {
    * Searches entities specified by <code>searchParam</code>
    *
    * @param searchParam the <code>SearchParam</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * SearchParam searchParam = SearchParam.create(collectionName)
@@ -255,7 +252,7 @@ public interface MilvusClient extends AutoCloseable {
    * Searches entities specified by <code>searchParam</code> asynchronously
    *
    * @param searchParam the <code>SearchParam</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * SearchParam searchParam = SearchParam.create(collectionName)
@@ -330,8 +327,8 @@ public interface MilvusClient extends AutoCloseable {
    * Drops collection index
    *
    * @param collectionName The collection to drop index.
-   * @param fieldName Name of the field to drop index for. If this is set to empty string,
-   *                  index of all fields in the collection will be dropped.
+   * @param fieldName Name of the field to drop index for. If this is set to empty string, index of
+   *     all fields in the collection will be dropped.
    */
   void dropIndex(String collectionName, String fieldName);
 
@@ -342,7 +339,6 @@ public interface MilvusClient extends AutoCloseable {
    * result will be returned as JSON string.
    *
    * @param collectionName collection to show info from
-   *
    * @return collection stats
    */
   String getCollectionStats(String collectionName);
@@ -352,11 +348,12 @@ public interface MilvusClient extends AutoCloseable {
    *
    * @param collectionName collection to get entities from
    * @param ids a <code>List</code> of entity ids
-   * @param fieldNames  a <code>List</code> of field names. Server will only return entity
-   *                    information for these fields.
+   * @param fieldNames a <code>List</code> of field names. Server will only return entity
+   *     information for these fields.
    * @return a map of entity id to entity properties
    */
-  Map<Long, Map<String, Object>> getEntityByID(String collectionName, List<Long> ids, List<String> fieldNames);
+  Map<Long, Map<String, Object>> getEntityByID(
+      String collectionName, List<Long> ids, List<String> fieldNames);
 
   /**
    * Gets entities data by id array
@@ -426,7 +423,7 @@ public interface MilvusClient extends AutoCloseable {
    * until you call compact.
    *
    * @param compactParam the <code>CompactParam</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * CompactParam compactParam = CompactParam.create(collectionName).setThreshold(0.3);
@@ -443,7 +440,7 @@ public interface MilvusClient extends AutoCloseable {
    * until you call compact.
    *
    * @param compactParam the <code>CompactParam</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * CompactParam compactParam = CompactParam.create(collectionName).setThreshold(0.3);

+ 286 - 197
src/main/java/io/milvus/client/MilvusGrpcClient.java

@@ -36,11 +36,31 @@ import io.milvus.client.exception.ClientSideMilvusException;
 import io.milvus.client.exception.MilvusException;
 import io.milvus.client.exception.ServerSideMilvusException;
 import io.milvus.client.exception.UnsupportedServerVersion;
-import io.milvus.grpc.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Nonnull;
+import io.milvus.grpc.AttrRecord;
+import io.milvus.grpc.BoolReply;
+import io.milvus.grpc.CollectionInfo;
+import io.milvus.grpc.CollectionName;
+import io.milvus.grpc.CollectionNameList;
+import io.milvus.grpc.CollectionRowCount;
+import io.milvus.grpc.Command;
+import io.milvus.grpc.DeleteByIDParam;
+import io.milvus.grpc.Entities;
+import io.milvus.grpc.EntityIdentity;
+import io.milvus.grpc.EntityIds;
+import io.milvus.grpc.ErrorCode;
+import io.milvus.grpc.FieldValue;
+import io.milvus.grpc.FlushParam;
+import io.milvus.grpc.GetEntityIDsParam;
+import io.milvus.grpc.IndexParam;
+import io.milvus.grpc.Mapping;
+import io.milvus.grpc.MilvusServiceGrpc;
+import io.milvus.grpc.PartitionList;
+import io.milvus.grpc.PartitionParam;
+import io.milvus.grpc.QueryResult;
+import io.milvus.grpc.Status;
+import io.milvus.grpc.StringReply;
+import io.milvus.grpc.VectorRecord;
+import io.milvus.grpc.VectorRowRecord;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -50,6 +70,9 @@ import java.util.Map;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /** Actual implementation of interface <code>MilvusClient</code> */
 public class MilvusGrpcClient extends AbstractMilvusGrpcClient {
@@ -64,22 +87,25 @@ public class MilvusGrpcClient extends AbstractMilvusGrpcClient {
 
   public MilvusGrpcClient(ConnectParam connectParam) {
     target = connectParam.getTarget();
-    channel = ManagedChannelBuilder
-        .forTarget(connectParam.getTarget())
-        .usePlaintext()
-        .maxInboundMessageSize(Integer.MAX_VALUE)
-        .defaultLoadBalancingPolicy(connectParam.getDefaultLoadBalancingPolicy())
-        .keepAliveTime(connectParam.getKeepAliveTime(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS)
-        .keepAliveTimeout(connectParam.getKeepAliveTimeout(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS)
-        .keepAliveWithoutCalls(connectParam.isKeepAliveWithoutCalls())
-        .idleTimeout(connectParam.getIdleTimeout(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS)
-        .build();
+    channel =
+        ManagedChannelBuilder.forTarget(connectParam.getTarget())
+            .usePlaintext()
+            .maxInboundMessageSize(Integer.MAX_VALUE)
+            .defaultLoadBalancingPolicy(connectParam.getDefaultLoadBalancingPolicy())
+            .keepAliveTime(
+                connectParam.getKeepAliveTime(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS)
+            .keepAliveTimeout(
+                connectParam.getKeepAliveTimeout(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS)
+            .keepAliveWithoutCalls(connectParam.isKeepAliveWithoutCalls())
+            .idleTimeout(connectParam.getIdleTimeout(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS)
+            .build();
     blockingStub = MilvusServiceGrpc.newBlockingStub(channel);
     futureStub = MilvusServiceGrpc.newFutureStub(channel);
     try {
       String serverVersion = getServerVersion();
       if (!serverVersion.matches("^" + SUPPORTED_SERVER_VERSION + "(\\..*)?$")) {
-        throw new UnsupportedServerVersion(connectParam.getTarget(), SUPPORTED_SERVER_VERSION, serverVersion);
+        throw new UnsupportedServerVersion(
+            connectParam.getTarget(), SUPPORTED_SERVER_VERSION, serverVersion);
       }
     } catch (Throwable t) {
       channel.shutdownNow();
@@ -163,7 +189,7 @@ public class MilvusGrpcClient extends AbstractMilvusGrpcClient {
   }
 
   private static class TimeoutInterceptor implements ClientInterceptor {
-    private long timeoutMillis;
+    private final long timeoutMillis;
 
     TimeoutInterceptor(long timeoutMillis) {
       this.timeoutMillis = timeoutMillis;
@@ -172,12 +198,13 @@ public class MilvusGrpcClient extends AbstractMilvusGrpcClient {
     @Override
     public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
         MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next) {
-      return next.newCall(method, callOptions.withDeadlineAfter(timeoutMillis, TimeUnit.MILLISECONDS));
+      return next.newCall(
+          method, callOptions.withDeadlineAfter(timeoutMillis, TimeUnit.MILLISECONDS));
     }
   }
 
   private static class LoggingInterceptor implements ClientInterceptor {
-    private LoggingAdapter loggingAdapter;
+    private final LoggingAdapter loggingAdapter;
 
     LoggingInterceptor(LoggingAdapter loggingAdapter) {
       this.loggingAdapter = loggingAdapter;
@@ -186,8 +213,9 @@ public class MilvusGrpcClient extends AbstractMilvusGrpcClient {
     @Override
     public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
         MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next) {
-      return new ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) {
-        private String traceId = loggingAdapter.getTraceId();
+      return new ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>(
+          next.newCall(method, callOptions)) {
+        private final String traceId = loggingAdapter.getTraceId();
 
         @Override
         public void sendMessage(ReqT message) {
@@ -197,13 +225,16 @@ public class MilvusGrpcClient extends AbstractMilvusGrpcClient {
 
         @Override
         public void start(Listener<RespT> responseListener, Metadata headers) {
-          super.start(new ForwardingClientCallListener.SimpleForwardingClientCallListener<RespT>(responseListener) {
-            @Override
-            public void onMessage(RespT message) {
-              loggingAdapter.logResponse(logger, traceId, method, message);
-              super.onMessage(message);
-            }
-          }, headers);
+          super.start(
+              new ForwardingClientCallListener.SimpleForwardingClientCallListener<RespT>(
+                  responseListener) {
+                @Override
+                public void onMessage(RespT message) {
+                  loggingAdapter.logResponse(logger, traceId, method, message);
+                  super.onMessage(message);
+                }
+              },
+              headers);
         }
       };
     }
@@ -212,13 +243,15 @@ public class MilvusGrpcClient extends AbstractMilvusGrpcClient {
 
 abstract class AbstractMilvusGrpcClient implements MilvusClient {
   protected abstract MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub();
+
   protected abstract MilvusServiceGrpc.MilvusServiceFutureStub futureStub();
 
   private void translateExceptions(Runnable body) {
-    translateExceptions(() -> {
-      body.run();
-      return null;
-    });
+    translateExceptions(
+        () -> {
+          body.run();
+          return null;
+        });
   }
 
   @SuppressWarnings("unchecked")
@@ -227,8 +260,10 @@ abstract class AbstractMilvusGrpcClient implements MilvusClient {
       T result = body.get();
       if (result instanceof ListenableFuture) {
         ListenableFuture futureResult = (ListenableFuture) result;
-        result = (T) Futures.catching(
-            futureResult, Throwable.class, this::translate, MoreExecutors.directExecutor());
+        result =
+            (T)
+                Futures.catching(
+                    futureResult, Throwable.class, this::translate, MoreExecutors.directExecutor());
       }
       return result;
     } catch (Throwable e) {
@@ -255,84 +290,99 @@ abstract class AbstractMilvusGrpcClient implements MilvusClient {
 
   @Override
   public void createCollection(@Nonnull CollectionMapping collectionMapping) {
-    translateExceptions(() -> {
-      Status response = blockingStub().createCollection(collectionMapping.grpc());
-      checkResponseStatus(response);
-    });
+    translateExceptions(
+        () -> {
+          Status response = blockingStub().createCollection(collectionMapping.grpc());
+          checkResponseStatus(response);
+        });
   }
 
   @Override
   public boolean hasCollection(@Nonnull String collectionName) {
-    return translateExceptions(() -> {
-      CollectionName request = CollectionName.newBuilder().setCollectionName(collectionName).build();
-      BoolReply response = blockingStub().hasCollection(request);
-      checkResponseStatus(response.getStatus());
-      return response.getBoolReply();
-    });
+    return translateExceptions(
+        () -> {
+          CollectionName request =
+              CollectionName.newBuilder().setCollectionName(collectionName).build();
+          BoolReply response = blockingStub().hasCollection(request);
+          checkResponseStatus(response.getStatus());
+          return response.getBoolReply();
+        });
   }
 
   @Override
   public void dropCollection(@Nonnull String collectionName) {
-    translateExceptions(() -> {
-      CollectionName request = CollectionName.newBuilder().setCollectionName(collectionName).build();
-      Status response = blockingStub().dropCollection(request);
-      checkResponseStatus(response);
-    });
+    translateExceptions(
+        () -> {
+          CollectionName request =
+              CollectionName.newBuilder().setCollectionName(collectionName).build();
+          Status response = blockingStub().dropCollection(request);
+          checkResponseStatus(response);
+        });
   }
 
   @Override
   public void createIndex(@Nonnull Index index) {
-    translateExceptions(() -> {
-      Futures.getUnchecked(createIndexAsync(index));
-    });
+    translateExceptions(
+        () -> {
+          Futures.getUnchecked(createIndexAsync(index));
+        });
   }
 
   @Override
   public ListenableFuture<Void> createIndexAsync(@Nonnull Index index) {
-    return translateExceptions(() -> {
-      IndexParam request = index.grpc();
-      ListenableFuture<Status> responseFuture = futureStub().createIndex(request);
-      return Futures.transform(responseFuture, this::checkResponseStatus, MoreExecutors.directExecutor());
-    });
+    return translateExceptions(
+        () -> {
+          IndexParam request = index.grpc();
+          ListenableFuture<Status> responseFuture = futureStub().createIndex(request);
+          return Futures.transform(
+              responseFuture, this::checkResponseStatus, MoreExecutors.directExecutor());
+        });
   }
 
   @Override
   public void createPartition(String collectionName, String tag) {
-    translateExceptions(() -> {
-      PartitionParam request = PartitionParam.newBuilder().setCollectionName(collectionName).setTag(tag).build();
-      Status response = blockingStub().createPartition(request);
-      checkResponseStatus(response);
-    });
+    translateExceptions(
+        () -> {
+          PartitionParam request =
+              PartitionParam.newBuilder().setCollectionName(collectionName).setTag(tag).build();
+          Status response = blockingStub().createPartition(request);
+          checkResponseStatus(response);
+        });
   }
 
   @Override
   public boolean hasPartition(String collectionName, String tag) {
-    return translateExceptions(() -> {
-      PartitionParam request = PartitionParam.newBuilder().setCollectionName(collectionName).setTag(tag).build();
-      BoolReply response = blockingStub().hasPartition(request);
-      checkResponseStatus(response.getStatus());
-      return response.getBoolReply();
-    });
+    return translateExceptions(
+        () -> {
+          PartitionParam request =
+              PartitionParam.newBuilder().setCollectionName(collectionName).setTag(tag).build();
+          BoolReply response = blockingStub().hasPartition(request);
+          checkResponseStatus(response.getStatus());
+          return response.getBoolReply();
+        });
   }
 
   @Override
   public List<String> listPartitions(String collectionName) {
-    return translateExceptions(() -> {
-      CollectionName request = CollectionName.newBuilder().setCollectionName(collectionName).build();
-      PartitionList response = blockingStub().showPartitions(request);
-      checkResponseStatus(response.getStatus());
-      return response.getPartitionTagArrayList();
-    });
+    return translateExceptions(
+        () -> {
+          CollectionName request =
+              CollectionName.newBuilder().setCollectionName(collectionName).build();
+          PartitionList response = blockingStub().showPartitions(request);
+          checkResponseStatus(response.getStatus());
+          return response.getPartitionTagArrayList();
+        });
   }
 
   @Override
   public void dropPartition(String collectionName, String tag) {
-    translateExceptions(() -> {
-      PartitionParam request =
-          PartitionParam.newBuilder().setCollectionName(collectionName).setTag(tag).build();
-      Status response = blockingStub().dropPartition(request);
-      checkResponseStatus(response);
-    });
+    translateExceptions(
+        () -> {
+          PartitionParam request =
+              PartitionParam.newBuilder().setCollectionName(collectionName).setTag(tag).build();
+          Status response = blockingStub().dropPartition(request);
+          checkResponseStatus(response);
+        });
   }
 
   @Override
@@ -342,14 +392,18 @@ abstract class AbstractMilvusGrpcClient implements MilvusClient {
 
   @Override
   public ListenableFuture<List<Long>> insertAsync(@Nonnull InsertParam insertParam) {
-    return translateExceptions(() -> {
-      io.milvus.grpc.InsertParam request = insertParam.grpc();
-      ListenableFuture<EntityIds> responseFuture = futureStub().insert(request);
-      return Futures.transform(responseFuture, entityIds -> {
-        checkResponseStatus(entityIds.getStatus());
-        return entityIds.getEntityIdArrayList();
-      }, MoreExecutors.directExecutor());
-    });
+    return translateExceptions(
+        () -> {
+          io.milvus.grpc.InsertParam request = insertParam.grpc();
+          ListenableFuture<EntityIds> responseFuture = futureStub().insert(request);
+          return Futures.transform(
+              responseFuture,
+              entityIds -> {
+                checkResponseStatus(entityIds.getStatus());
+                return entityIds.getEntityIdArrayList();
+              },
+              MoreExecutors.directExecutor());
+        });
   }
 
   @Override
@@ -359,44 +413,53 @@ abstract class AbstractMilvusGrpcClient implements MilvusClient {
 
   @Override
   public ListenableFuture<SearchResult> searchAsync(@Nonnull SearchParam searchParam) {
-    return translateExceptions(() -> {
-      io.milvus.grpc.SearchParam request = searchParam.grpc();
-      ListenableFuture<QueryResult> responseFuture = futureStub().search(request);
-      return Futures.transform(responseFuture, queryResult -> {
-        checkResponseStatus(queryResult.getStatus());
-        return buildSearchResponse(queryResult);
-      }, MoreExecutors.directExecutor());
-    });
+    return translateExceptions(
+        () -> {
+          io.milvus.grpc.SearchParam request = searchParam.grpc();
+          ListenableFuture<QueryResult> responseFuture = futureStub().search(request);
+          return Futures.transform(
+              responseFuture,
+              queryResult -> {
+                checkResponseStatus(queryResult.getStatus());
+                return buildSearchResponse(queryResult);
+              },
+              MoreExecutors.directExecutor());
+        });
   }
 
   @Override
   public CollectionMapping getCollectionInfo(@Nonnull String collectionName) {
-    return translateExceptions(() -> {
-      CollectionName request = CollectionName.newBuilder().setCollectionName(collectionName).build();
-      Mapping response = blockingStub().describeCollection(request);
-      checkResponseStatus(response.getStatus());
-      return new CollectionMapping(response);
-    });
+    return translateExceptions(
+        () -> {
+          CollectionName request =
+              CollectionName.newBuilder().setCollectionName(collectionName).build();
+          Mapping response = blockingStub().describeCollection(request);
+          checkResponseStatus(response.getStatus());
+          return new CollectionMapping(response);
+        });
   }
 
   @Override
   public List<String> listCollections() {
-    return translateExceptions(() -> {
-      Command request = Command.newBuilder().setCmd("").build();
-      CollectionNameList response = blockingStub().showCollections(request);
-      checkResponseStatus(response.getStatus());
-      return response.getCollectionNamesList();
-    });
+    return translateExceptions(
+        () -> {
+          Command request = Command.newBuilder().setCmd("").build();
+          CollectionNameList response = blockingStub().showCollections(request);
+          checkResponseStatus(response.getStatus());
+          return response.getCollectionNamesList();
+        });
   }
 
   @Override
   public long countEntities(@Nonnull String collectionName) {
-    return translateExceptions(() -> {
-      CollectionName request = CollectionName.newBuilder().setCollectionName(collectionName).build();
-      CollectionRowCount response = blockingStub().countCollection(request);
-      checkResponseStatus(response.getStatus());
-      return response.getCollectionRowCount();
-    });
+    return translateExceptions(
+        () -> {
+          CollectionName request =
+              CollectionName.newBuilder().setCollectionName(collectionName).build();
+          CollectionRowCount response = blockingStub().countCollection(request);
+          checkResponseStatus(response.getStatus());
+          return response.getCollectionRowCount();
+        });
   }
 
   @Override
@@ -410,75 +473,84 @@ abstract class AbstractMilvusGrpcClient implements MilvusClient {
   }
 
   public String command(@Nonnull String command) {
-    return translateExceptions(() -> {
-      Command request = Command.newBuilder().setCmd(command).build();
-      StringReply response = blockingStub().cmd(request);
-      checkResponseStatus(response.getStatus());
-      return response.getStringReply();
-    });
+    return translateExceptions(
+        () -> {
+          Command request = Command.newBuilder().setCmd(command).build();
+          StringReply response = blockingStub().cmd(request);
+          checkResponseStatus(response.getStatus());
+          return response.getStringReply();
+        });
   }
 
   @Override
   public void loadCollection(@Nonnull String collectionName) {
-    translateExceptions(() -> {
-      CollectionName request = CollectionName.newBuilder().setCollectionName(collectionName).build();
-      Status response = blockingStub().preloadCollection(request);
-      checkResponseStatus(response);
-    });
+    translateExceptions(
+        () -> {
+          CollectionName request =
+              CollectionName.newBuilder().setCollectionName(collectionName).build();
+          Status response = blockingStub().preloadCollection(request);
+          checkResponseStatus(response);
+        });
   }
 
   @Override
   public void dropIndex(String collectionName, String fieldName) {
-    translateExceptions(() -> {
-      IndexParam request = IndexParam.newBuilder()
-          .setCollectionName(collectionName)
-          .setFieldName(fieldName)
-          .build();
-      Status response = blockingStub().dropIndex(request);
-      checkResponseStatus(response);
-    });
+    translateExceptions(
+        () -> {
+          IndexParam request =
+              IndexParam.newBuilder()
+                  .setCollectionName(collectionName)
+                  .setFieldName(fieldName)
+                  .build();
+          Status response = blockingStub().dropIndex(request);
+          checkResponseStatus(response);
+        });
   }
 
   @Override
   public String getCollectionStats(String collectionName) {
-    return translateExceptions(() -> {
-      CollectionName request = CollectionName.newBuilder().setCollectionName(collectionName).build();
-      CollectionInfo response = blockingStub().showCollectionInfo(request);
-      checkResponseStatus(response.getStatus());
-      return response.getJsonInfo();
-    });
-  }
-  
-  @Override
-  public Map<Long, Map<String, Object>> getEntityByID(String collectionName, List<Long> ids, List<String> fieldNames) {
-    return translateExceptions(() -> {
-      EntityIdentity request = EntityIdentity.newBuilder()
-          .setCollectionName(collectionName)
-          .addAllIdArray(ids)
-          .addAllFieldNames(fieldNames)
-          .build();
-      Entities response = blockingStub().getEntityByID(request);
-      checkResponseStatus(response.getStatus());
-      Map<String, Iterator<?>> fieldIterators = response.getFieldsList()
-          .stream()
-          .collect(Collectors.toMap(FieldValue::getFieldName, this::fieldValueIterator));
-      Iterator<Long> idIterator = ids.iterator();
-      Map<Long, Map<String, Object>> entities = new HashMap<>(response.getValidRowList().size());
-      for (boolean valid : response.getValidRowList()) {
-        long id = idIterator.next();
-        if (valid) {
-          entities.put(id, toMap(fieldIterators));
-        }
-      }
-      return entities;
-    });
+    return translateExceptions(
+        () -> {
+          CollectionName request =
+              CollectionName.newBuilder().setCollectionName(collectionName).build();
+          CollectionInfo response = blockingStub().showCollectionInfo(request);
+          checkResponseStatus(response.getStatus());
+          return response.getJsonInfo();
+        });
+  }
+
+  @Override
+  public Map<Long, Map<String, Object>> getEntityByID(
+      String collectionName, List<Long> ids, List<String> fieldNames) {
+    return translateExceptions(
+        () -> {
+          EntityIdentity request =
+              EntityIdentity.newBuilder()
+                  .setCollectionName(collectionName)
+                  .addAllIdArray(ids)
+                  .addAllFieldNames(fieldNames)
+                  .build();
+          Entities response = blockingStub().getEntityByID(request);
+          checkResponseStatus(response.getStatus());
+          Map<String, Iterator<?>> fieldIterators =
+              response.getFieldsList().stream()
+                  .collect(Collectors.toMap(FieldValue::getFieldName, this::fieldValueIterator));
+          Iterator<Long> idIterator = ids.iterator();
+          Map<Long, Map<String, Object>> entities =
+              new HashMap<>(response.getValidRowList().size());
+          for (boolean valid : response.getValidRowList()) {
+            long id = idIterator.next();
+            if (valid) {
+              entities.put(id, toMap(fieldIterators));
+            }
+          }
+          return entities;
+        });
   }
-  
+
   private Map<String, Object> toMap(Map<String, Iterator<?>> fieldIterators) {
     return fieldIterators.entrySet().stream()
-        .collect(Collectors.toMap(
-            entry -> entry.getKey(),
-            entry -> entry.getValue().next()));
+        .collect(Collectors.toMap(entry -> entry.getKey(), entry -> entry.getValue().next()));
   }
 
   private Iterator<?> fieldValueIterator(FieldValue fieldValue) {
@@ -496,7 +568,11 @@ abstract class AbstractMilvusGrpcClient implements MilvusClient {
     }
     VectorRecord record = fieldValue.getVectorRecord();
     return record.getRecordsList().stream()
-        .map(row -> row.getFloatDataCount() > 0 ? row.getFloatDataList() : row.getBinaryData().asReadOnlyByteBuffer())
+        .map(
+            row ->
+                row.getFloatDataCount() > 0
+                    ? row.getFloatDataList()
+                    : row.getBinaryData().asReadOnlyByteBuffer())
         .iterator();
   }
 
@@ -507,27 +583,31 @@ abstract class AbstractMilvusGrpcClient implements MilvusClient {
 
   @Override
   public List<Long> listIDInSegment(String collectionName, Long segmentId) {
-    return translateExceptions(() -> {
-      GetEntityIDsParam request = GetEntityIDsParam.newBuilder()
-          .setCollectionName(collectionName)
-          .setSegmentId(segmentId)
-          .build();
-      EntityIds response = blockingStub().getEntityIDs(request);
-      checkResponseStatus(response.getStatus());
-      return response.getEntityIdArrayList();
-    });
+    return translateExceptions(
+        () -> {
+          GetEntityIDsParam request =
+              GetEntityIDsParam.newBuilder()
+                  .setCollectionName(collectionName)
+                  .setSegmentId(segmentId)
+                  .build();
+          EntityIds response = blockingStub().getEntityIDs(request);
+          checkResponseStatus(response.getStatus());
+          return response.getEntityIdArrayList();
+        });
   }
 
   @Override
   public void deleteEntityByID(String collectionName, List<Long> ids) {
-    translateExceptions(() -> {
-      DeleteByIDParam request = DeleteByIDParam.newBuilder()
-          .setCollectionName(collectionName)
-          .addAllIdArray(ids)
-          .build();
-      Status response = blockingStub().deleteByID(request);
-      checkResponseStatus(response);
-    });
+    translateExceptions(
+        () -> {
+          DeleteByIDParam request =
+              DeleteByIDParam.newBuilder()
+                  .setCollectionName(collectionName)
+                  .addAllIdArray(ids)
+                  .build();
+          Status response = blockingStub().deleteByID(request);
+          checkResponseStatus(response);
+        });
   }
 
   @Override
@@ -537,11 +617,14 @@ abstract class AbstractMilvusGrpcClient implements MilvusClient {
 
   @Override
   public ListenableFuture<Void> flushAsync(@Nonnull List<String> collectionNames) {
-    return translateExceptions(() -> {
-      FlushParam request = FlushParam.newBuilder().addAllCollectionNameArray(collectionNames).build();
-      ListenableFuture<Status> response = futureStub().flush(request);
-      return Futures.transform(response, this::checkResponseStatus, MoreExecutors.directExecutor());
-    });
+    return translateExceptions(
+        () -> {
+          FlushParam request =
+              FlushParam.newBuilder().addAllCollectionNameArray(collectionNames).build();
+          ListenableFuture<Status> response = futureStub().flush(request);
+          return Futures.transform(
+              response, this::checkResponseStatus, MoreExecutors.directExecutor());
+        });
   }
 
   @Override
@@ -561,11 +644,13 @@ abstract class AbstractMilvusGrpcClient implements MilvusClient {
 
   @Override
   public ListenableFuture<Void> compactAsync(@Nonnull CompactParam compactParam) {
-    return translateExceptions(() -> {
-      io.milvus.grpc.CompactParam request = compactParam.grpc();
-      ListenableFuture<Status> response = futureStub().compact(request);
-      return Futures.transform(response, this::checkResponseStatus, MoreExecutors.directExecutor());
-    });
+    return translateExceptions(
+        () -> {
+          io.milvus.grpc.CompactParam request = compactParam.grpc();
+          ListenableFuture<Status> response = futureStub().compact(request);
+          return Futures.transform(
+              response, this::checkResponseStatus, MoreExecutors.directExecutor());
+        });
   }
 
   ///////////////////// Util Functions/////////////////////
@@ -607,7 +692,11 @@ abstract class AbstractMilvusGrpcClient implements MilvusClient {
               if (vectorRowRecordList.get(j).getFloatDataCount() > 0) {
                 fieldsMap.get(j).put(fieldName, vectorRowRecordList.get(j).getFloatDataList());
               } else {
-                fieldsMap.get(j).put(fieldName, vectorRowRecordList.get(j).getBinaryData().asReadOnlyByteBuffer());
+                fieldsMap
+                    .get(j)
+                    .put(
+                        fieldName,
+                        vectorRowRecordList.get(j).getBinaryData().asReadOnlyByteBuffer());
               }
             }
           }

+ 51 - 49
src/main/java/io/milvus/client/SearchParam.java

@@ -27,16 +27,15 @@ import io.milvus.grpc.KeyValuePair;
 import io.milvus.grpc.VectorParam;
 import io.milvus.grpc.VectorRecord;
 import io.milvus.grpc.VectorRowRecord;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
 import java.util.stream.Collectors;
 import java.util.stream.StreamSupport;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
 
 /** Contains parameters for <code>search</code> */
 public class SearchParam {
@@ -45,15 +44,15 @@ public class SearchParam {
 
   private final io.milvus.grpc.SearchParam.Builder builder;
 
-  public static SearchParam create(String collectionName) {
-    return new SearchParam(collectionName);
-  }
-
   private SearchParam(String collectionName) {
     builder = io.milvus.grpc.SearchParam.newBuilder();
     builder.setCollectionName(collectionName);
   }
 
+  public static SearchParam create(String collectionName) {
+    return new SearchParam(collectionName);
+  }
+
   public SearchParam setDsl(JSONObject json) {
     builder.setDsl(json.toString());
     return this;
@@ -62,8 +61,9 @@ public class SearchParam {
   public SearchParam setDsl(String dsl) {
     try {
       JSONObject dslJson = new JSONObject(dsl);
-      JSONObject vectorQueryParent = locateVectorQuery(dslJson)
-          .orElseThrow(() -> new InvalidDsl("A vector query must be specified", dsl));
+      JSONObject vectorQueryParent =
+          locateVectorQuery(dslJson)
+              .orElseThrow(() -> new InvalidDsl("A vector query must be specified", dsl));
       JSONObject vectorQueries = vectorQueryParent.getJSONObject(VECTOR_QUERY_KEY);
       vectorQueryParent.put(VECTOR_QUERY_KEY, VECTOR_QUERY_PLACEHOLDER);
       String vectorQueryField = vectorQueries.keys().next();
@@ -87,13 +87,10 @@ public class SearchParam {
       vectorQuery.remove("type");
       vectorQuery.remove("query");
       json.put("placeholder", vectorQueries);
-      VectorParam vectorParam = VectorParam.newBuilder()
-          .setJson(json.toString())
-          .setRowRecord(vectorRecord)
-          .build();
+      VectorParam vectorParam =
+          VectorParam.newBuilder().setJson(json.toString()).setRowRecord(vectorRecord).build();
 
-      builder.setDsl(dslJson.toString())
-          .addAllVectorParam(ImmutableList.of(vectorParam));
+      builder.setDsl(dslJson.toString()).addAllVectorParam(ImmutableList.of(vectorParam));
       return this;
     } catch (JSONException e) {
       throw new InvalidDsl(e.getMessage(), dsl);
@@ -111,10 +108,11 @@ public class SearchParam {
   }
 
   public SearchParam setParamsInJson(String paramsInJson) {
-    builder.addExtraParams(KeyValuePair.newBuilder()
-        .setKey(MilvusClient.extraParamKey)
-        .setValue(paramsInJson)
-        .build());
+    builder.addExtraParams(
+        KeyValuePair.newBuilder()
+            .setKey(MilvusClient.extraParamKey)
+            .setValue(paramsInJson)
+            .build());
     return this;
   }
 
@@ -123,9 +121,9 @@ public class SearchParam {
   }
 
   private Optional<JSONObject> locateVectorQuery(Object obj) {
-    return obj instanceof JSONObject ? locateVectorQuery((JSONObject) obj)
-        : obj instanceof JSONArray ? locateVectorQuery((JSONArray) obj)
-        : Optional.empty();
+    return obj instanceof JSONObject
+        ? locateVectorQuery((JSONObject) obj)
+        : obj instanceof JSONArray ? locateVectorQuery((JSONArray) obj) : Optional.empty();
   }
 
   private Optional<JSONObject> locateVectorQuery(JSONArray array) {
@@ -148,36 +146,40 @@ public class SearchParam {
   }
 
   private VectorRecord toFloatVectorRecord(JSONArray data) {
-    return VectorRecord.newBuilder().addAllRecords(
-        StreamSupport.stream(data.spliterator(), false)
-            .map(element -> (JSONArray) element)
-            .map(array -> {
-              int dimension = array.length();
-              List<Float> vector = new ArrayList<>(dimension);
-              for (int i = 0; i < dimension; i++) {
-                vector.add(array.getFloat(i));
-              }
-              return VectorRowRecord.newBuilder().addAllFloatData(vector).build();
-            })
-            .collect(Collectors.toList()))
+    return VectorRecord.newBuilder()
+        .addAllRecords(
+            StreamSupport.stream(data.spliterator(), false)
+                .map(element -> (JSONArray) element)
+                .map(
+                    array -> {
+                      int dimension = array.length();
+                      List<Float> vector = new ArrayList<>(dimension);
+                      for (int i = 0; i < dimension; i++) {
+                        vector.add(array.getFloat(i));
+                      }
+                      return VectorRowRecord.newBuilder().addAllFloatData(vector).build();
+                    })
+                .collect(Collectors.toList()))
         .build();
   }
 
   private VectorRecord toBinaryVectorRecord(JSONArray data) {
-    return VectorRecord.newBuilder().addAllRecords(
-        StreamSupport.stream(data.spliterator(), false)
-            .map(element -> (JSONArray) element)
-            .map(array -> {
-              int dimension = array.length();
-              ByteBuffer bytes = ByteBuffer.allocate(dimension);
-              for (int i = 0; i < dimension; i++) {
-                bytes.put(array.getNumber(i).byteValue());
-              }
-              bytes.flip();
-              ByteString vector = UnsafeByteOperations.unsafeWrap(bytes);
-              return VectorRowRecord.newBuilder().setBinaryData(vector).build();
-            })
-            .collect(Collectors.toList()))
+    return VectorRecord.newBuilder()
+        .addAllRecords(
+            StreamSupport.stream(data.spliterator(), false)
+                .map(element -> (JSONArray) element)
+                .map(
+                    array -> {
+                      int dimension = array.length();
+                      ByteBuffer bytes = ByteBuffer.allocate(dimension);
+                      for (int i = 0; i < dimension; i++) {
+                        bytes.put(array.getNumber(i).byteValue());
+                      }
+                      bytes.flip();
+                      ByteString vector = UnsafeByteOperations.unsafeWrap(bytes);
+                      return VectorRowRecord.newBuilder().setBinaryData(vector).build();
+                    })
+                .collect(Collectors.toList()))
         .build();
   }
 }

+ 19 - 13
src/main/java/io/milvus/client/SearchResult.java

@@ -7,17 +7,18 @@ import java.util.stream.IntStream;
 
 /** A class that contains information from Search */
 public class SearchResult {
-  private int numQueries;
-  private long topK;
-  private List<List<Long>> resultIdsList;
-  private List<List<Float>> resultDistancesList;
-  private List<List<Map<String, Object>>> fieldsMap;
+  private final int numQueries;
+  private final long topK;
+  private final List<List<Long>> resultIdsList;
+  private final List<List<Float>> resultDistancesList;
+  private final List<List<Map<String, Object>>> fieldsMap;
 
-  public SearchResult(int numQueries,
-                      long topK,
-                      List<List<Long>> resultIdsList,
-                      List<List<Float>> resultDistancesList,
-                      List<List<Map<String, Object>>> fieldsMap) {
+  public SearchResult(
+      int numQueries,
+      long topK,
+      List<List<Long>> resultIdsList,
+      List<List<Float>> resultDistancesList,
+      List<List<Map<String, Object>>> fieldsMap) {
     this.numQueries = numQueries;
     this.topK = topK;
     this.resultIdsList = resultIdsList;
@@ -47,9 +48,14 @@ public class SearchResult {
 
   public List<List<QueryResult>> getQueryResultsList() {
     return IntStream.range(0, numQueries)
-        .mapToObj(i -> IntStream.range(0, resultIdsList.get(i).size())
-            .mapToObj(j -> new QueryResult(resultIdsList.get(i).get(j), resultDistancesList.get(i).get(j)))
-            .collect(Collectors.toList()))
+        .mapToObj(
+            i ->
+                IntStream.range(0, resultIdsList.get(i).size())
+                    .mapToObj(
+                        j ->
+                            new QueryResult(
+                                resultIdsList.get(i).get(j), resultDistancesList.get(i).get(j)))
+                    .collect(Collectors.toList()))
         .collect(Collectors.toList());
   }
 

+ 14 - 12
src/main/java/io/milvus/client/dsl/BoolQuery.java

@@ -1,11 +1,10 @@
 package io.milvus.client.dsl;
 
 import io.milvus.client.SearchParam;
-import org.json.JSONArray;
-import org.json.JSONObject;
-
 import java.util.List;
 import java.util.stream.Collectors;
+import org.json.JSONArray;
+import org.json.JSONObject;
 
 public class BoolQuery extends Query {
   private final Type type;
@@ -16,8 +15,15 @@ public class BoolQuery extends Query {
     this.subqueries = subqueries;
   }
 
+  @Override
+  protected JSONObject buildSearchParam(SearchParam searchParam, JSONObject outer) {
+    return outer.put(type.name().toLowerCase(), type.buildSearchParam(searchParam, subqueries));
+  }
+
   enum Type {
-    MUST, MUST_NOT, SHOULD,
+    MUST,
+    MUST_NOT,
+    SHOULD,
 
     BOOL {
       @Override
@@ -29,14 +35,10 @@ public class BoolQuery extends Query {
     };
 
     public Object buildSearchParam(SearchParam searchParam, List<Query> subqueries) {
-      return new JSONArray(subqueries.stream()
-          .map(query -> query.buildSearchParam(searchParam, new JSONObject()))
-          .collect(Collectors.toList()));
+      return new JSONArray(
+          subqueries.stream()
+              .map(query -> query.buildSearchParam(searchParam, new JSONObject()))
+              .collect(Collectors.toList()));
     }
   }
-
-  @Override
-  protected JSONObject buildSearchParam(SearchParam searchParam, JSONObject outer) {
-    return outer.put(type.name().toLowerCase(), type.buildSearchParam(searchParam, subqueries));
-  }
 }

+ 11 - 8
src/main/java/io/milvus/client/dsl/MilvusService.java

@@ -8,7 +8,6 @@ import io.milvus.client.MetricType;
 import io.milvus.client.MilvusClient;
 import io.milvus.client.SearchParam;
 import io.milvus.client.SearchResult;
-
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -21,7 +20,7 @@ public class MilvusService {
   private final String collectionName;
   private final Schema schema;
 
-  public MilvusService(MilvusClient client, String  collectionName, Schema schema) {
+  public MilvusService(MilvusClient client, String collectionName, Schema schema) {
     this.client = client;
     this.collectionName = collectionName;
     this.schema = schema;
@@ -48,12 +47,18 @@ public class MilvusService {
   }
 
   public void createIndex(
-      Schema.VectorField vectorField, IndexType indexType, MetricType metricType, String paramsInJson) {
+      Schema.VectorField vectorField,
+      IndexType indexType,
+      MetricType metricType,
+      String paramsInJson) {
     Futures.getUnchecked(createIndexAsync(vectorField, indexType, metricType, paramsInJson));
   }
 
   public ListenableFuture<Void> createIndexAsync(
-      Schema.VectorField vectorField, IndexType indexType, MetricType metricType, String paramsInJson) {
+      Schema.VectorField vectorField,
+      IndexType indexType,
+      MetricType metricType,
+      String paramsInJson) {
     return client.createIndexAsync(
         Index.create(collectionName, vectorField.name)
             .setIndexType(indexType)
@@ -83,10 +88,8 @@ public class MilvusService {
 
   public Map<Long, Schema.Entity> getEntityByID(List<Long> ids, List<Schema.Field<?>> fields) {
     List<String> fieldNames = fields.stream().map(f -> f.name).collect(Collectors.toList());
-    return client.getEntityByID(collectionName, ids, fieldNames)
-        .entrySet().stream().collect(Collectors.toMap(
-            e -> e.getKey(),
-            e -> schema.new Entity(e.getValue())));
+    return client.getEntityByID(collectionName, ids, fieldNames).entrySet().stream()
+        .collect(Collectors.toMap(e -> e.getKey(), e -> schema.new Entity(e.getValue())));
   }
 
   public boolean hasCollection(String collectionName) {

+ 1 - 2
src/main/java/io/milvus/client/dsl/Query.java

@@ -1,9 +1,8 @@
 package io.milvus.client.dsl;
 
 import io.milvus.client.SearchParam;
-import org.json.JSONObject;
-
 import java.util.Arrays;
+import org.json.JSONObject;
 
 public abstract class Query {
 

+ 7 - 5
src/main/java/io/milvus/client/dsl/RangeQuery.java

@@ -1,14 +1,13 @@
 package io.milvus.client.dsl;
 
 import io.milvus.client.SearchParam;
-import org.json.JSONObject;
-
 import java.util.ArrayList;
 import java.util.List;
+import org.json.JSONObject;
 
 public class RangeQuery<T> extends Query {
-  private Schema.Field<T> field;
-  private List<Expr> exprs = new ArrayList<>();
+  private final Schema.Field<T> field;
+  private final List<Expr> exprs = new ArrayList<>();
 
   RangeQuery(Schema.Field field) {
     this.field = field;
@@ -46,7 +45,10 @@ public class RangeQuery<T> extends Query {
   }
 
   public enum Type {
-    GT, GTE, LT, LTE;
+    GT,
+    GTE,
+    LT,
+    LTE
   }
 
   private class Expr {

+ 10 - 8
src/main/java/io/milvus/client/dsl/Schema.java

@@ -2,7 +2,6 @@ package io.milvus.client.dsl;
 
 import io.milvus.client.CollectionMapping;
 import io.milvus.client.DataType;
-
 import java.nio.ByteBuffer;
 import java.util.Arrays;
 import java.util.LinkedHashMap;
@@ -18,13 +17,16 @@ public abstract class Schema {
 
   CollectionMapping mapToCollection(String collectionName) {
     CollectionMapping mapping = CollectionMapping.create(collectionName);
-    fields.values().forEach(f -> {
-      if (f instanceof ScalarField) {
-        mapping.addField(f.name, f.dataType);
-      } else if (f instanceof VectorField) {
-        mapping.addVectorField(f.name, f.dataType, ((VectorField<?>) f).dimension);
-      }
-    });
+    fields
+        .values()
+        .forEach(
+            f -> {
+              if (f instanceof ScalarField) {
+                mapping.addField(f.name, f.dataType);
+              } else if (f instanceof VectorField) {
+                mapping.addVectorField(f.name, f.dataType, ((VectorField<?>) f).dimension);
+              }
+            });
     return mapping;
   }
 

+ 1 - 2
src/main/java/io/milvus/client/dsl/TermQuery.java

@@ -1,11 +1,10 @@
 package io.milvus.client.dsl;
 
 import io.milvus.client.SearchParam;
+import java.util.Collection;
 import org.json.JSONArray;
 import org.json.JSONObject;
 
-import java.util.Collection;
-
 public class TermQuery<T> extends Query {
   private final Schema.Field<T> field;
   private final Type type;

+ 40 - 23
src/main/java/io/milvus/client/dsl/VectorQuery.java

@@ -6,11 +6,10 @@ import io.milvus.client.SearchParam;
 import io.milvus.grpc.VectorParam;
 import io.milvus.grpc.VectorRecord;
 import io.milvus.grpc.VectorRowRecord;
-import org.json.JSONObject;
-
 import java.nio.ByteBuffer;
 import java.util.List;
 import java.util.stream.Collectors;
+import org.json.JSONObject;
 
 public class VectorQuery<T> extends Query {
   private final Schema.VectorField<T> field;
@@ -62,30 +61,48 @@ public class VectorQuery<T> extends Query {
   void buildSearchParam(SearchParam searchParam) {
     VectorRecord vectorRecord = null;
     if (field instanceof Schema.FloatVectorField) {
-      vectorRecord = VectorRecord.newBuilder().addAllRecords(
-          ((List<List<Float>>) this.queries).stream().map(vector ->
-              VectorRowRecord.newBuilder().addAllFloatData(vector).build())
-              .collect(Collectors.toList()))
-          .build();
+      vectorRecord =
+          VectorRecord.newBuilder()
+              .addAllRecords(
+                  ((List<List<Float>>) this.queries)
+                      .stream()
+                          .map(
+                              vector ->
+                                  VectorRowRecord.newBuilder().addAllFloatData(vector).build())
+                          .collect(Collectors.toList()))
+              .build();
     } else if (field instanceof Schema.BinaryVectorField) {
-      vectorRecord = VectorRecord.newBuilder().addAllRecords(
-          ((List<ByteBuffer>) this.queries).stream().map(vector ->
-            VectorRowRecord.newBuilder().setBinaryData(UnsafeByteOperations.unsafeWrap(vector)).build())
-              .collect(Collectors.toList()))
-          .build();
+      vectorRecord =
+          VectorRecord.newBuilder()
+              .addAllRecords(
+                  ((List<ByteBuffer>) this.queries)
+                      .stream()
+                          .map(
+                              vector ->
+                                  VectorRowRecord.newBuilder()
+                                      .setBinaryData(UnsafeByteOperations.unsafeWrap(vector))
+                                      .build())
+                          .collect(Collectors.toList()))
+              .build();
     }
 
-    VectorParam vectorParam = VectorParam.newBuilder()
-        .setJson(new JSONObject()
-            .put(placeholder, new JSONObject()
-                .put(field.name, new JSONObject()
-                    .put("topk", topK)
-                    .put("metric_type", metricType.name())
-                    .put("boost", boost)
-                    .put("params", params)))
-                .toString())
-        .setRowRecord(vectorRecord)
-        .build();
+    VectorParam vectorParam =
+        VectorParam.newBuilder()
+            .setJson(
+                new JSONObject()
+                    .put(
+                        placeholder,
+                        new JSONObject()
+                            .put(
+                                field.name,
+                                new JSONObject()
+                                    .put("topk", topK)
+                                    .put("metric_type", metricType.name())
+                                    .put("boost", boost)
+                                    .put("params", params)))
+                    .toString())
+            .setRowRecord(vectorRecord)
+            .build();
 
     searchParam.addQueries(vectorParam);
   }

+ 1 - 1
src/main/java/io/milvus/client/exception/InvalidDsl.java

@@ -2,7 +2,7 @@ package io.milvus.client.exception;
 
 /** Milvus exception where invalid DSL is passed by client as a query */
 public class InvalidDsl extends ClientSideMilvusException {
-  private String dsl;
+  private final String dsl;
 
   public InvalidDsl(String dsl, String message) {
     super(null, message);

+ 2 - 2
src/main/java/io/milvus/client/exception/MilvusException.java

@@ -2,8 +2,8 @@ package io.milvus.client.exception;
 
 /** General Milvus exception */
 public abstract class MilvusException extends RuntimeException {
-  private String target;
-  private boolean fillInStackTrace;
+  private final String target;
+  private final boolean fillInStackTrace;
 
   MilvusException(String target, boolean fillInStackTrace) {
     this(target, fillInStackTrace, null, null);

+ 2 - 2
src/main/java/io/milvus/client/exception/ServerSideMilvusException.java

@@ -5,8 +5,8 @@ import io.milvus.grpc.Status;
 
 /** Milvus exception from server side */
 public class ServerSideMilvusException extends MilvusException {
-  private ErrorCode errorCode;
-  private String reason;
+  private final ErrorCode errorCode;
+  private final String reason;
 
   public ServerSideMilvusException(String target, Status status) {
     super(target, false);

+ 5 - 4
src/main/java/io/milvus/client/exception/UnsupportedServerVersion.java

@@ -4,8 +4,8 @@ import io.milvus.client.MilvusClient;
 
 /** Milvus exception where client and server versions do not match */
 public class UnsupportedServerVersion extends ClientSideMilvusException {
-  private String expect;
-  private String actual;
+  private final String expect;
+  private final String actual;
 
   public UnsupportedServerVersion(String target, String expect, String actual) {
     super(target);
@@ -15,7 +15,8 @@ public class UnsupportedServerVersion extends ClientSideMilvusException {
 
   @Override
   public String getErrorMessage() {
-    return String.format("Milvus client %s is expected to work with Milvus server %s, but the version of the connected server is %s",
+    return String.format(
+        "Milvus client %s is expected to work with Milvus server %s, but the version of the connected server is %s",
         MilvusClient.clientVersion, expect, actual);
   }
-}
+}

+ 217 - 202
src/test/java/io/milvus/client/MilvusGrpcClientTest.java

@@ -19,6 +19,11 @@
 
 package io.milvus.client;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 import com.google.common.collect.ImmutableSet;
 import io.grpc.NameResolverProvider;
 import io.grpc.NameResolverRegistry;
@@ -28,15 +33,6 @@ import io.milvus.client.exception.ClientSideMilvusException;
 import io.milvus.client.exception.ServerSideMilvusException;
 import io.milvus.client.exception.UnsupportedServerVersion;
 import io.milvus.grpc.ErrorCode;
-import org.apache.commons.lang3.RandomStringUtils;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
-import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
-import org.testcontainers.containers.GenericContainer;
-import org.testcontainers.junit.jupiter.Container;
-import org.testcontainers.junit.jupiter.Testcontainers;
-
 import java.net.InetSocketAddress;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
@@ -52,23 +48,27 @@ import java.util.stream.Collectors;
 import java.util.stream.DoubleStream;
 import java.util.stream.IntStream;
 import java.util.stream.LongStream;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
 
 @Testcontainers
 @EnabledIfSystemProperty(named = "with-containers", matches = "true")
 class ContainerMilvusClientTest extends MilvusClientTest {
   @Container
-  private GenericContainer milvusContainer =
-      new GenericContainer(System.getProperty("docker_image_name", "milvusdb/milvus:0.11.0-cpu-d101620-4c44c0"))
+  private static final GenericContainer milvusContainer2 =
+      new GenericContainer(
+              System.getProperty("docker_image_name", "milvusdb/milvus:0.11.0-cpu-d101620-4c44c0"))
           .withExposedPorts(19530);
-
   @Container
-  private static GenericContainer milvusContainer2 =
-      new GenericContainer(System.getProperty("docker_image_name", "milvusdb/milvus:0.11.0-cpu-d101620-4c44c0"))
+  private final GenericContainer milvusContainer =
+      new GenericContainer(
+              System.getProperty("docker_image_name", "milvusdb/milvus:0.11.0-cpu-d101620-4c44c0"))
           .withExposedPorts(19530);
 
   @Override
@@ -78,18 +78,23 @@ class ContainerMilvusClientTest extends MilvusClientTest {
 
   @org.junit.jupiter.api.Test
   void loadBalancing() {
-    NameResolverProvider testNameResolverProvider = new StaticNameResolverProvider(
-        new InetSocketAddress(milvusContainer.getHost(), milvusContainer.getFirstMappedPort()),
-        new InetSocketAddress(milvusContainer2.getHost(), milvusContainer2.getFirstMappedPort()));
+    NameResolverProvider testNameResolverProvider =
+        new StaticNameResolverProvider(
+            new InetSocketAddress(milvusContainer.getHost(), milvusContainer.getFirstMappedPort()),
+            new InetSocketAddress(
+                milvusContainer2.getHost(), milvusContainer2.getFirstMappedPort()));
 
     NameResolverRegistry.getDefaultRegistry().register(testNameResolverProvider);
 
-    ConnectParam connectParam = connectParamBuilder()
-        .withTarget(testNameResolverProvider.getDefaultScheme() + ":///test")
-        .build();
+    ConnectParam connectParam =
+        connectParamBuilder()
+            .withTarget(testNameResolverProvider.getDefaultScheme() + ":///test")
+            .build();
 
     MilvusClient loadBalancingClient = new MilvusGrpcClient(connectParam).withLogging();
-    assertEquals(50, IntStream.range(0, 100)
+    assertEquals(
+        50,
+        IntStream.range(0, 100)
             .filter(i -> loadBalancingClient.hasCollection(randomCollectionName))
             .count());
   }
@@ -99,34 +104,11 @@ class ContainerMilvusClientTest extends MilvusClientTest {
 @DisabledIfSystemProperty(named = "with-containers", matches = "true")
 class MilvusClientTest {
 
-  private MilvusClient client;
-
   protected String randomCollectionName;
+  private MilvusClient client;
   private int size;
   private int dimension;
 
-  protected ConnectParam.Builder connectParamBuilder() {
-    return connectParamBuilder("localhost", 19530);
-  }
-
-  protected ConnectParam.Builder connectParamBuilder(GenericContainer milvusContainer) {
-    return connectParamBuilder(milvusContainer.getHost(), milvusContainer.getFirstMappedPort());
-  }
-
-  protected ConnectParam.Builder connectParamBuilder(String host, int port) {
-    return new ConnectParam.Builder().withHost(host).withPort(port);
-  }
-
-  protected void assertErrorCode(ErrorCode errorCode, Runnable runnable) {
-    assertEquals(errorCode, assertThrows(ServerSideMilvusException.class, runnable::run).getErrorCode());
-  }
-
-  protected void assertGrpcStatusCode(Status.Code statusCode, Runnable runnable) {
-    ClientSideMilvusException error = assertThrows(ClientSideMilvusException.class, runnable::run);
-    assertTrue(error.getCause() instanceof StatusRuntimeException);
-    assertEquals(statusCode, ((StatusRuntimeException) error.getCause()).getStatus().getCode());
-  }
-
   // Helper function that generates random float vectors
   static List<List<Float>> generateFloatVectors(int vectorCount, int dimension) {
     SplittableRandom splittableRandom = new SplittableRandom();
@@ -171,7 +153,8 @@ class MilvusClientTest {
             + "    \"vector\": {"
             + "        \"float_vec\": {"
             + "            \"topk\": %d, \"metric_type\": \"L2\", \"type\": \"float\", \"query\": %s, \"params\": {\"nprobe\": 20}"
-            + "    }}}]}}", topK, query);
+            + "    }}}]}}",
+        topK, query);
   }
 
   // Helper function that generate a complex DSL statement with scalar field filtering
@@ -199,6 +182,29 @@ class MilvusClientTest {
         topK, query);
   }
 
+  protected ConnectParam.Builder connectParamBuilder() {
+    return connectParamBuilder("localhost", 19530);
+  }
+
+  protected ConnectParam.Builder connectParamBuilder(GenericContainer milvusContainer) {
+    return connectParamBuilder(milvusContainer.getHost(), milvusContainer.getFirstMappedPort());
+  }
+
+  protected ConnectParam.Builder connectParamBuilder(String host, int port) {
+    return new ConnectParam.Builder().withHost(host).withPort(port);
+  }
+
+  protected void assertErrorCode(ErrorCode errorCode, Runnable runnable) {
+    assertEquals(
+        errorCode, assertThrows(ServerSideMilvusException.class, runnable::run).getErrorCode());
+  }
+
+  protected void assertGrpcStatusCode(Status.Code statusCode, Runnable runnable) {
+    ClientSideMilvusException error = assertThrows(ClientSideMilvusException.class, runnable::run);
+    assertTrue(error.getCause() instanceof StatusRuntimeException);
+    assertEquals(statusCode, ((StatusRuntimeException) error.getCause()).getStatus().getCode());
+  }
+
   @org.junit.jupiter.api.BeforeEach
   void setUp() throws Exception {
 
@@ -209,15 +215,16 @@ class MilvusClientTest {
     size = 100000;
     dimension = 128;
 
-    CollectionMapping collectionMapping = CollectionMapping
-        .create(randomCollectionName)
-        .addField("int64", DataType.INT64)
-        .addField("float", DataType.FLOAT)
-        .addVectorField("float_vec", DataType.VECTOR_FLOAT, dimension)
-        .setParamsInJson(new JsonBuilder()
-            .param("segment_row_limit", 50000)
-            .param("auto_id", false)
-            .build());
+    CollectionMapping collectionMapping =
+        CollectionMapping.create(randomCollectionName)
+            .addField("int64", DataType.INT64)
+            .addField("float", DataType.FLOAT)
+            .addVectorField("float_vec", DataType.VECTOR_FLOAT, dimension)
+            .setParamsInJson(
+                new JsonBuilder()
+                    .param("segment_row_limit", 50000)
+                    .param("auto_id", false)
+                    .build());
 
     client.createCollection(collectionMapping);
   }
@@ -230,9 +237,7 @@ class MilvusClientTest {
 
   @org.junit.jupiter.api.Test
   void idleTest() throws InterruptedException {
-    ConnectParam connectParam = connectParamBuilder()
-        .withIdleTimeout(1, TimeUnit.SECONDS)
-        .build();
+    ConnectParam connectParam = connectParamBuilder().withIdleTimeout(1, TimeUnit.SECONDS).build();
     MilvusClient client = new MilvusGrpcClient(connectParam).withLogging();
     TimeUnit.SECONDS.sleep(2);
     // A new RPC would take the channel out of idle mode
@@ -281,8 +286,7 @@ class MilvusClientTest {
   @org.junit.jupiter.api.Test
   void unsupportedServerVersion() {
     GenericContainer unsupportedMilvusContainer =
-        new GenericContainer("milvusdb/milvus:0.9.1-cpu-d052920-e04ed5")
-            .withExposedPorts(19530);
+        new GenericContainer("milvusdb/milvus:0.9.1-cpu-d052920-e04ed5").withExposedPorts(19530);
     try {
       unsupportedMilvusContainer.start();
       ConnectParam connectParam = connectParamBuilder(unsupportedMilvusContainer).build();
@@ -296,35 +300,38 @@ class MilvusClientTest {
   void grpcTimeout() {
     insert();
     MilvusClient timeoutClient = client.withTimeout(1, TimeUnit.MILLISECONDS);
-    Index index = Index.create(randomCollectionName, "float_vec")
-        .setIndexType(IndexType.IVF_FLAT)
-        .setMetricType(MetricType.L2)
-        .setParamsInJson(new JsonBuilder().param("nlist", 2048).build());
+    Index index =
+        Index.create(randomCollectionName, "float_vec")
+            .setIndexType(IndexType.IVF_FLAT)
+            .setMetricType(MetricType.L2)
+            .setParamsInJson(new JsonBuilder().param("nlist", 2048).build());
     assertGrpcStatusCode(Status.Code.DEADLINE_EXCEEDED, () -> timeoutClient.createIndex(index));
   }
 
   @org.junit.jupiter.api.Test
   void createInvalidCollection() {
     // invalid collection name
-    CollectionMapping invalidCollectionName = CollectionMapping
-        .create("╯°□°)╯")
-        .addVectorField("float_vec", DataType.VECTOR_FLOAT, dimension);
+    CollectionMapping invalidCollectionName =
+        CollectionMapping.create("╯°□°)╯")
+            .addVectorField("float_vec", DataType.VECTOR_FLOAT, dimension);
 
-    assertErrorCode(ErrorCode.ILLEGAL_COLLECTION_NAME, () -> client.createCollection(invalidCollectionName));
+    assertErrorCode(
+        ErrorCode.ILLEGAL_COLLECTION_NAME, () -> client.createCollection(invalidCollectionName));
 
     // invalid field
     CollectionMapping withoutField = CollectionMapping.create("validCollectionName");
     assertThrows(ClientSideMilvusException.class, () -> client.createCollection(withoutField));
 
     // invalid segment_row_limit
-    CollectionMapping invalidSegmentRowCount = CollectionMapping
-        .create("validCollectionName")
-        .addField("int64", DataType.INT64)
-        .addField("float", DataType.FLOAT)
-        .addVectorField("float_vec", DataType.VECTOR_FLOAT, dimension)
-        .setParamsInJson(new JsonBuilder().param("segment_row_limit", -1000).build());
+    CollectionMapping invalidSegmentRowCount =
+        CollectionMapping.create("validCollectionName")
+            .addField("int64", DataType.INT64)
+            .addField("float", DataType.FLOAT)
+            .addVectorField("float_vec", DataType.VECTOR_FLOAT, dimension)
+            .setParamsInJson(new JsonBuilder().param("segment_row_limit", -1000).build());
 
-    assertErrorCode(ErrorCode.ILLEGAL_ARGUMENT, () -> client.createCollection(invalidSegmentRowCount));
+    assertErrorCode(
+        ErrorCode.ILLEGAL_ARGUMENT, () -> client.createCollection(invalidSegmentRowCount));
   }
 
   @org.junit.jupiter.api.Test
@@ -335,7 +342,8 @@ class MilvusClientTest {
   @org.junit.jupiter.api.Test
   void dropCollection() {
     String nonExistingCollectionName = RandomStringUtils.randomAlphabetic(10);
-    assertErrorCode(ErrorCode.COLLECTION_NOT_EXISTS, () -> client.dropCollection(nonExistingCollectionName));
+    assertErrorCode(
+        ErrorCode.COLLECTION_NOT_EXISTS, () -> client.dropCollection(nonExistingCollectionName));
   }
 
   @org.junit.jupiter.api.Test
@@ -358,23 +366,23 @@ class MilvusClientTest {
     }
 
     List<Long> entityIds1 = LongStream.range(0, size).boxed().collect(Collectors.toList());
-    InsertParam insertParam = InsertParam
-        .create(randomCollectionName)
-        .addField("int64", DataType.INT64, intValues)
-        .addField("float", DataType.FLOAT, floatValues)
-        .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
-        .setEntityIds(entityIds1)
-        .setPartitionTag(tag1);
+    InsertParam insertParam =
+        InsertParam.create(randomCollectionName)
+            .addField("int64", DataType.INT64, intValues)
+            .addField("float", DataType.FLOAT, floatValues)
+            .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
+            .setEntityIds(entityIds1)
+            .setPartitionTag(tag1);
     client.insert(insertParam);
 
     List<Long> entityIds2 = LongStream.range(size, size * 2).boxed().collect(Collectors.toList());
-    insertParam = InsertParam
-        .create(randomCollectionName)
-        .addField("int64", DataType.INT64, intValues)
-        .addField("float", DataType.FLOAT, floatValues)
-        .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
-        .setEntityIds(entityIds2)
-        .setPartitionTag(tag2);
+    insertParam =
+        InsertParam.create(randomCollectionName)
+            .addField("int64", DataType.INT64, intValues)
+            .addField("float", DataType.FLOAT, floatValues)
+            .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
+            .setEntityIds(entityIds2)
+            .setPartitionTag(tag2);
     client.insert(insertParam);
 
     client.flush(randomCollectionName);
@@ -387,10 +395,10 @@ class MilvusClientTest {
     List<List<Float>> vectorsToSearch1 = vectors.subList(0, searchSize);
     List<String> partitionTags1 = new ArrayList<>();
     partitionTags1.add(tag1);
-    SearchParam searchParam1 = SearchParam
-        .create(randomCollectionName)
-        .setDsl(generateSimpleDSL(topK, vectorsToSearch1.toString()))
-        .setPartitionTags(partitionTags1);
+    SearchParam searchParam1 =
+        SearchParam.create(randomCollectionName)
+            .setDsl(generateSimpleDSL(topK, vectorsToSearch1.toString()))
+            .setPartitionTags(partitionTags1);
     SearchResult searchResult1 = client.search(searchParam1);
     List<List<Long>> resultIdsList1 = searchResult1.getResultIdsList();
     assertEquals(searchSize, resultIdsList1.size());
@@ -399,9 +407,10 @@ class MilvusClientTest {
     List<List<Float>> vectorsToSearch2 = vectors.subList(0, searchSize);
     List<String> partitionTags2 = new ArrayList<>();
     partitionTags2.add(tag2);
-    SearchParam searchParam2 = SearchParam.create(randomCollectionName)
-        .setDsl(generateSimpleDSL(topK, vectorsToSearch2.toString()))
-        .setPartitionTags(partitionTags2);
+    SearchParam searchParam2 =
+        SearchParam.create(randomCollectionName)
+            .setDsl(generateSimpleDSL(topK, vectorsToSearch2.toString()))
+            .setPartitionTags(partitionTags2);
     SearchResult searchResult2 = client.search(searchParam2);
     List<List<Long>> resultIdsList2 = searchResult2.getResultIdsList();
     assertEquals(searchSize, resultIdsList2.size());
@@ -423,10 +432,11 @@ class MilvusClientTest {
     insert();
     client.flush(randomCollectionName);
 
-    Index index = Index.create(randomCollectionName, "float_vec")
-        .setIndexType(IndexType.IVF_SQ8)
-        .setMetricType(MetricType.L2)
-        .setParamsInJson(new JsonBuilder().param("nlist", 2048).build());
+    Index index =
+        Index.create(randomCollectionName, "float_vec")
+            .setIndexType(IndexType.IVF_SQ8)
+            .setMetricType(MetricType.L2)
+            .setParamsInJson(new JsonBuilder().param("nlist", 2048).build());
 
     client.createIndex(index);
 
@@ -445,12 +455,12 @@ class MilvusClientTest {
     }
 
     List<Long> entityIds = LongStream.range(0, size).boxed().collect(Collectors.toList());
-    InsertParam insertParam = InsertParam
-        .create(randomCollectionName)
-        .addField("int64", DataType.INT64, intValues)
-        .addField("float", DataType.FLOAT, floatValues)
-        .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
-        .setEntityIds(entityIds);
+    InsertParam insertParam =
+        InsertParam.create(randomCollectionName)
+            .addField("int64", DataType.INT64, intValues)
+            .addField("float", DataType.FLOAT, floatValues)
+            .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
+            .setEntityIds(entityIds);
 
     assertEquals(entityIds, client.insert(insertParam));
   }
@@ -461,22 +471,23 @@ class MilvusClientTest {
 
     String binaryCollectionName = RandomStringUtils.randomAlphabetic(10);
 
-    CollectionMapping collectionMapping = CollectionMapping
-        .create(binaryCollectionName)
-        .addVectorField("binary_vec", DataType.VECTOR_BINARY, binaryDimension);
+    CollectionMapping collectionMapping =
+        CollectionMapping.create(binaryCollectionName)
+            .addVectorField("binary_vec", DataType.VECTOR_BINARY, binaryDimension);
 
     client.createCollection(collectionMapping);
 
     List<ByteBuffer> vectors = generateBinaryVectors(size, binaryDimension);
-    InsertParam insertParam = InsertParam
-        .create(binaryCollectionName)
-        .addVectorField("binary_vec", DataType.VECTOR_BINARY, vectors);
+    InsertParam insertParam =
+        InsertParam.create(binaryCollectionName)
+            .addVectorField("binary_vec", DataType.VECTOR_BINARY, vectors);
     assertEquals(size, client.insert(insertParam).size());
 
-    Index index = Index.create(binaryCollectionName, "binary_vec")
-        .setIndexType(IndexType.BIN_IVF_FLAT)
-        .setMetricType(MetricType.JACCARD)
-        .setParamsInJson(new JsonBuilder().param("nlist", 100).build());
+    Index index =
+        Index.create(binaryCollectionName, "binary_vec")
+            .setIndexType(IndexType.BIN_IVF_FLAT)
+            .setMetricType(MetricType.JACCARD)
+            .setParamsInJson(new JsonBuilder().param("nlist", 100).build());
 
     client.createIndex(index);
 
@@ -498,12 +509,12 @@ class MilvusClientTest {
     vectors = vectors.stream().map(MilvusClientTest::normalizeVector).collect(Collectors.toList());
 
     List<Long> insertIds = LongStream.range(0, size).boxed().collect(Collectors.toList());
-    InsertParam insertParam = InsertParam
-        .create(randomCollectionName)
-        .addField("int64", DataType.INT64, intValues)
-        .addField("float", DataType.FLOAT, floatValues)
-        .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
-        .setEntityIds(insertIds);
+    InsertParam insertParam =
+        InsertParam.create(randomCollectionName)
+            .addField("int64", DataType.INT64, intValues)
+            .addField("float", DataType.FLOAT, floatValues)
+            .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
+            .setEntityIds(insertIds);
     List<Long> entityIds = client.insert(insertParam);
     assertEquals(size, entityIds.size());
 
@@ -513,11 +524,13 @@ class MilvusClientTest {
     List<List<Float>> vectorsToSearch = vectors.subList(0, searchSize);
 
     final long topK = 10;
-    SearchParam searchParam = SearchParam
-        .create(randomCollectionName)
-        .setDsl(generateComplexDSL(topK, vectorsToSearch.toString()))
-        .setParamsInJson(new JsonBuilder().param("fields",
-            new ArrayList<>(Arrays.asList("int64", "float_vec"))).build());
+    SearchParam searchParam =
+        SearchParam.create(randomCollectionName)
+            .setDsl(generateComplexDSL(topK, vectorsToSearch.toString()))
+            .setParamsInJson(
+                new JsonBuilder()
+                    .param("fields", new ArrayList<>(Arrays.asList("int64", "float_vec")))
+                    .build());
     SearchResult searchResult = client.search(searchParam);
     List<List<Long>> resultIdsList = searchResult.getResultIdsList();
     assertEquals(searchSize, resultIdsList.size());
@@ -541,11 +554,11 @@ class MilvusClientTest {
     final int binaryDimension = 64;
 
     String binaryCollectionName = RandomStringUtils.randomAlphabetic(10);
-    CollectionMapping collectionMapping = CollectionMapping
-        .create(binaryCollectionName)
-        .addField("int64", DataType.INT64)
-        .addField("float", DataType.FLOAT)
-        .addVectorField("binary_vec", DataType.VECTOR_BINARY, binaryDimension);
+    CollectionMapping collectionMapping =
+        CollectionMapping.create(binaryCollectionName)
+            .addField("int64", DataType.INT64)
+            .addField("float", DataType.FLOAT)
+            .addVectorField("binary_vec", DataType.VECTOR_BINARY, binaryDimension);
 
     client.createCollection(collectionMapping);
 
@@ -558,25 +571,26 @@ class MilvusClientTest {
     }
     List<ByteBuffer> vectors = generateBinaryVectors(size, binaryDimension);
 
-    InsertParam insertParam = InsertParam
-        .create(binaryCollectionName)
-        .addField("int64", DataType.INT64, intValues)
-        .addField("float", DataType.FLOAT, floatValues)
-        .addVectorField("binary_vec", DataType.VECTOR_BINARY, vectors);
+    InsertParam insertParam =
+        InsertParam.create(binaryCollectionName)
+            .addField("int64", DataType.INT64, intValues)
+            .addField("float", DataType.FLOAT, floatValues)
+            .addVectorField("binary_vec", DataType.VECTOR_BINARY, vectors);
     List<Long> entityIds = client.insert(insertParam);
     assertEquals(size, entityIds.size());
 
     client.flush(binaryCollectionName);
 
     final int searchSize = 5;
-    List<String> vectorsToSearch = vectors.subList(0, searchSize)
-        .stream().map(byteBuffer -> Arrays.toString(byteBuffer.array()))
-        .collect(Collectors.toList());
+    List<String> vectorsToSearch =
+        vectors.subList(0, searchSize).stream()
+            .map(byteBuffer -> Arrays.toString(byteBuffer.array()))
+            .collect(Collectors.toList());
 
     final long topK = 10;
-    SearchParam searchParam = SearchParam
-        .create(binaryCollectionName)
-        .setDsl(generateComplexDSLBinary(topK, vectorsToSearch.toString()));
+    SearchParam searchParam =
+        SearchParam.create(binaryCollectionName)
+            .setDsl(generateComplexDSLBinary(topK, vectorsToSearch.toString()));
     SearchResult searchResult = client.search(searchParam);
     List<List<Long>> resultIdsList = searchResult.getResultIdsList();
     assertEquals(searchSize, resultIdsList.size());
@@ -607,7 +621,8 @@ class MilvusClientTest {
     }
 
     String nonExistingCollectionName = RandomStringUtils.randomAlphabetic(10);
-    assertErrorCode(ErrorCode.COLLECTION_NOT_EXISTS, () -> client.getCollectionInfo(nonExistingCollectionName));
+    assertErrorCode(
+        ErrorCode.COLLECTION_NOT_EXISTS, () -> client.getCollectionInfo(nonExistingCollectionName));
   }
 
   @org.junit.jupiter.api.Test
@@ -619,12 +634,14 @@ class MilvusClientTest {
   @org.junit.jupiter.api.Test
   void serverStatus() {
     JSONObject serverStatus = new JSONObject(client.getServerStatus());
-    assertEquals(ImmutableSet.of("indexing", "require_restart", "server_time", "uptime"), serverStatus.keySet());
+    assertEquals(
+        ImmutableSet.of("indexing", "require_restart", "server_time", "uptime"),
+        serverStatus.keySet());
   }
 
   @org.junit.jupiter.api.Test
   void serverVersion() {
-    assertEquals("0.11.0", client.getServerVersion());
+    assertEquals("0.11.1", client.getServerVersion());
   }
 
   @org.junit.jupiter.api.Test
@@ -670,12 +687,12 @@ class MilvusClientTest {
     vectors = vectors.stream().map(MilvusClientTest::normalizeVector).collect(Collectors.toList());
 
     List<Long> insertIds = LongStream.range(0, size).boxed().collect(Collectors.toList());
-    InsertParam insertParam = InsertParam
-        .create(randomCollectionName)
-        .addField("int64", DataType.INT64, intValues)
-        .addField("float", DataType.FLOAT, floatValues)
-        .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
-        .setEntityIds(insertIds);
+    InsertParam insertParam =
+        InsertParam.create(randomCollectionName)
+            .addField("int64", DataType.INT64, intValues)
+            .addField("float", DataType.FLOAT, floatValues)
+            .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
+            .setEntityIds(insertIds);
     List<Long> entityIds = client.insert(insertParam);
     assertEquals(size, entityIds.size());
 
@@ -699,19 +716,19 @@ class MilvusClientTest {
     final int binaryDimension = 64;
 
     String binaryCollectionName = RandomStringUtils.randomAlphabetic(10);
-    CollectionMapping collectionMapping = CollectionMapping
-        .create(binaryCollectionName)
-        .addVectorField("binary_vec", DataType.VECTOR_BINARY, binaryDimension)
-        .setParamsInJson(new JsonBuilder().param("auto_id", false).build());
+    CollectionMapping collectionMapping =
+        CollectionMapping.create(binaryCollectionName)
+            .addVectorField("binary_vec", DataType.VECTOR_BINARY, binaryDimension)
+            .setParamsInJson(new JsonBuilder().param("auto_id", false).build());
 
     client.createCollection(collectionMapping);
 
     List<ByteBuffer> vectors = generateBinaryVectors(size, binaryDimension);
     List<Long> entityIds = LongStream.range(0, size).boxed().collect(Collectors.toList());
-    InsertParam insertParam = InsertParam
-        .create(binaryCollectionName)
-        .addVectorField("binary_vec", DataType.VECTOR_BINARY, vectors)
-        .setEntityIds(entityIds);
+    InsertParam insertParam =
+        InsertParam.create(binaryCollectionName)
+            .addVectorField("binary_vec", DataType.VECTOR_BINARY, vectors)
+            .setEntityIds(entityIds);
     assertEquals(size, client.insert(insertParam).size());
 
     client.deleteEntityByID(binaryCollectionName, entityIds.subList(10, 20));
@@ -737,11 +754,12 @@ class MilvusClientTest {
 
     String collectionStats = client.getCollectionStats(randomCollectionName);
     JSONObject jsonInfo = new JSONObject(collectionStats);
-    JSONObject segmentInfo = jsonInfo
-        .getJSONArray("partitions")
-        .getJSONObject(0)
-        .getJSONArray("segments")
-        .getJSONObject(0);
+    JSONObject segmentInfo =
+        jsonInfo
+            .getJSONArray("partitions")
+            .getJSONObject(0)
+            .getJSONArray("segments")
+            .getJSONObject(0);
 
     List<Long> entityIds = client.listIDInSegment(randomCollectionName, segmentInfo.getLong("id"));
     assertFalse(entityIds.isEmpty());
@@ -759,12 +777,12 @@ class MilvusClientTest {
     vectors = vectors.stream().map(MilvusClientTest::normalizeVector).collect(Collectors.toList());
 
     List<Long> insertIds = LongStream.range(0, size).boxed().collect(Collectors.toList());
-    InsertParam insertParam = InsertParam
-        .create(randomCollectionName)
-        .addField("int64", DataType.INT64, intValues)
-        .addField("float", DataType.FLOAT, floatValues)
-        .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
-        .setEntityIds(insertIds);
+    InsertParam insertParam =
+        InsertParam.create(randomCollectionName)
+            .addField("int64", DataType.INT64, intValues)
+            .addField("float", DataType.FLOAT, floatValues)
+            .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
+            .setEntityIds(insertIds);
     List<Long> entityIds = client.insert(insertParam);
     assertEquals(size, entityIds.size());
 
@@ -797,12 +815,12 @@ class MilvusClientTest {
     vectors = vectors.stream().map(MilvusClientTest::normalizeVector).collect(Collectors.toList());
 
     List<Long> insertIds = LongStream.range(0, size).boxed().collect(Collectors.toList());
-    InsertParam insertParam = InsertParam
-        .create(randomCollectionName)
-        .addField("int64", DataType.INT64, intValues)
-        .addField("float", DataType.FLOAT, floatValues)
-        .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
-        .setEntityIds(insertIds);
+    InsertParam insertParam =
+        InsertParam.create(randomCollectionName)
+            .addField("int64", DataType.INT64, intValues)
+            .addField("float", DataType.FLOAT, floatValues)
+            .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
+            .setEntityIds(insertIds);
     List<Long> entityIds = client.insert(insertParam);
     assertEquals(size, entityIds.size());
 
@@ -810,10 +828,8 @@ class MilvusClientTest {
 
     String collectionStats = client.getCollectionStats(randomCollectionName);
     JSONObject jsonInfo = new JSONObject(collectionStats);
-    long previousSegmentSize = jsonInfo
-        .getJSONArray("partitions")
-        .getJSONObject(0)
-        .getLong("data_size");
+    long previousSegmentSize =
+        jsonInfo.getJSONArray("partitions").getJSONObject(0).getLong("data_size");
 
     client.deleteEntityByID(randomCollectionName, entityIds.subList(0, size / 2));
     client.flush(randomCollectionName);
@@ -822,10 +838,8 @@ class MilvusClientTest {
     collectionStats = client.getCollectionStats(randomCollectionName);
 
     jsonInfo = new JSONObject(collectionStats);
-    long currentSegmentSize = jsonInfo
-        .getJSONArray("partitions")
-        .getJSONObject(0)
-        .getLong("data_size");
+    long currentSegmentSize =
+        jsonInfo.getJSONArray("partitions").getJSONObject(0).getLong("data_size");
     assertTrue(currentSegmentSize < previousSegmentSize);
   }
 
@@ -841,12 +855,12 @@ class MilvusClientTest {
     vectors = vectors.stream().map(MilvusClientTest::normalizeVector).collect(Collectors.toList());
 
     List<Long> insertIds = LongStream.range(0, size).boxed().collect(Collectors.toList());
-    InsertParam insertParam = InsertParam
-        .create(randomCollectionName)
-        .addField("int64", DataType.INT64, intValues)
-        .addField("float", DataType.FLOAT, floatValues)
-        .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
-        .setEntityIds(insertIds);
+    InsertParam insertParam =
+        InsertParam.create(randomCollectionName)
+            .addField("int64", DataType.INT64, intValues)
+            .addField("float", DataType.FLOAT, floatValues)
+            .addVectorField("float_vec", DataType.VECTOR_FLOAT, vectors)
+            .setEntityIds(insertIds);
     List<Long> entityIds = client.insert(insertParam);
     assertEquals(size, entityIds.size());
 
@@ -869,11 +883,12 @@ class MilvusClientTest {
 
     collectionStats = client.getCollectionStats(randomCollectionName);
     jsonInfo = new JSONObject(collectionStats);
-    segmentInfo = jsonInfo
-        .getJSONArray("partitions")
-        .getJSONObject(0)
-        .getJSONArray("segments")
-        .getJSONObject(0);
+    segmentInfo =
+        jsonInfo
+            .getJSONArray("partitions")
+            .getJSONObject(0)
+            .getJSONArray("segments")
+            .getJSONObject(0);
 
     long currentSegmentSize = segmentInfo.getLong("data_size");
     assertFalse(currentSegmentSize < previousSegmentSize); // threshold 0.8 > 0.5, no compact

+ 6 - 7
src/test/java/io/milvus/client/StaticNameResolverProvider.java

@@ -4,7 +4,6 @@ import io.grpc.Attributes;
 import io.grpc.EquivalentAddressGroup;
 import io.grpc.NameResolver;
 import io.grpc.NameResolverProvider;
-
 import java.net.SocketAddress;
 import java.net.URI;
 import java.util.Arrays;
@@ -13,7 +12,7 @@ import java.util.List;
 import java.util.stream.Collectors;
 
 public class StaticNameResolverProvider extends NameResolverProvider {
-  private List<SocketAddress> addresses;
+  private final List<SocketAddress> addresses;
 
   public StaticNameResolverProvider(SocketAddress... addresses) {
     this.addresses = Arrays.asList(addresses);
@@ -47,9 +46,10 @@ public class StaticNameResolverProvider extends NameResolverProvider {
 
       @Override
       public void start(Listener2 listener) {
-        List<EquivalentAddressGroup> addrs = addresses.stream()
-            .map(addr -> new EquivalentAddressGroup(Collections.singletonList(addr)))
-            .collect(Collectors.toList());
+        List<EquivalentAddressGroup> addrs =
+            addresses.stream()
+                .map(addr -> new EquivalentAddressGroup(Collections.singletonList(addr)))
+                .collect(Collectors.toList());
 
         listener.onResult(
             ResolutionResult.newBuilder()
@@ -59,8 +59,7 @@ public class StaticNameResolverProvider extends NameResolverProvider {
       }
 
       @Override
-      public void shutdown() {
-      }
+      public void shutdown() {}
     };
   }
 }

+ 181 - 113
src/test/java/io/milvus/client/dsl/SearchDslTest.java

@@ -30,14 +30,15 @@ import org.testcontainers.junit.jupiter.Testcontainers;
 public class SearchDslTest {
 
   @Container
-  private GenericContainer milvusContainer =
-      new GenericContainer(System.getProperty("docker_image_name", "milvusdb/milvus:0.11.0-cpu-d101620-4c44c0"))
+  private final GenericContainer milvusContainer =
+      new GenericContainer(
+              System.getProperty("docker_image_name", "milvusdb/milvus:0.11.0-cpu-d101620-4c44c0"))
           .withExposedPorts(19530);
 
-  private TestFloatSchema floatSchema = new TestFloatSchema();
-  private TestBinarySchema binarySchema = new TestBinarySchema();
-  private String collectionName = "test_collection";
-  private int size = 1000;
+  private final TestFloatSchema floatSchema = new TestFloatSchema();
+  private final TestBinarySchema binarySchema = new TestBinarySchema();
+  private final String collectionName = "test_collection";
+  private final int size = 1000;
 
   private ConnectParam connectParam(GenericContainer milvusContainer) {
     return new ConnectParam.Builder()
@@ -63,7 +64,9 @@ public class SearchDslTest {
   }
 
   private List<List<Float>> randomFloatVectors(int size, int dimension) {
-    return Stream.generate(() -> randomFloatVector(dimension)).limit(size).collect(Collectors.toList());
+    return Stream.generate(() -> randomFloatVector(dimension))
+        .limit(size)
+        .collect(Collectors.toList());
   }
 
   private ByteBuffer randomBinaryVector(int dimension) {
@@ -71,165 +74,230 @@ public class SearchDslTest {
   }
 
   private List<ByteBuffer> randomBinaryVectors(int size, int dimension) {
-    return Stream.generate(() -> randomBinaryVector(dimension)).limit(size).collect(Collectors.toList());
+    return Stream.generate(() -> randomBinaryVector(dimension))
+        .limit(size)
+        .collect(Collectors.toList());
   }
 
   @Test
   public void testCreateCollectionFloat() {
-    withMilvusServiceFloat(service -> {
-      service.createCollection(new JsonBuilder().param("auto_id", false).build());
-      assertTrue(service.hasCollection(collectionName));
-    });
+    withMilvusServiceFloat(
+        service -> {
+          service.createCollection(new JsonBuilder().param("auto_id", false).build());
+          assertTrue(service.hasCollection(collectionName));
+        });
   }
 
   @Test
   public void testCreateCollectionBinary() {
-    withMilvusServiceBinary(service -> {
-      service.createCollection(new JsonBuilder().param("auto_id", false).build());
-      assertTrue(service.hasCollection(collectionName));
-    });
+    withMilvusServiceBinary(
+        service -> {
+          service.createCollection(new JsonBuilder().param("auto_id", false).build());
+          assertTrue(service.hasCollection(collectionName));
+        });
   }
 
   @Test
   public void testInsertFloat() {
     testCreateCollectionFloat();
 
-    withMilvusServiceFloat(service -> {
-      service.insert(insertParam -> insertParam
-          .withIds(LongStream.range(0, size).boxed().collect(Collectors.toList()))
-          .with(floatSchema.intField, IntStream.range(0, size).boxed().collect(Collectors.toList()))
-          .with(floatSchema.longField, LongStream.range(0, size).boxed().collect(Collectors.toList()))
-          .with(floatSchema.floatField, IntStream.range(0, size).boxed().map(Number::floatValue).collect(Collectors.toList()))
-          .with(floatSchema.doubleField, IntStream.range(0, size).boxed().map(Number::doubleValue).collect(Collectors.toList()))
-          .with(floatSchema.floatVectorField, randomFloatVectors(size, floatSchema.floatVectorField.dimension)));
-
-      service.flush();
-
-      assertEquals(size, service.countEntities());
-    });
+    withMilvusServiceFloat(
+        service -> {
+          service.insert(
+              insertParam ->
+                  insertParam
+                      .withIds(LongStream.range(0, size).boxed().collect(Collectors.toList()))
+                      .with(
+                          floatSchema.intField,
+                          IntStream.range(0, size).boxed().collect(Collectors.toList()))
+                      .with(
+                          floatSchema.longField,
+                          LongStream.range(0, size).boxed().collect(Collectors.toList()))
+                      .with(
+                          floatSchema.floatField,
+                          IntStream.range(0, size)
+                              .boxed()
+                              .map(Number::floatValue)
+                              .collect(Collectors.toList()))
+                      .with(
+                          floatSchema.doubleField,
+                          IntStream.range(0, size)
+                              .boxed()
+                              .map(Number::doubleValue)
+                              .collect(Collectors.toList()))
+                      .with(
+                          floatSchema.floatVectorField,
+                          randomFloatVectors(size, floatSchema.floatVectorField.dimension)));
+
+          service.flush();
+
+          assertEquals(size, service.countEntities());
+        });
   }
 
   @Test
   public void testInsertBinary() {
     testCreateCollectionBinary();
 
-    withMilvusServiceBinary(service -> {
-      service.insert(insertParam -> insertParam
-          .withIds(LongStream.range(0, size).boxed().collect(Collectors.toList()))
-          .with(binarySchema.intField, IntStream.range(0, size).boxed().collect(Collectors.toList()))
-          .with(binarySchema.longField, LongStream.range(0, size).boxed().collect(Collectors.toList()))
-          .with(binarySchema.floatField, IntStream.range(0, size).boxed().map(Number::floatValue).collect(Collectors.toList()))
-          .with(binarySchema.doubleField, IntStream.range(0, size).boxed().map(Number::doubleValue).collect(Collectors.toList()))
-          .with(binarySchema.binaryVectorField, randomBinaryVectors(size, binarySchema.binaryVectorField.dimension)));
-
-      service.flush();
-
-      assertEquals(size, service.countEntities());
-    });
+    withMilvusServiceBinary(
+        service -> {
+          service.insert(
+              insertParam ->
+                  insertParam
+                      .withIds(LongStream.range(0, size).boxed().collect(Collectors.toList()))
+                      .with(
+                          binarySchema.intField,
+                          IntStream.range(0, size).boxed().collect(Collectors.toList()))
+                      .with(
+                          binarySchema.longField,
+                          LongStream.range(0, size).boxed().collect(Collectors.toList()))
+                      .with(
+                          binarySchema.floatField,
+                          IntStream.range(0, size)
+                              .boxed()
+                              .map(Number::floatValue)
+                              .collect(Collectors.toList()))
+                      .with(
+                          binarySchema.doubleField,
+                          IntStream.range(0, size)
+                              .boxed()
+                              .map(Number::doubleValue)
+                              .collect(Collectors.toList()))
+                      .with(
+                          binarySchema.binaryVectorField,
+                          randomBinaryVectors(size, binarySchema.binaryVectorField.dimension)));
+
+          service.flush();
+
+          assertEquals(size, service.countEntities());
+        });
   }
 
   @Test
   public void testCreateIndexFloat() {
     testInsertFloat();
 
-    withMilvusServiceFloat(service -> {
-      service.createIndex(floatSchema.floatVectorField, IndexType.IVF_SQ8, MetricType.L2, "{\"nlist\": 256}");
-    });
+    withMilvusServiceFloat(
+        service -> {
+          service.createIndex(
+              floatSchema.floatVectorField, IndexType.IVF_SQ8, MetricType.L2, "{\"nlist\": 256}");
+        });
   }
 
   @Test
   public void testCreateIndexBinary() {
     testInsertBinary();
 
-    withMilvusServiceBinary(service -> {
-      service.createIndex(binarySchema.binaryVectorField, IndexType.BIN_FLAT, MetricType.JACCARD, "{}");
-    });
+    withMilvusServiceBinary(
+        service -> {
+          service.createIndex(
+              binarySchema.binaryVectorField, IndexType.BIN_FLAT, MetricType.JACCARD, "{}");
+        });
   }
 
   @Test
   public void testGetEntityByIdFloat() {
-    withMilvusServiceFloat(service -> {
-      testInsertFloat();
-
-      Map<Long, Schema.Entity> entities = service.getEntityByID(
-          LongStream.range(0, 10).boxed().collect(Collectors.toList()),
-          Arrays.asList(floatSchema.intField, floatSchema.longField));
-
-      LongStream.range(0, 10).forEach(i -> {
-        assertEquals((int) i, entities.get(i).get(floatSchema.intField));
-        assertEquals(i, entities.get(i).get(floatSchema.longField));
-      });
-    });
+    withMilvusServiceFloat(
+        service -> {
+          testInsertFloat();
+
+          Map<Long, Schema.Entity> entities =
+              service.getEntityByID(
+                  LongStream.range(0, 10).boxed().collect(Collectors.toList()),
+                  Arrays.asList(floatSchema.intField, floatSchema.longField));
+
+          LongStream.range(0, 10)
+              .forEach(
+                  i -> {
+                    assertEquals((int) i, entities.get(i).get(floatSchema.intField));
+                    assertEquals(i, entities.get(i).get(floatSchema.longField));
+                  });
+        });
   }
 
   @Test
   public void testGetEntityByIdBinary() {
-    withMilvusServiceBinary(service -> {
-      testInsertBinary();
-
-      Map<Long, Schema.Entity> entities = service.getEntityByID(
-          LongStream.range(0, 10).boxed().collect(Collectors.toList()),
-          Arrays.asList(binarySchema.intField, binarySchema.longField));
-
-      LongStream.range(0, 10).forEach(i -> {
-        assertEquals((int) i, entities.get(i).get(binarySchema.intField));
-        assertEquals(i, entities.get(i).get(binarySchema.longField));
-      });
-    });
+    withMilvusServiceBinary(
+        service -> {
+          testInsertBinary();
+
+          Map<Long, Schema.Entity> entities =
+              service.getEntityByID(
+                  LongStream.range(0, 10).boxed().collect(Collectors.toList()),
+                  Arrays.asList(binarySchema.intField, binarySchema.longField));
+
+          LongStream.range(0, 10)
+              .forEach(
+                  i -> {
+                    assertEquals((int) i, entities.get(i).get(binarySchema.intField));
+                    assertEquals(i, entities.get(i).get(binarySchema.longField));
+                  });
+        });
   }
 
   @Test
   public void testFloatVectorQuery() {
-    withMilvusServiceFloat(service -> {
-      testCreateIndexFloat();
-
-      List<Long> entityIds = LongStream.range(0, 10).boxed().collect(Collectors.toList());
-
-      Map<Long, Schema.Entity> entities = service.getEntityByID(entityIds);
-
-      List<List<Float>> vectors = entities.values().stream().map(e -> e.get(floatSchema.floatVectorField)).collect(Collectors.toList());
-
-      Query query = Query.bool(
-          Query.must(
-              floatSchema.floatVectorField.query(vectors).param("nprobe", 16).top(1)
-          )
-      );
-
-      SearchParam searchParam = service.buildSearchParam(query)
-          .setParamsInJson(new JsonBuilder().param("fields", Arrays.asList("int64", "float_vec")).build());
-
-      SearchResult searchResult = service.search(searchParam);
-      assertEquals(entityIds,
-          searchResult.getResultIdsList().stream()
-              .map(ids -> ids.get(0))
-              .collect(Collectors.toList()));
-    });
+    withMilvusServiceFloat(
+        service -> {
+          testCreateIndexFloat();
+
+          List<Long> entityIds = LongStream.range(0, 10).boxed().collect(Collectors.toList());
+
+          Map<Long, Schema.Entity> entities = service.getEntityByID(entityIds);
+
+          List<List<Float>> vectors =
+              entities.values().stream()
+                  .map(e -> e.get(floatSchema.floatVectorField))
+                  .collect(Collectors.toList());
+
+          Query query =
+              Query.bool(
+                  Query.must(
+                      floatSchema.floatVectorField.query(vectors).param("nprobe", 16).top(1)));
+
+          SearchParam searchParam =
+              service
+                  .buildSearchParam(query)
+                  .setParamsInJson(
+                      new JsonBuilder()
+                          .param("fields", Arrays.asList("int64", "float_vec"))
+                          .build());
+
+          SearchResult searchResult = service.search(searchParam);
+          assertEquals(
+              entityIds,
+              searchResult.getResultIdsList().stream()
+                  .map(ids -> ids.get(0))
+                  .collect(Collectors.toList()));
+        });
   }
 
   @Test
   public void testBinaryVectorQuery() {
-    withMilvusServiceBinary(service -> {
-      testCreateIndexBinary();
+    withMilvusServiceBinary(
+        service -> {
+          testCreateIndexBinary();
 
-      List<Long> entityIds = LongStream.range(0, 10).boxed().collect(Collectors.toList());
+          List<Long> entityIds = LongStream.range(0, 10).boxed().collect(Collectors.toList());
 
-      Map<Long, Schema.Entity> entities = service.getEntityByID(entityIds);
+          Map<Long, Schema.Entity> entities = service.getEntityByID(entityIds);
 
-      List<ByteBuffer> vectors = entities.values().stream().map(e -> e.get(binarySchema.binaryVectorField)).collect(Collectors.toList());
+          List<ByteBuffer> vectors =
+              entities.values().stream()
+                  .map(e -> e.get(binarySchema.binaryVectorField))
+                  .collect(Collectors.toList());
 
-      Query query = Query.bool(
-          Query.must(
-              binarySchema.binaryVectorField.query(vectors).top(1)
-          )
-      );
+          Query query =
+              Query.bool(Query.must(binarySchema.binaryVectorField.query(vectors).top(1)));
 
-      SearchParam searchParam = service.buildSearchParam(query);
+          SearchParam searchParam = service.buildSearchParam(query);
 
-      SearchResult searchResult = service.search(searchParam);
-      assertEquals(entityIds,
-          searchResult.getResultIdsList().stream()
-              .map(ids -> ids.get(0))
-              .collect(Collectors.toList()));
-    });
+          SearchResult searchResult = service.search(searchParam);
+          assertEquals(
+              entityIds,
+              searchResult.getResultIdsList().stream()
+                  .map(ids -> ids.get(0))
+                  .collect(Collectors.toList()));
+        });
   }
 }