2
0
Эх сурвалжийг харах

change IndexParam in DescribeIndexResponse to Index

zhiru 5 жил өмнө
parent
commit
3895b8d058

+ 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());

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

@@ -31,7 +31,7 @@ class MilvusGrpcClientTest {
 
         client = new MilvusGrpcClient();
         ConnectParam connectParam = new ConnectParam.Builder()
-                                        .withHost("localhost")
+                                        .withHost("192.168.1.149")
                                         .withPort("19530")
                                         .build();
         client.connect(connectParam);
@@ -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