Zhiru Zhu 5 سال پیش
والد
کامیت
e1b90fc1eb

+ 12 - 10
src/main/java/io/milvus/client/MilvusClient.java

@@ -33,7 +33,7 @@ public interface MilvusClient {
    * Connects to Milvus server
    *
    * @param connectParam the <code>ConnectParam</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * ConnectParam connectParam = new ConnectParam.Builder()
@@ -56,8 +56,10 @@ public interface MilvusClient {
    */
   Response connect(ConnectParam connectParam) throws ConnectFailedException;
 
-  /** @return <code>true</code> if the client is connected to Milvus server.
-   * The channel's connectivity state is READY.*/
+  /**
+   * @return <code>true</code> if the client is connected to Milvus server. The channel's
+   *     connectivity state is READY.
+   */
   boolean isConnected();
 
   /**
@@ -73,7 +75,7 @@ public interface MilvusClient {
    * Creates table specified by <code>tableSchemaParam</code>
    *
    * @param tableSchema the <code>TableSchema</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * TableSchema tableSchema = new TableSchema.Builder(tableName, dimension)
@@ -113,7 +115,7 @@ public interface MilvusClient {
    * Creates index specified by <code>indexParam</code>
    *
    * @param createIndexParam the <code>CreateIndexParam</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * Index index = new Index.Builder()
@@ -138,7 +140,7 @@ public interface MilvusClient {
    * Creates a partition specified by <code>PartitionParam</code>
    *
    * @param partition the <code>PartitionParam</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * Partition partition = new Partition.Builder(tableName, partitionName, tag).build();
@@ -163,12 +165,12 @@ public interface MilvusClient {
 
   /**
    * Drops partition specified by <code>partitionName</code>
+   *
    * @param partitionName partition name
    * @see Response
    */
   Response dropPartition(String partitionName);
 
-
   /**
    * Drops partition specified by <code>tableName</code> and <code>tag</code>
    *
@@ -182,7 +184,7 @@ public interface MilvusClient {
    * Inserts data specified by <code>insertParam</code>
    *
    * @param insertParam the <code>InsertParam</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * InsertParam insertParam = new InsertParam.Builder(tableName, vectors)
@@ -203,7 +205,7 @@ public interface MilvusClient {
    * Searches vectors specified by <code>searchParam</code>
    *
    * @param searchParam the <code>SearchParam</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * SearchParam searchParam = new SearchParam.Builder(tableName, vectorsToSearch)
@@ -227,7 +229,7 @@ public interface MilvusClient {
    * Searches vectors in specific files specified by <code>searchInFilesParam</code>
    *
    * @param searchInFilesParam the <code>SearchInFilesParam</code> object
-   * <pre>
+   *     <pre>
    * example usage:
    * <code>
    * SearchParam searchParam = new SearchParam.Builder(tableName, vectorsToSearch)

+ 45 - 39
src/main/java/io/milvus/client/Partition.java

@@ -22,52 +22,58 @@ package io.milvus.client;
 import javax.annotation.Nonnull;
 
 public class Partition {
-    private final String tableName;
-    private final String partitionName;
-    private final String tag;
+  private final String tableName;
+  private final String partitionName;
+  private final String tag;
 
-    private Partition(@Nonnull Builder builder) {
-        this.tableName = builder.tableName;
-        this.partitionName = builder.partitionName;
-        this.tag = builder.tag;
-    }
+  private Partition(@Nonnull Builder builder) {
+    this.tableName = builder.tableName;
+    this.partitionName = builder.partitionName;
+    this.tag = builder.tag;
+  }
 
-    public String getTableName() {
-        return tableName;
-    }
+  public String getTableName() {
+    return tableName;
+  }
 
-    public String getPartitionName() {
-        return partitionName;
-    }
+  public String getPartitionName() {
+    return partitionName;
+  }
 
-    public String getTag() {
-        return tag;
-    }
+  public String getTag() {
+    return tag;
+  }
 
-    @Override
-    public String toString() {
-        return "PartitionParam {" +
-                "tableName='" + tableName + '\'' +
-                ", partitionName='" + partitionName + '\'' +
-                ", tag='" + tag + '\'' +
-                '}';
-    }
+  @Override
+  public String toString() {
+    return "PartitionParam {"
+        + "tableName='"
+        + tableName
+        + '\''
+        + ", partitionName='"
+        + partitionName
+        + '\''
+        + ", tag='"
+        + tag
+        + '\''
+        + '}';
+  }
 
-    /** Builder for <code>Partition</code> */
-    public static class Builder {
-        // Required parameters
-        private final String tableName;
-        private final String partitionName;
-        private final String tag;
+  /** Builder for <code>Partition</code> */
+  public static class Builder {
+    // Required parameters
+    private final String tableName;
+    private final String partitionName;
+    private final String tag;
 
-        public Builder(@Nonnull String tableName, @Nonnull String partitionName, @Nonnull String tag) {
-            this.tableName = tableName;
-            this.partitionName = partitionName;
-            this.tag = tag;
-        }
+    public Builder(@Nonnull String tableName, @Nonnull String partitionName, @Nonnull String tag) {
+      this.tableName = tableName;
+      this.partitionName = partitionName;
+      this.tag = tag;
+    }
 
-        public Partition build() {
-            return new Partition(this);
-        }
+    public Partition build() {
+      return new Partition(this);
     }
+  }
 }

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

@@ -124,7 +124,8 @@ public class SearchParam {
     }
 
     /**
-     * Optional. Search vectors with corresponding <code>partitionTags</code>. Default to an empty <code>List</code>
+     * Optional. Search vectors with corresponding <code>partitionTags</code>. Default to an empty
+     * <code>List</code>
      *
      * @param partitionTags a <code>List</code> of partition tags
      * @return <code>Builder</code>

+ 15 - 16
src/main/java/io/milvus/client/ShowPartitionsResponse.java

@@ -22,24 +22,23 @@ package io.milvus.client;
 import java.util.List;
 
 public class ShowPartitionsResponse {
-    private final Response response;
-    private final List<Partition> partitionList;
+  private final Response response;
+  private final List<Partition> partitionList;
 
-    ShowPartitionsResponse(Response response, List<Partition> partitionList) {
-        this.response = response;
-        this.partitionList = partitionList;
-    }
+  ShowPartitionsResponse(Response response, List<Partition> partitionList) {
+    this.response = response;
+    this.partitionList = partitionList;
+  }
 
-    public List<Partition> getPartitionList() {
-        return partitionList;
-    }
+  public List<Partition> getPartitionList() {
+    return partitionList;
+  }
 
-    public Response getResponse() {
-        return response;
-    }
-
-    public boolean ok() {
-        return response.ok();
-    }
+  public Response getResponse() {
+    return response;
+  }
 
+  public boolean ok() {
+    return response.ok();
+  }
 }

+ 7 - 7
src/test/java/io/milvus/client/MilvusGrpcClientTest.java

@@ -182,7 +182,8 @@ class MilvusClientTest {
     assertTrue(createPartitionResponse.ok());
 
     List<List<Float>> vectors = generateVectors(size, dimension);
-    InsertParam insertParam = new InsertParam.Builder(randomTableName, vectors).withPartitionTag(tag).build();
+    InsertParam insertParam =
+        new InsertParam.Builder(randomTableName, vectors).withPartitionTag(tag).build();
     InsertResponse insertResponse = client.insert(insertParam);
     assertTrue(insertResponse.ok());
 
@@ -195,11 +196,11 @@ class MilvusClientTest {
     partitionTags.add(tag);
     final long topK = 10;
     SearchParam searchParam =
-            new SearchParam.Builder(randomTableName, vectorsToSearch)
-                    .withTopK(topK)
-                    .withNProbe(20)
-                    .withPartitionTags(partitionTags)
-                    .build();
+        new SearchParam.Builder(randomTableName, vectorsToSearch)
+            .withTopK(topK)
+            .withNProbe(20)
+            .withPartitionTags(partitionTags)
+            .build();
     SearchResponse searchResponse = client.search(searchParam);
     assertTrue(searchResponse.ok());
     List<List<Long>> resultIdsList = searchResponse.getResultIdsList();
@@ -225,7 +226,6 @@ class MilvusClientTest {
 
     dropPartitionResponse = client.dropPartition(randomTableName, tag2);
     assertTrue(dropPartitionResponse.ok());
-
   }
 
   @org.junit.jupiter.api.Test