Browse Source

Rename some methods to lower case (#233)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
groot 3 years ago
parent
commit
4d3fb59b41

+ 5 - 5
examples/main/io/milvus/GeneralExample.java

@@ -155,7 +155,7 @@ public class GeneralExample {
                         .withCollectionName(COLLECTION_NAME)
                         .build());
         GetCollStatResponseWrapper wrapper = new GetCollStatResponseWrapper(response.getData());
-        System.out.println("Collection row count: " + wrapper.GetRowCount());
+        System.out.println("Collection row count: " + wrapper.getRowCount());
         return response;
     }
 
@@ -309,10 +309,10 @@ public class GeneralExample {
         SearchResultsWrapper wrapper = new SearchResultsWrapper(response.getData().getResults());
         for (int i = 0; i < vectors.size(); ++i) {
             System.out.println("Search result of No." + i);
-            List<SearchResultsWrapper.IDScore> scores = wrapper.GetIDScore(i);
+            List<SearchResultsWrapper.IDScore> scores = wrapper.getIDScore(i);
             System.out.println(scores);
         }
-        System.out.println(wrapper.GetFieldData(AGE_FIELD).getFieldData());
+        System.out.println(wrapper.getFieldData(AGE_FIELD).getFieldData());
 
         return response;
     }
@@ -340,11 +340,11 @@ public class GeneralExample {
         SearchResultsWrapper wrapper = new SearchResultsWrapper(response.getData().getResults());
         for (int i = 0; i < vectors.size(); ++i) {
             System.out.println("Search result of No." + i);
-            List<SearchResultsWrapper.IDScore> scores = wrapper.GetIDScore(i);
+            List<SearchResultsWrapper.IDScore> scores = wrapper.getIDScore(i);
             System.out.println(scores);
         }
 
-        System.out.println(wrapper.GetFieldData(AGE_FIELD).getFieldData());
+        System.out.println(wrapper.getFieldData(AGE_FIELD).getFieldData());
 
         return response;
     }

+ 15 - 15
src/main/java/io/milvus/Response/DescCollResponseWrapper.java

@@ -27,7 +27,7 @@ public class DescCollResponseWrapper {
      *
      * @return <code>String</code> name of the collection
      */
-    public String GetCollectionName() {
+    public String getCollectionName() {
         CollectionSchema schema = response.getSchema();
         return schema.getName();
     }
@@ -37,7 +37,7 @@ public class DescCollResponseWrapper {
      *
      * @return <code>String</code> description of the collection
      */
-    public String GetCollectionDescription() {
+    public String getCollectionDescription() {
         CollectionSchema schema = response.getSchema();
         return schema.getDescription();
     }
@@ -47,7 +47,7 @@ public class DescCollResponseWrapper {
      *
      * @return <code>long</code> internal id of the collection
      */
-    public long GetCollectionID() {
+    public long getCollectionID() {
         return response.getCollectionID();
     }
 
@@ -56,7 +56,7 @@ public class DescCollResponseWrapper {
      *
      * @return <code>int</code> shard number of the collection
      */
-    public int GetShardNumber() {
+    public int getShardNumber() {
         return response.getShardsNum();
     }
 
@@ -65,7 +65,7 @@ public class DescCollResponseWrapper {
      *
      * @return <code>long</code> utc timestamp when collection created
      */
-    public long GetCreatedUtcTimestamp() {
+    public long getCreatedUtcTimestamp() {
         return response.getCreatedUtcTimestamp();
     }
 
@@ -74,7 +74,7 @@ public class DescCollResponseWrapper {
      *
      * @return <code>List<String></String></code> aliases of the collection
      */
-    public List<String> GetAliases() {
+    public List<String> getAliases() {
         List<String> aliases = new ArrayList<>();
         for (int i = 0; i < response.getAliasesCount(); ++i) {
             aliases.add(response.getAliases(i));
@@ -88,7 +88,7 @@ public class DescCollResponseWrapper {
      *
      * @return <code>List<FieldType></code> schema of the collection's fields
      */
-    public List<FieldType> GetFields() {
+    public List<FieldType> getFields() {
         List<FieldType> results = new ArrayList<>();
         CollectionSchema schema = response.getSchema();
         List<FieldSchema> fields = schema.getFieldsList();
@@ -103,7 +103,7 @@ public class DescCollResponseWrapper {
      *
      * @return <code>FieldType</code> schema of the field
      */
-    public FieldType GetField(@NonNull String name) {
+    public FieldType getFieldByName(@NonNull String name) {
         CollectionSchema schema = response.getSchema();
         for (int i = 0; i < schema.getFieldsCount(); ++i) {
             FieldSchema field = schema.getFields(i);
@@ -142,13 +142,13 @@ public class DescCollResponseWrapper {
     @Override
     public String toString() {
         return "Collection Description{" +
-                "name:'" + GetCollectionName() + '\'' +
-                ", description:'" + GetCollectionDescription() + '\'' +
-                ", id:" + GetCollectionID() +
-                ", shardNumber:" + GetShardNumber() +
-                ", createdUtcTimestamp:" + GetCreatedUtcTimestamp() +
-                ", aliases:" + GetAliases() +
-                ", fields:" + GetFields().toString() +
+                "name:'" + getCollectionName() + '\'' +
+                ", description:'" + getCollectionDescription() + '\'' +
+                ", id:" + getCollectionID() +
+                ", shardNumber:" + getShardNumber() +
+                ", createdUtcTimestamp:" + getCreatedUtcTimestamp() +
+                ", aliases:" + getAliases() +
+                ", fields:" + getFields().toString() +
                 '}';
     }
 }

+ 40 - 9
src/main/java/io/milvus/Response/DescIndexResponseWrapper.java

@@ -3,6 +3,9 @@ package io.milvus.Response;
 import io.milvus.grpc.IndexDescription;
 import io.milvus.grpc.DescribeIndexResponse;
 
+import io.milvus.param.Constant;
+import io.milvus.param.IndexType;
+import io.milvus.param.MetricType;
 import lombok.Getter;
 import lombok.NonNull;
 
@@ -26,12 +29,12 @@ public class DescIndexResponseWrapper {
      *
      * @return <code>List<IndexDesc></code> index description of fields
      */
-    public List<IndexDesc> GetIndexDescriptions() {
+    public List<IndexDesc> getIndexDescriptions() {
         List<IndexDesc> results = new ArrayList<>();
         List<IndexDescription> descriptions = response.getIndexDescriptionsList();
         descriptions.forEach((desc)->{
             IndexDesc res = new IndexDesc(desc.getFieldName(), desc.getIndexName(), desc.getIndexID());
-            desc.getParamsList().forEach((kv)-> res.AddParam(kv.getKey(), kv.getValue()));
+            desc.getParamsList().forEach((kv)-> res.addParam(kv.getKey(), kv.getValue()));
             results.add(res);
         });
 
@@ -44,12 +47,12 @@ public class DescIndexResponseWrapper {
      *
      * @return <code>IndexDesc</code> description of the index
      */
-    public IndexDesc GetIndexDescByFieldName(@NonNull String name) {
+    public IndexDesc getIndexDescByFieldName(@NonNull String name) {
         for (int i = 0; i < response.getIndexDescriptionsCount(); ++i) {
             IndexDescription desc = response.getIndexDescriptions(i);
             if (name.compareTo(desc.getFieldName()) == 0) {
                 IndexDesc res = new IndexDesc(desc.getFieldName(), desc.getIndexName(), desc.getIndexID());
-                desc.getParamsList().forEach((kv)-> res.AddParam(kv.getKey(), kv.getValue()));
+                desc.getParamsList().forEach((kv)-> res.addParam(kv.getKey(), kv.getValue()));
                 return res;
             }
         }
@@ -67,20 +70,48 @@ public class DescIndexResponseWrapper {
         private final long id;
         private final Map<String, String> params = new HashMap<>();
 
-        public IndexDesc(@NonNull String fieldName, String indexName, long id) {
+        public IndexDesc(@NonNull String fieldName, @NonNull String indexName, long id) {
             this.fieldName = fieldName;
             this.indexName = indexName;
             this.id = id;
         }
 
-        public void AddParam(@NonNull String key, @NonNull String value) {
+        public void addParam(@NonNull String key, @NonNull String value) {
             this.params.put(key, value);
         }
 
+        public IndexType getIndexType() {
+            if (this.params.containsKey(Constant.INDEX_TYPE)) {
+                // may throw IllegalArgumentException
+                return IndexType.valueOf(params.get(Constant.INDEX_TYPE));
+            }
+
+            return IndexType.INVALID;
+        }
+
+        public MetricType getMetricType() {
+            if (this.params.containsKey(Constant.METRIC_TYPE)) {
+                // may throw IllegalArgumentException
+                return MetricType.valueOf(params.get(Constant.METRIC_TYPE));
+            }
+
+            return MetricType.INVALID;
+        }
+
+        public String getExtraParam() {
+            if (this.params.containsKey(Constant.PARAMS)) {
+                // may throw IllegalArgumentException
+                return params.get(Constant.PARAMS);
+            }
+
+            return "";
+        }
+
         @Override
         public String toString() {
-            return "(fieldName: " + fieldName + " indexName: " + indexName + " id: " + id + " params: " +
-                    params.toString() + ")";
+            return "IndexDesc(fieldName: " + getFieldName() + " indexName: " + getIndexName() +
+                    " id: " + getId() + " indexType: " + getIndexType().name() + " metricType: " +
+                    getMetricType().name() + " extraParam: " + getExtraParam() + ")";
         }
     }
 
@@ -92,7 +123,7 @@ public class DescIndexResponseWrapper {
     @Override
     public String toString() {
         return "Index description{" +
-                GetIndexDescriptions().toString() +
+                getIndexDescriptions().toString() +
                 '}';
     }
 }

+ 1 - 1
src/main/java/io/milvus/Response/GetCollStatResponseWrapper.java

@@ -22,7 +22,7 @@ public class GetCollStatResponseWrapper {
      *
      * @return <code>int</code> dimension of the vector field
      */
-    public long GetRowCount() throws NumberFormatException {
+    public long getRowCount() throws NumberFormatException {
         List<KeyValuePair> stats = stat.getStatsList();
         for (KeyValuePair kv : stats) {
             if (kv.getKey().compareTo("row_count") == 0) {

+ 1 - 1
src/main/java/io/milvus/Response/GetPartStatResponseWrapper.java

@@ -22,7 +22,7 @@ public class GetPartStatResponseWrapper {
      *
      * @return <code>int</code> dimension of the vector field
      */
-    public long GetRowCount() throws NumberFormatException {
+    public long getRowCount() throws NumberFormatException {
         List<KeyValuePair> stats = stat.getStatsList();
         for (KeyValuePair kv : stats) {
             if (kv.getKey().compareTo("row_count") == 0) {

+ 2 - 2
src/main/java/io/milvus/Response/SearchResultsWrapper.java

@@ -25,7 +25,7 @@ public class SearchResultsWrapper {
      *
      * @return <code>FieldDataWrapper</code>
      */
-    public FieldDataWrapper GetFieldData(@NonNull String fieldName) {
+    public FieldDataWrapper getFieldData(@NonNull String fieldName) {
         for (int i = 0; i < results.getFieldsDataCount(); ++i) {
             FieldData data = results.getFieldsData(i);
             if (fieldName.compareTo(data.getFieldName()) == 0) {
@@ -43,7 +43,7 @@ public class SearchResultsWrapper {
      *
      * @return <code>List<IDScore></code> ID-score pairs returned by search interface
      */
-    public List<IDScore> GetIDScore(int indexOfTarget) throws ParamException, IllegalResponseException {
+    public List<IDScore> getIDScore(int indexOfTarget) throws ParamException, IllegalResponseException {
         List<Long> kList = results.getTopksList();
 
         // if the server didn't return separate topK, use same topK value

+ 5 - 5
src/main/java/io/milvus/Response/ShowCollResponseWrapper.java

@@ -24,7 +24,7 @@ public class ShowCollResponseWrapper {
      *
      * @return <code>List<CollectionInfo></code> information array of the collections
      */
-    public List<CollectionInfo> GetCollectionsInfo() throws IllegalResponseException {
+    public List<CollectionInfo> getCollectionsInfo() throws IllegalResponseException {
         if (response.getCollectionNamesCount() != response.getCollectionIdsCount()
             || response.getCollectionNamesCount() != response.getCreatedUtcTimestampsCount()) {
             throw new IllegalResponseException("Collection information count doesn't match");
@@ -48,7 +48,7 @@ public class ShowCollResponseWrapper {
      *
      * @return <code>CollectionInfo</code> information of the collection
      */
-    public CollectionInfo GetCollectionInfo(@NonNull String name) {
+    public CollectionInfo getCollectionInfo(@NonNull String name) {
         for (int i = 0; i < response.getCollectionNamesCount(); ++i) {
             if ( name.compareTo(response.getCollectionNames(i)) == 0) {
                 CollectionInfo info = new CollectionInfo(response.getCollectionNames(i), response.getCollectionIds(i),
@@ -85,8 +85,8 @@ public class ShowCollResponseWrapper {
 
         @Override
         public String toString() {
-            return "(name: " + name + " id: " + id + " utcTimestamp: " + utcTimestamp + " inMemoryPercentage: "
-                    + inMemoryPercentage + ")";
+            return "(name: " + getName() + " id: " + getId() + " utcTimestamp: " + getUtcTimestamp() +
+                    " inMemoryPercentage: " + getInMemoryPercentage() + ")";
         }
     }
 
@@ -98,7 +98,7 @@ public class ShowCollResponseWrapper {
     @Override
     public String toString() {
         return "Collections{" +
-                GetCollectionsInfo().toString() +
+                getCollectionsInfo().toString() +
                 '}';
     }
 }

+ 8 - 8
src/main/java/io/milvus/Response/ShowPartResponseWrapper.java

@@ -24,7 +24,7 @@ public class ShowPartResponseWrapper {
      *
      * @return <code>List<PartitionInfo></code> information array of the partitions
      */
-    public List<PartitionInfo> GetPartitionsInfo() throws IllegalResponseException {
+    public List<PartitionInfo> getPartitionsInfo() throws IllegalResponseException {
         if (response.getPartitionNamesCount() != response.getPartitionIDsCount()
                 || response.getPartitionNamesCount() != response.getCreatedUtcTimestampsCount()) {
             throw new IllegalResponseException("Partition information count doesn't match");
@@ -35,7 +35,7 @@ public class ShowPartResponseWrapper {
             PartitionInfo info = new PartitionInfo(response.getPartitionNames(i), response.getPartitionIDs(i),
                     response.getCreatedUtcTimestamps(i));
             if (response.getInMemoryPercentagesCount() > i) {
-                info.SetInMemoryPercentage(response.getInMemoryPercentages(i));
+                info.setInMemoryPercentage(response.getInMemoryPercentages(i));
             }
             results.add(info);
         }
@@ -48,13 +48,13 @@ public class ShowPartResponseWrapper {
      *
      * @return <code>PartitionInfo</code> information of the partition
      */
-    public PartitionInfo GetPartitionInfo(@NonNull String name) {
+    public PartitionInfo getPartitionInfoByName(@NonNull String name) {
         for (int i = 0; i < response.getPartitionNamesCount(); ++i) {
             if ( name.compareTo(response.getPartitionNames(i)) == 0) {
                 PartitionInfo info = new PartitionInfo(response.getPartitionNames(i), response.getPartitionIDs(i),
                         response.getCreatedUtcTimestamps(i));
                 if (response.getInMemoryPercentagesCount() > i) {
-                    info.SetInMemoryPercentage(response.getInMemoryPercentages(i));
+                    info.setInMemoryPercentage(response.getInMemoryPercentages(i));
                 }
                 return info;
             }
@@ -79,14 +79,14 @@ public class ShowPartResponseWrapper {
             this.utcTimestamp = utcTimestamp;
         }
 
-        public void SetInMemoryPercentage(long inMemoryPercentage) {
+        public void setInMemoryPercentage(long inMemoryPercentage) {
             this.inMemoryPercentage = inMemoryPercentage;
         }
 
         @Override
         public String toString() {
-            return "(name: " + name + " id: " + id + " utcTimestamp: " + utcTimestamp + " inMemoryPercentage: "
-                    + inMemoryPercentage + ")";
+            return "(name: " + getName() + " id: " + getId() + " utcTimestamp: " + getUtcTimestamp() +
+                    " inMemoryPercentage: " + getInMemoryPercentage() + ")";
         }
     }
 
@@ -98,7 +98,7 @@ public class ShowPartResponseWrapper {
     @Override
     public String toString() {
         return "Partitions{" +
-                GetPartitionsInfo().toString() +
+                getPartitionsInfo().toString() +
                 '}';
     }
 }

+ 5 - 5
src/test/java/io/milvus/client/MilvusClientDockerTest.java

@@ -267,7 +267,7 @@ public class MilvusClientDockerTest {
         assertEquals(statR.getStatus().intValue(), R.Status.Success.getCode());
 
         GetCollStatResponseWrapper stat = new GetCollStatResponseWrapper(statR.getData());
-        System.out.println("Collection row count: " + stat.GetRowCount());
+        System.out.println("Collection row count: " + stat.getRowCount());
 
         // get partition statistics
         R<GetPartitionStatisticsResponse> statPartR = client.getPartitionStatistics(GetPartitionStatisticsParam
@@ -279,7 +279,7 @@ public class MilvusClientDockerTest {
         assertEquals(statPartR.getStatus().intValue(), R.Status.Success.getCode());
 
         GetPartStatResponseWrapper statPart = new GetPartStatResponseWrapper(statPartR.getData());
-        System.out.println("Partition row count: " + statPart.GetRowCount());
+        System.out.println("Partition row count: " + statPart.getRowCount());
 
         // create index
         CreateIndexParam indexParam = CreateIndexParam.newBuilder()
@@ -420,7 +420,7 @@ public class MilvusClientDockerTest {
         // verify the search result
         SearchResultsWrapper results = new SearchResultsWrapper(searchR.getData().getResults());
         for (int i = 0; i < targetVectors.size(); ++i) {
-            List<SearchResultsWrapper.IDScore> scores = results.GetIDScore(i);
+            List<SearchResultsWrapper.IDScore> scores = results.getIDScore(i);
             System.out.println("The result of No." + i + " target vector(ID = " + targetVectorIDs.get(i) + "):");
             System.out.println(scores);
             assertEquals(targetVectorIDs.get(i).longValue(), scores.get(0).getLongID());
@@ -498,7 +498,7 @@ public class MilvusClientDockerTest {
         assertEquals(statR.getStatus().intValue(), R.Status.Success.getCode());
 
         GetCollStatResponseWrapper stat = new GetCollStatResponseWrapper(statR.getData());
-        System.out.println("Collection row count: " + stat.GetRowCount());
+        System.out.println("Collection row count: " + stat.getRowCount());
 
         // load collection
         R<RpcStatus> loadR = client.loadCollection(LoadCollectionParam.newBuilder()
@@ -533,7 +533,7 @@ public class MilvusClientDockerTest {
         // verify the search result
         SearchResultsWrapper results = new SearchResultsWrapper(searchR.getData().getResults());
         for (int i = 0; i < targetVectors.size(); ++i) {
-            List<SearchResultsWrapper.IDScore> scores = results.GetIDScore(i);
+            List<SearchResultsWrapper.IDScore> scores = results.getIDScore(i);
             System.out.println("The result of No." + i + " target vector(ID = " + targetVectorIDs.get(i) + "):");
             System.out.println(scores);
             assertEquals(targetVectorIDs.get(i).longValue(), scores.get(0).getLongID());

+ 8 - 8
src/test/java/io/milvus/client/MilvusServiceClientTest.java

@@ -1971,17 +1971,17 @@ class MilvusServiceClientTest {
                 .addStats(KeyValuePair.newBuilder().setKey("row_count").setValue("invalid").build())
                 .build();
         GetCollStatResponseWrapper invalidWrapper = new GetCollStatResponseWrapper(response);
-        assertThrows(NumberFormatException.class, invalidWrapper::GetRowCount);
+        assertThrows(NumberFormatException.class, invalidWrapper::getRowCount);
 
         response = GetCollectionStatisticsResponse.newBuilder()
                 .addStats(KeyValuePair.newBuilder().setKey("row_count").setValue("10").build())
                 .build();
         GetCollStatResponseWrapper wrapper = new GetCollStatResponseWrapper(response);
-        assertEquals(10, wrapper.GetRowCount());
+        assertEquals(10, wrapper.getRowCount());
 
         response = GetCollectionStatisticsResponse.newBuilder().build();
         wrapper = new GetCollStatResponseWrapper(response);
-        assertEquals(0, wrapper.GetRowCount());
+        assertEquals(0, wrapper.getRowCount());
     }
 
     @Test
@@ -2068,12 +2068,12 @@ class MilvusServiceClientTest {
                 .build();
 
         SearchResultsWrapper intWrapper = new SearchResultsWrapper(results);
-        assertNotNull(intWrapper.GetFieldData(fieldName));
-        assertNull(intWrapper.GetFieldData("invalid"));
+        assertNotNull(intWrapper.getFieldData(fieldName));
+        assertNull(intWrapper.getFieldData("invalid"));
 
-        List<SearchResultsWrapper.IDScore> idScores = intWrapper.GetIDScore(1);
+        List<SearchResultsWrapper.IDScore> idScores = intWrapper.getIDScore(1);
         assertEquals(idScores.size(), topK);
-        assertThrows(ParamException.class, () -> intWrapper.GetIDScore((int) numQueries));
+        assertThrows(ParamException.class, () -> intWrapper.getIDScore((int) numQueries));
 
         // for string id
         results = SearchResultData.newBuilder()
@@ -2090,7 +2090,7 @@ class MilvusServiceClientTest {
                 .build();
 
         SearchResultsWrapper strWrapper = new SearchResultsWrapper(results);
-        idScores = strWrapper.GetIDScore(0);
+        idScores = strWrapper.getIDScore(0);
         assertEquals(idScores.size(), topK);
     }
 }