浏览代码

Merge pull request #17 from youny626/branch-0.5.0

change IndexParam in DescribeIndexResponse to Index
Jin Hai 5 年之前
父节点
当前提交
409ecaa288

+ 2 - 1
CHANGELOG.md

@@ -7,7 +7,8 @@
 - \#6: Update pom & fix deleteByRange error message & update unittest
 - \#8: change default timeout to 24 hour
 - \#9: Add more getters in SearchResponse & add normalize method in unittest
-- \#10: fix connected() & add port range check & add @nonnull annotation & set maxInboundMessageSize    
+- \#10: fix connected() & add port range check & add @nonnull annotation & set maxInboundMessageSize
+- \#17: change IndexParam in DescribeIndexResponse to Index
     
 ### New Feature
 ---

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

@@ -5,15 +5,15 @@ import java.util.Optional;
 
 public class DescribeIndexResponse {
     private final Response response;
-    private final IndexParam indexParam;
+    private final Index index;
 
-    public DescribeIndexResponse(Response response, @Nullable IndexParam indexParam) {
+    public DescribeIndexResponse(Response response, @Nullable Index index) {
         this.response = response;
-        this.indexParam = indexParam;
+        this.index = index;
     }
 
-    public Optional<IndexParam> getIndexParam() {
-        return Optional.ofNullable(indexParam);
+    public Optional<Index> getIndex() {
+        return Optional.ofNullable(index);
     }
 
     public Response getResponse() {
@@ -23,6 +23,6 @@ public class DescribeIndexResponse {
     @Override
     public String toString() {
         return String.format("DescribeIndexResponse {%s, %s}", response.toString(),
-                              indexParam == null ? "Index param = None" : indexParam.toString());
+                             index == null ? "Index = Null" : index.toString());
     }
 }

+ 8 - 0
src/main/java/io/milvus/client/Index.java

@@ -38,4 +38,12 @@ public class Index {
     public int getNList() {
         return nList;
     }
+
+    @Override
+    public String toString() {
+        return "Index {" +
+                "indexType=" + indexType +
+                ", nList=" + nList +
+                '}';
+    }
 }

+ 3 - 6
src/main/java/io/milvus/client/MilvusGrpcClient.java

@@ -623,16 +623,13 @@ public class MilvusGrpcClient implements MilvusClient {
                         .withIndexType(IndexType.valueOf(response.getIndex().getIndexType()))
                         .withNList(response.getIndex().getNlist())
                         .build();
-                IndexParam indexParam = new IndexParam.Builder(response.getTableName())
-                        .withIndex(index)
-                        .build();
-                logInfo("Describe index for table `{0}` returned:\n{1}", tableName, indexParam);
-                return new DescribeIndexResponse(new Response(Response.Status.SUCCESS), indexParam);
+                logInfo("Describe index for table `{0}` returned:\n{1}", tableName, index.toString());
+                return new DescribeIndexResponse(new Response(Response.Status.SUCCESS), index);
             } else {
                 logSevere("Describe index for table `{0}` failed:\n{1}", tableName, response.toString());
                 return new DescribeIndexResponse(new Response(Response.Status.valueOf(response.getStatus().getErrorCodeValue()),
                                                               response.getStatus().getReason()),
-                                       null);
+                                            null);
             }
         } catch (StatusRuntimeException e) {
             logSevere("describeIndex RPC failed:\n{0}", e.getStatus().toString());

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

@@ -245,7 +245,7 @@ class MilvusGrpcClientTest {
     void describeIndex() {
         DescribeIndexResponse describeIndexResponse = client.describeIndex(tableParam);
         assertTrue(describeIndexResponse.getResponse().ok());
-        assertTrue(describeIndexResponse.getIndexParam().isPresent());
+        assertTrue(describeIndexResponse.getIndex().isPresent());
     }
 
     @org.junit.jupiter.api.Test