diff --git a/examples/pom.xml b/examples/pom.xml index 91d9532f9..aef753bfa 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -77,12 +77,6 @@ tensorflow-core-platform 0.5.0 - - org.projectlombok - lombok - 1.18.22 - provided - org.slf4j slf4j-log4j12 diff --git a/examples/src/main/java/io/milvus/v1/ArrayFieldExample.java b/examples/src/main/java/io/milvus/v1/ArrayFieldExample.java index bad93ce96..c61493c48 100644 --- a/examples/src/main/java/io/milvus/v1/ArrayFieldExample.java +++ b/examples/src/main/java/io/milvus/v1/ArrayFieldExample.java @@ -34,7 +34,10 @@ import io.milvus.param.index.CreateIndexParam; import io.milvus.response.QueryResultsWrapper; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Random; public class ArrayFieldExample { private static final String COLLECTION_NAME = "java_sdk_example_array_v1"; @@ -141,7 +144,7 @@ public static void main(String[] args) { List strArray = new ArrayList<>(); int capacity = random.nextInt(5) + 5; for (int k = 0; k < capacity; k++) { - intArray.add((i+k)%100); + intArray.add((i + k) % 100); strArray.add(String.format("string-%d-%d", i, k)); } intArrArray.add(intArray); @@ -186,7 +189,7 @@ public static void main(String[] args) { .withConsistencyLevel(ConsistencyLevelEnum.STRONG) .build()); QueryResultsWrapper queryWrapper = new QueryResultsWrapper(queryRet.getData()); - System.out.printf("%d rows in collection\n", (long)queryWrapper.getFieldWrapper("count(*)").getFieldData().get(0)); + System.out.printf("%d rows in collection\n", (long) queryWrapper.getFieldWrapper("count(*)").getFieldData().get(0)); // Query by filtering expression queryWithExpr(client, "array_int32[0] == 99"); diff --git a/examples/src/main/java/io/milvus/v1/BinaryVectorExample.java b/examples/src/main/java/io/milvus/v1/BinaryVectorExample.java index 85ca00d94..5787a52cd 100644 --- a/examples/src/main/java/io/milvus/v1/BinaryVectorExample.java +++ b/examples/src/main/java/io/milvus/v1/BinaryVectorExample.java @@ -42,7 +42,7 @@ public class BinaryVectorExample { private static final String VECTOR_FIELD = "vector"; private static final Integer VECTOR_DIM = 128; - + public static void main(String[] args) { // Connect to Milvus server. Replace the "localhost" and port with your Milvus server address. @@ -172,7 +172,7 @@ public static void main(String[] args) { System.out.printf("The result of No.%d target vector:\n", i); for (SearchResultsWrapper.IDScore score : scores) { System.out.println(score); - ByteBuffer vector = (ByteBuffer)score.get(VECTOR_FIELD); + ByteBuffer vector = (ByteBuffer) score.get(VECTOR_FIELD); CommonUtils.printBinaryVector(vector); } if (scores.get(0).getLongID() != k) { diff --git a/examples/src/main/java/io/milvus/v1/BulkWriterExample.java b/examples/src/main/java/io/milvus/v1/BulkWriterExample.java index cea07c4c4..80f46af56 100644 --- a/examples/src/main/java/io/milvus/v1/BulkWriterExample.java +++ b/examples/src/main/java/io/milvus/v1/BulkWriterExample.java @@ -24,11 +24,7 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import io.milvus.bulkwriter.BulkWriter; -import io.milvus.bulkwriter.LocalBulkWriter; -import io.milvus.bulkwriter.LocalBulkWriterParam; -import io.milvus.bulkwriter.RemoteBulkWriter; -import io.milvus.bulkwriter.RemoteBulkWriterParam; +import io.milvus.bulkwriter.*; import io.milvus.bulkwriter.common.clientenum.BulkFileType; import io.milvus.bulkwriter.common.clientenum.CloudStorage; import io.milvus.bulkwriter.common.utils.GeneratorUtils; @@ -50,19 +46,8 @@ import io.milvus.grpc.DataType; import io.milvus.grpc.GetCollectionStatisticsResponse; import io.milvus.grpc.QueryResults; -import io.milvus.param.ConnectParam; -import io.milvus.param.IndexType; -import io.milvus.param.MetricType; -import io.milvus.param.R; -import io.milvus.param.RpcStatus; -import io.milvus.param.collection.CollectionSchemaParam; -import io.milvus.param.collection.CreateCollectionParam; -import io.milvus.param.collection.DropCollectionParam; -import io.milvus.param.collection.FieldType; -import io.milvus.param.collection.FlushParam; -import io.milvus.param.collection.GetCollectionStatisticsParam; -import io.milvus.param.collection.HasCollectionParam; -import io.milvus.param.collection.LoadCollectionParam; +import io.milvus.param.*; +import io.milvus.param.collection.*; import io.milvus.param.dml.QueryParam; import io.milvus.param.index.CreateIndexParam; import io.milvus.response.GetCollStatResponseWrapper; @@ -74,11 +59,7 @@ import java.io.File; import java.io.IOException; import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.TimeUnit; @@ -596,7 +577,7 @@ private void callCloudImport(List> batchFiles, String collectionNam /** * @param collectionSchema collection info - * @param dropIfExist if collection already exist, will drop firstly and then create again + * @param dropIfExist if collection already exist, will drop firstly and then create again */ private void createCollection(String collectionName, CollectionSchemaParam collectionSchema, boolean dropIfExist) { System.out.println("\n===================== create collection ===================="); diff --git a/examples/src/main/java/io/milvus/v1/ClientPoolExample.java b/examples/src/main/java/io/milvus/v1/ClientPoolExample.java index 72dd615f9..634b2be56 100644 --- a/examples/src/main/java/io/milvus/v1/ClientPoolExample.java +++ b/examples/src/main/java/io/milvus/v1/ClientPoolExample.java @@ -38,7 +38,10 @@ import io.milvus.response.QueryResultsWrapper; import java.time.Duration; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; public class ClientPoolExample { public static String serverUri = "http://localhost:19530"; @@ -51,6 +54,7 @@ private static void printKeyClientNumber(MilvusClientV1Pool pool, String key) { System.out.printf("Key '%s': %d idle clients and %d active clients%n", key, pool.getIdleClientNumber(key), pool.getActiveClientNumber(key)); } + private static void printClientNumber(MilvusClientV1Pool pool) { System.out.println("======================================================================"); System.out.printf("Total %d idle clients and %d active clients%n", @@ -158,7 +162,7 @@ public static Thread runInsertThread(MilvusClientV1Pool pool, String dbName, int Gson gson = new Gson(); for (int i = 0; i < repeatRequests; i++) { MilvusClient client = null; - while(client == null) { + while (client == null) { try { // getClient() might exceeds the borrowMaxWaitMillis and throw exception // retry to call until it return a client @@ -201,7 +205,7 @@ public static Thread runSearchThread(MilvusClientV1Pool pool, String dbName, int Thread t = new Thread(() -> { for (int i = 0; i < repeatRequests; i++) { MilvusClient client = null; - while(client == null) { + while (client == null) { try { // getClient() might exceeds the borrowMaxWaitMillis and throw exception // retry to call until it return a client @@ -253,7 +257,7 @@ public static void verifyRowCount(MilvusClientV1Pool pool, long expectedCount) { .withConsistencyLevel(ConsistencyLevelEnum.STRONG) .build()); QueryResultsWrapper queryWrapper = new QueryResultsWrapper(queryRet.getData()); - long rowCount = (long)queryWrapper.getFieldWrapper("count(*)").getFieldData().get(0); + long rowCount = (long) queryWrapper.getFieldWrapper("count(*)").getFieldData().get(0); System.out.printf("%d rows persisted in collection '%s' of database '%s'%n", rowCount, CollectionName, dbName); if (rowCount != expectedCount) { @@ -359,7 +363,7 @@ public static void main(String[] args) throws InterruptedException { printClientNumber(pool); // check row count of each collection, there are threadCount*repeatRequests rows were inserted by multiple threads - verifyRowCount(pool, threadCount*repeatRequests); + verifyRowCount(pool, threadCount * repeatRequests); // drop collections dropCollections(pool); // drop databases, only after database is empty, it is able to be dropped @@ -367,7 +371,7 @@ public static void main(String[] args) throws InterruptedException { long end = System.currentTimeMillis(); System.out.printf("%d insert requests and %d search requests finished in %.3f seconds%n", - threadCount*repeatRequests*3, threadCount*repeatRequests*3, (end-start)*0.001); + threadCount * repeatRequests * 3, threadCount * repeatRequests * 3, (end - start) * 0.001); printClientNumber(pool); pool.clear(); // clear idle clients diff --git a/examples/src/main/java/io/milvus/v1/CommonUtils.java b/examples/src/main/java/io/milvus/v1/CommonUtils.java index 0d89dab49..e41f0c5d4 100644 --- a/examples/src/main/java/io/milvus/v1/CommonUtils.java +++ b/examples/src/main/java/io/milvus/v1/CommonUtils.java @@ -20,7 +20,6 @@ import io.milvus.common.utils.Float16Utils; import io.milvus.param.R; - import org.tensorflow.Tensor; import org.tensorflow.ndarray.Shape; import org.tensorflow.ndarray.buffer.ByteDataBuffer; @@ -69,7 +68,7 @@ public static List> generateFloatVectors(int dimension, int count) { public static List> generateFixFloatVectors(int dimension, int count) { List> vectors = new ArrayList<>(); for (int n = 0; n < count; ++n) { - List vector = generateFloatVector(dimension, (float)n); + List vector = generateFloatVector(dimension, (float) n); vectors.add(vector); } return vectors; @@ -87,7 +86,7 @@ public static void compareFloatVectors(List vec1, List vec2) { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////// + /// ////////////////////////////////////////////////////////////////////////////////////////////////// public static ByteBuffer generateBinaryVector(int dimension) { Random ran = new Random(); int byteCount = dimension / 8; @@ -117,7 +116,7 @@ public static void printBinaryVector(ByteBuffer vector) { System.out.println(); } - ///////////////////////////////////////////////////////////////////////////////////////////////////// + /// ////////////////////////////////////////////////////////////////////////////////////////////////// public static TBfloat16 genTensorflowBF16Vector(int dimension) { Random ran = new Random(); float[] array = new float[dimension]; @@ -131,7 +130,7 @@ public static TBfloat16 genTensorflowBF16Vector(int dimension) { public static List genTensorflowBF16Vectors(int dimension, int count) { List vectors = new ArrayList<>(); for (int n = 0; n < count; ++n) { - TBfloat16 vector = genTensorflowBF16Vector(dimension); + TBfloat16 vector = genTensorflowBF16Vector(dimension); vectors.add(vector); } @@ -140,7 +139,7 @@ public static List genTensorflowBF16Vectors(int dimension, int count) public static ByteBuffer encodeTensorBF16Vector(TBfloat16 vector) { ByteDataBuffer tensorBuf = vector.asRawTensor().data(); - ByteBuffer buf = ByteBuffer.allocate((int)tensorBuf.size()); + ByteBuffer buf = ByteBuffer.allocate((int) tensorBuf.size()); for (long i = 0; i < tensorBuf.size(); i++) { buf.put(tensorBuf.getByte(i)); } @@ -157,10 +156,10 @@ public static List encodeTensorBF16Vectors(List vectors) } public static TBfloat16 decodeBF16VectorToTensor(ByteBuffer buf) { - if (buf.limit()%2 != 0) { + if (buf.limit() % 2 != 0) { return null; } - int dim = buf.limit()/2; + int dim = buf.limit() / 2; ByteDataBuffer bf = DataBuffers.of(buf.array()); return Tensor.of(TBfloat16.class, Shape.of(dim), bf); } @@ -197,7 +196,7 @@ public static List genTensorflowFP16Vectors(int dimension, int count) public static ByteBuffer encodeTensorFP16Vector(TFloat16 vector) { ByteDataBuffer tensorBuf = vector.asRawTensor().data(); - ByteBuffer buf = ByteBuffer.allocate((int)tensorBuf.size()); + ByteBuffer buf = ByteBuffer.allocate((int) tensorBuf.size()); for (long i = 0; i < tensorBuf.size(); i++) { buf.put(tensorBuf.getByte(i)); } @@ -214,10 +213,10 @@ public static List encodeTensorFP16Vectors(List vectors) { } public static TFloat16 decodeFP16VectorToTensor(ByteBuffer buf) { - if (buf.limit()%2 != 0) { + if (buf.limit() % 2 != 0) { return null; } - int dim = buf.limit()/2; + int dim = buf.limit() / 2; ByteDataBuffer bf = DataBuffers.of(buf.array()); return Tensor.of(TFloat16.class, Shape.of(dim), bf); } @@ -231,7 +230,7 @@ public static List decodeFP16VectorToFloat(ByteBuffer buf) { return vector; } - ///////////////////////////////////////////////////////////////////////////////////////////////////// + /// ////////////////////////////////////////////////////////////////////////////////////////////////// public static ByteBuffer encodeFloat16Vector(List originVector, boolean bfloat16) { if (bfloat16) { return Float16Utils.f32VectorToBf16Buffer(originVector); @@ -274,7 +273,7 @@ public static List generateFloat16Vectors(int dimension, int count, return vectors; } - ///////////////////////////////////////////////////////////////////////////////////////////////////// + /// ////////////////////////////////////////////////////////////////////////////////////////////////// public static ByteBuffer generateInt8Vector(int dimension) { Random ran = new Random(); int byteCount = dimension; @@ -295,13 +294,13 @@ public static List generateInt8Vectors(int dimension, int count) { return vectors; } - ///////////////////////////////////////////////////////////////////////////////////////////////////// + /// ////////////////////////////////////////////////////////////////////////////////////////////////// public static SortedMap generateSparseVector() { Random ran = new Random(); SortedMap sparse = new TreeMap<>(); int dim = ran.nextInt(10) + 10; while (sparse.size() < dim) { - sparse.put((long)ran.nextInt(1000000), ran.nextFloat()); + sparse.put((long) ran.nextInt(1000000), ran.nextFloat()); } return sparse; } diff --git a/examples/src/main/java/io/milvus/v1/ConsistencyLevelExample.java b/examples/src/main/java/io/milvus/v1/ConsistencyLevelExample.java index c8b58f45b..f39477fda 100644 --- a/examples/src/main/java/io/milvus/v1/ConsistencyLevelExample.java +++ b/examples/src/main/java/io/milvus/v1/ConsistencyLevelExample.java @@ -137,7 +137,7 @@ private static List search(String collectionName, .withCollectionName(collectionName) .withVectorFieldName("vector") .withFloatVectors(Collections.singletonList(CommonUtils.generateFloatVector(VECTOR_DIM))) - .withLimit((long)topK) + .withLimit((long) topK) .withMetricType(MetricType.L2) .build()); CommonUtils.handleResponseStatus(searchR); @@ -187,7 +187,7 @@ private static void testSessionLevel() throws ClassNotFoundException, NoSuchMeth row.add("vector", gson.toJsonTree(vector)); // insert by a MilvusClient - String clientName1 = String.format("client_%d", i%10); + String clientName1 = String.format("client_%d", i % 10); MilvusClient client1 = pool.getClient(clientName1); client1.insert(InsertParam.newBuilder() .withCollectionName(collectionName) @@ -198,7 +198,7 @@ private static void testSessionLevel() throws ClassNotFoundException, NoSuchMeth // search by another MilvusClient, use the just inserted vector to search // the returned item is expected to be the just inserted item - String clientName2 = String.format("client_%d", i%10+1); + String clientName2 = String.format("client_%d", i % 10 + 1); MilvusClient client2 = pool.getClient(clientName2); R searchR = client2.search(SearchParam.newBuilder() .withCollectionName(collectionName) diff --git a/examples/src/main/java/io/milvus/v1/Float16VectorExample.java b/examples/src/main/java/io/milvus/v1/Float16VectorExample.java index 9cd1c21ac..1ebbf0c16 100644 --- a/examples/src/main/java/io/milvus/v1/Float16VectorExample.java +++ b/examples/src/main/java/io/milvus/v1/Float16VectorExample.java @@ -22,12 +22,19 @@ import com.google.gson.JsonObject; import io.milvus.client.MilvusServiceClient; import io.milvus.common.clientenum.ConsistencyLevelEnum; -import io.milvus.grpc.*; +import io.milvus.grpc.DataType; +import io.milvus.grpc.MutationResult; +import io.milvus.grpc.QueryResults; +import io.milvus.grpc.SearchResults; import io.milvus.param.*; import io.milvus.param.collection.*; -import io.milvus.param.dml.*; -import io.milvus.param.index.*; -import io.milvus.response.*; +import io.milvus.param.dml.InsertParam; +import io.milvus.param.dml.QueryParam; +import io.milvus.param.dml.SearchParam; +import io.milvus.param.index.CreateIndexParam; +import io.milvus.response.FieldDataWrapper; +import io.milvus.response.QueryResultsWrapper; +import io.milvus.response.SearchResultsWrapper; import org.tensorflow.types.TBfloat16; import org.tensorflow.types.TFloat16; @@ -42,6 +49,7 @@ public class Float16VectorExample { private static final Integer VECTOR_DIM = 128; private static final MilvusServiceClient milvusClient; + static { // Connect to Milvus server. Replace the "localhost" and port with your Milvus server address. milvusClient = new MilvusServiceClient(ConnectParam.newBuilder() @@ -179,7 +187,7 @@ private static void testFloat16(boolean bfloat16) { // Ensure the returned top1 item's ID should be equal to target vector's ID for (int i = 0; i < 10; i++) { Random ran = new Random(); - int k = ran.nextInt(batchRowCount*2); + int k = ran.nextInt(batchRowCount * 2); ByteBuffer targetVector = encodedVectors.get(k); SearchParam.Builder builder = SearchParam.newBuilder() .withCollectionName(COLLECTION_NAME) @@ -208,7 +216,7 @@ private static void testFloat16(boolean bfloat16) { firstScore.getLongID(), k)); } - ByteBuffer outputBuf = (ByteBuffer)firstScore.get(VECTOR_FIELD); + ByteBuffer outputBuf = (ByteBuffer) firstScore.get(VECTOR_FIELD); if (!outputBuf.equals(targetVector)) { throw new RuntimeException(String.format("The output vector is not equal to target vector: ID %d", k)); } @@ -229,7 +237,7 @@ private static void testFloat16(boolean bfloat16) { // Retrieve some data and verify the output for (int i = 0; i < 10; i++) { Random ran = new Random(); - int k = ran.nextInt(batchRowCount*2); + int k = ran.nextInt(batchRowCount * 2); R queryR = milvusClient.query(QueryParam.newBuilder() .withCollectionName(COLLECTION_NAME) .withExpr(String.format("id == %d", k)) diff --git a/examples/src/main/java/io/milvus/v1/GeneralExample.java b/examples/src/main/java/io/milvus/v1/GeneralExample.java index ee24f7514..b0aeb90a0 100644 --- a/examples/src/main/java/io/milvus/v1/GeneralExample.java +++ b/examples/src/main/java/io/milvus/v1/GeneralExample.java @@ -46,7 +46,7 @@ public class GeneralExample { ConnectParam connectParam = ConnectParam.newBuilder() .withHost("localhost") .withPort(19530) - .withAuthorization("root","Milvus") + .withAuthorization("root", "Milvus") .build(); RetryParam retryParam = RetryParam.newBuilder() .withMaxRetryTimes(3) diff --git a/examples/src/main/java/io/milvus/v1/HighLevelExample.java b/examples/src/main/java/io/milvus/v1/HighLevelExample.java index 279b390be..d47ecf40b 100644 --- a/examples/src/main/java/io/milvus/v1/HighLevelExample.java +++ b/examples/src/main/java/io/milvus/v1/HighLevelExample.java @@ -18,21 +18,26 @@ */ package io.milvus.v1; +import com.google.common.collect.Lists; import com.google.gson.Gson; import com.google.gson.JsonObject; -import com.google.common.collect.Lists; import io.milvus.client.MilvusServiceClient; import io.milvus.common.clientenum.ConsistencyLevelEnum; import io.milvus.common.utils.VectorUtils; -import io.milvus.grpc.*; -import io.milvus.param.*; -import io.milvus.param.collection.*; -import io.milvus.param.highlevel.collection.response.ListCollectionsResponse; +import io.milvus.grpc.DescribeCollectionResponse; +import io.milvus.param.ConnectParam; +import io.milvus.param.IndexType; +import io.milvus.param.R; +import io.milvus.param.RpcStatus; +import io.milvus.param.collection.DescribeCollectionParam; +import io.milvus.param.collection.FlushParam; import io.milvus.param.highlevel.collection.CreateSimpleCollectionParam; import io.milvus.param.highlevel.collection.ListCollectionsParam; +import io.milvus.param.highlevel.collection.response.ListCollectionsResponse; import io.milvus.param.highlevel.dml.*; import io.milvus.param.highlevel.dml.response.*; -import io.milvus.response.*; +import io.milvus.response.DescCollResponseWrapper; +import io.milvus.response.QueryResultsWrapper; import java.util.ArrayList; import java.util.List; @@ -46,7 +51,7 @@ public class HighLevelExample { ConnectParam connectParam = ConnectParam.newBuilder() .withHost("localhost") .withPort(19530) - .withAuthorization("root","Milvus") + .withAuthorization("root", "Milvus") .build(); milvusClient = new MilvusServiceClient(connectParam); } @@ -68,7 +73,7 @@ public class HighLevelExample { private static final String BOOL_FIELD_NAME = "bool"; private static final String FLOAT_FIELD_NAME = "float"; private static final String DOUBLE_FIELD_NAME = "double"; - + private R describeCollection() { System.out.println("========== describeCollection() =========="); diff --git a/examples/src/main/java/io/milvus/v1/HybridSearchExample.java b/examples/src/main/java/io/milvus/v1/HybridSearchExample.java index 1b9444184..7640ec2f0 100644 --- a/examples/src/main/java/io/milvus/v1/HybridSearchExample.java +++ b/examples/src/main/java/io/milvus/v1/HybridSearchExample.java @@ -29,8 +29,10 @@ import io.milvus.grpc.SearchResults; import io.milvus.param.*; import io.milvus.param.collection.*; -import io.milvus.param.dml.*; -import io.milvus.param.dml.ranker.*; +import io.milvus.param.dml.AnnSearchParam; +import io.milvus.param.dml.HybridSearchParam; +import io.milvus.param.dml.InsertParam; +import io.milvus.param.dml.ranker.RRFRanker; import io.milvus.param.index.CreateIndexParam; import io.milvus.response.GetCollStatResponseWrapper; import io.milvus.response.SearchResultsWrapper; diff --git a/examples/src/main/java/io/milvus/v1/IteratorExample.java b/examples/src/main/java/io/milvus/v1/IteratorExample.java index 3615dd2e7..59ce3719c 100644 --- a/examples/src/main/java/io/milvus/v1/IteratorExample.java +++ b/examples/src/main/java/io/milvus/v1/IteratorExample.java @@ -24,22 +24,16 @@ import io.milvus.client.MilvusServiceClient; import io.milvus.common.clientenum.ConsistencyLevelEnum; import io.milvus.grpc.DataType; -import io.milvus.grpc.FlushResponse; import io.milvus.grpc.GetCollectionStatisticsResponse; import io.milvus.grpc.MutationResult; -import io.milvus.param.ConnectParam; -import io.milvus.param.IndexType; -import io.milvus.param.MetricType; -import io.milvus.param.R; -import io.milvus.param.RetryParam; -import io.milvus.param.RpcStatus; +import io.milvus.orm.iterator.QueryIterator; +import io.milvus.orm.iterator.SearchIterator; +import io.milvus.param.*; import io.milvus.param.collection.*; import io.milvus.param.dml.InsertParam; import io.milvus.param.dml.QueryIteratorParam; import io.milvus.param.dml.SearchIteratorParam; import io.milvus.param.index.CreateIndexParam; -import io.milvus.orm.iterator.QueryIterator; -import io.milvus.orm.iterator.SearchIterator; import io.milvus.response.GetCollStatResponseWrapper; import io.milvus.response.QueryResultsWrapper; diff --git a/examples/src/main/java/io/milvus/v1/JsonFieldExample.java b/examples/src/main/java/io/milvus/v1/JsonFieldExample.java index 0c7887979..7ceedb7ce 100644 --- a/examples/src/main/java/io/milvus/v1/JsonFieldExample.java +++ b/examples/src/main/java/io/milvus/v1/JsonFieldExample.java @@ -142,7 +142,7 @@ public static void main(String[] args) { JsonObject metadata = new JsonObject(); metadata.addProperty("path", String.format("\\root/abc/path_%d", i)); metadata.addProperty("size", i); - if (i%7 == 0) { + if (i % 7 == 0) { metadata.addProperty("special", true); } @@ -152,8 +152,8 @@ public static void main(String[] args) { // System.out.println(metadata); // dynamic fields - if (i%2 == 0) { - row.addProperty("dynamic1", (double)i/3); + if (i % 2 == 0) { + row.addProperty("dynamic1", (double) i / 3); } else { row.addProperty("dynamic2", "ok"); } @@ -172,7 +172,7 @@ public static void main(String[] args) { .withConsistencyLevel(ConsistencyLevelEnum.STRONG) .build()); QueryResultsWrapper queryWrapper = new QueryResultsWrapper(queryRet.getData()); - long rowCount = (long)queryWrapper.getFieldWrapper("count(*)").getFieldData().get(0); + long rowCount = (long) queryWrapper.getFieldWrapper("count(*)").getFieldData().get(0); System.out.printf("%d rows persisted\n", rowCount); // search and output JSON field @@ -221,7 +221,7 @@ public static void main(String[] args) { for (QueryResultsWrapper.RowRecord record : records) { System.out.println(record); } - long pk = (long)records.get(0).get(ID_FIELD); + long pk = (long) records.get(0).get(ID_FIELD); if (pk != i) { throw new RuntimeException(String.format("The top1 ID %d is not equal to target vector's ID %d", pk, i)); } diff --git a/examples/src/main/java/io/milvus/v1/NullAndDefaultExample.java b/examples/src/main/java/io/milvus/v1/NullAndDefaultExample.java index fd845ddf5..1a8569ee0 100644 --- a/examples/src/main/java/io/milvus/v1/NullAndDefaultExample.java +++ b/examples/src/main/java/io/milvus/v1/NullAndDefaultExample.java @@ -164,7 +164,7 @@ public static void main(String[] args) { } // some values are default value - if (i%3==0) { + if (i % 3 == 0) { row.addProperty("default_test", 1.0); } @@ -197,7 +197,7 @@ public static void main(String[] args) { .withConsistencyLevel(ConsistencyLevelEnum.STRONG) .build()); QueryResultsWrapper wrapper = new QueryResultsWrapper(queryRet.getData()); - long rowCount = (long)wrapper.getFieldWrapper("count(*)").getFieldData().get(0); + long rowCount = (long) wrapper.getFieldWrapper("count(*)").getFieldData().get(0); System.out.printf("%d rows in collection\n", rowCount); // Query by filtering expression diff --git a/examples/src/main/java/io/milvus/v1/RBACExample.java b/examples/src/main/java/io/milvus/v1/RBACExample.java index 4ecf5430a..606e06a01 100644 --- a/examples/src/main/java/io/milvus/v1/RBACExample.java +++ b/examples/src/main/java/io/milvus/v1/RBACExample.java @@ -37,7 +37,7 @@ public class RBACExample { ConnectParam connectParam = ConnectParam.newBuilder() .withHost("localhost") .withPort(19530) - .withAuthorization("root","Milvus") + .withAuthorization("root", "Milvus") .build(); milvusClient = new MilvusServiceClient(connectParam); } @@ -118,7 +118,7 @@ public static void main(String[] args) { // grant privilege to role. // grant object is all collections, grant object type is Collection, and the privilege is CreateCollection - resp = grantRolePrivilege("role1","Global","*", "CreateCollection"); + resp = grantRolePrivilege("role1", "Global", "*", "CreateCollection"); Validate.isTrue(resp.getStatus() == R.success().getStatus(), "bind privileges to role fail!"); System.out.println("grant privilege to role1"); @@ -128,7 +128,7 @@ public static void main(String[] args) { System.out.println("bind role1 to user"); // revoke privilege from role - resp = revokeRolePrivilege("role1","Global","*", "CreateCollection"); + resp = revokeRolePrivilege("role1", "Global", "*", "CreateCollection"); Validate.isTrue(resp.getStatus() == R.success().getStatus(), "revoke privileges to role fail!"); System.out.println("revoke privilege from role1"); diff --git a/examples/src/main/java/io/milvus/v1/ResourceGroupExample.java b/examples/src/main/java/io/milvus/v1/ResourceGroupExample.java index 3b0ae16d6..744558f1f 100644 --- a/examples/src/main/java/io/milvus/v1/ResourceGroupExample.java +++ b/examples/src/main/java/io/milvus/v1/ResourceGroupExample.java @@ -20,10 +20,9 @@ package io.milvus.v1; import com.google.gson.Gson; - import io.milvus.client.MilvusServiceClient; -import io.milvus.v1.resourcegroup.ResourceGroupManagement; import io.milvus.param.ConnectParam; +import io.milvus.v1.resourcegroup.ResourceGroupManagement; public class ResourceGroupExample { private static final ResourceGroupManagement manager; diff --git a/examples/src/main/java/io/milvus/v1/SimpleExample.java b/examples/src/main/java/io/milvus/v1/SimpleExample.java index f6d0717b2..850d8d81e 100644 --- a/examples/src/main/java/io/milvus/v1/SimpleExample.java +++ b/examples/src/main/java/io/milvus/v1/SimpleExample.java @@ -22,15 +22,26 @@ import com.google.gson.JsonObject; import io.milvus.client.MilvusServiceClient; import io.milvus.common.clientenum.ConsistencyLevelEnum; -import io.milvus.grpc.*; +import io.milvus.grpc.DataType; +import io.milvus.grpc.MutationResult; +import io.milvus.grpc.QueryResults; +import io.milvus.grpc.SearchResults; import io.milvus.param.*; -import io.milvus.param.collection.*; -import io.milvus.param.dml.*; -import io.milvus.param.index.*; -import io.milvus.response.*; -import io.milvus.v2.service.vector.response.QueryResp; - -import java.util.*; +import io.milvus.param.collection.CreateCollectionParam; +import io.milvus.param.collection.DropCollectionParam; +import io.milvus.param.collection.FieldType; +import io.milvus.param.collection.LoadCollectionParam; +import io.milvus.param.dml.InsertParam; +import io.milvus.param.dml.QueryParam; +import io.milvus.param.dml.SearchParam; +import io.milvus.param.index.CreateIndexParam; +import io.milvus.response.QueryResultsWrapper; +import io.milvus.response.SearchResultsWrapper; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; public class SimpleExample { @@ -113,7 +124,7 @@ public static void main(String[] args) { for (long i = 1L; i <= 10; ++i) { JsonObject row = new JsonObject(); row.addProperty(ID_FIELD, i); - List vector = Arrays.asList((float)i, (float)i, (float)i, (float)i); + List vector = Arrays.asList((float) i, (float) i, (float) i, (float) i); row.add(VECTOR_FIELD, gson.toJsonTree(vector)); row.addProperty(TITLE_FIELD, "Tom and Jerry " + i); rows.add(row); @@ -135,7 +146,7 @@ public static void main(String[] args) { .withConsistencyLevel(ConsistencyLevelEnum.STRONG) .build()); QueryResultsWrapper wrapper = new QueryResultsWrapper(queryRet.getData()); - long rowCount = (long)wrapper.getFieldWrapper("count(*)").getFieldData().get(0); + long rowCount = (long) wrapper.getFieldWrapper("count(*)").getFieldData().get(0); System.out.printf("%d rows persisted\n", rowCount); // Construct a vector to search top5 similar records, return the book title for us. @@ -160,11 +171,11 @@ public static void main(String[] args) { SearchResultsWrapper resultsWrapper = new SearchResultsWrapper(searchRet.getData().getResults()); List scores = resultsWrapper.getIDScore(0); System.out.println("The result of No.0 target vector:"); - for (SearchResultsWrapper.IDScore score:scores) { - List vectorReturned = (List)score.get(VECTOR_FIELD); + for (SearchResultsWrapper.IDScore score : scores) { + List vectorReturned = (List) score.get(VECTOR_FIELD); System.out.println(vectorReturned); - String title = (String)score.get(TITLE_FIELD); + String title = (String) score.get(TITLE_FIELD); System.out.println(title); } diff --git a/examples/src/main/java/io/milvus/v1/UpsertExample.java b/examples/src/main/java/io/milvus/v1/UpsertExample.java index 4eb33d234..99399474a 100644 --- a/examples/src/main/java/io/milvus/v1/UpsertExample.java +++ b/examples/src/main/java/io/milvus/v1/UpsertExample.java @@ -50,6 +50,7 @@ public class UpsertExample { .build(); client = new MilvusServiceClient(connectParam); } + private static final String COLLECTION_NAME = "java_sdk_example_upsert_v1"; private static final String ID_FIELD = "pk"; private static final String VECTOR_FIELD = "vector"; diff --git a/examples/src/main/java/io/milvus/v1/resourcegroup/NodeInfo.java b/examples/src/main/java/io/milvus/v1/resourcegroup/NodeInfo.java index e09415795..35aa87b88 100644 --- a/examples/src/main/java/io/milvus/v1/resourcegroup/NodeInfo.java +++ b/examples/src/main/java/io/milvus/v1/resourcegroup/NodeInfo.java @@ -19,14 +19,10 @@ package io.milvus.v1.resourcegroup; -import lombok.Getter; -import lombok.NonNull; - -@Getter public class NodeInfo { - private long nodeId; - private String address; - private String hostname; + private final long nodeId; + private final String address; + private final String hostname; private NodeInfo(Builder builder) { this.nodeId = builder.nodeId; @@ -34,6 +30,18 @@ private NodeInfo(Builder builder) { this.hostname = builder.hostname; } + public long getNodeId() { + return nodeId; + } + + public String getAddress() { + return address; + } + + public String getHostname() { + return hostname; + } + public static Builder newBuilder() { return new Builder(); } @@ -48,12 +56,12 @@ public Builder withNodeId(long nodeId) { return this; } - public Builder withAddress(@NonNull String address) { + public Builder withAddress(String address) { this.address = address; return this; } - public Builder withHostname(@NonNull String hostname) { + public Builder withHostname(String hostname) { this.hostname = hostname; return this; } diff --git a/examples/src/main/java/io/milvus/v1/resourcegroup/ResourceGroupInfo.java b/examples/src/main/java/io/milvus/v1/resourcegroup/ResourceGroupInfo.java index 10a7f2987..937ce60a8 100644 --- a/examples/src/main/java/io/milvus/v1/resourcegroup/ResourceGroupInfo.java +++ b/examples/src/main/java/io/milvus/v1/resourcegroup/ResourceGroupInfo.java @@ -19,23 +19,20 @@ package io.milvus.v1.resourcegroup; +import io.milvus.common.resourcegroup.ResourceGroupConfig; + import java.util.HashSet; import java.util.Set; -import io.milvus.common.resourcegroup.ResourceGroupConfig; -import lombok.Getter; -import lombok.NonNull; - -@Getter public class ResourceGroupInfo { private String resourceGroupName; private ResourceGroupConfig resourceGroupConfig; private Set fullDatabases; // databases belong to this resource group completely. private Set partialDatabases; // databases belong to this resource group partially, some collection is in - // other resource group. + // other resource group. private Set nodes; // actual query node in this resource group. - private ResourceGroupInfo(@NonNull Builder builder) { + private ResourceGroupInfo(Builder builder) { this.resourceGroupName = builder.resourceGroupName; this.resourceGroupConfig = builder.resourceGroupConfig; this.fullDatabases = builder.fullDatabases; @@ -52,6 +49,26 @@ private ResourceGroupInfo(@NonNull Builder builder) { } } + public String getResourceGroupName() { + return resourceGroupName; + } + + public ResourceGroupConfig getResourceGroupConfig() { + return resourceGroupConfig; + } + + public Set getFullDatabases() { + return fullDatabases; + } + + public Set getPartialDatabases() { + return partialDatabases; + } + + public Set getNodes() { + return nodes; + } + public static Builder newBuilder() { return new Builder(); } @@ -63,12 +80,12 @@ public static final class Builder { private Set partialDatabases; private Set nodes; // actual query node in this resource group. - public Builder withResourceGroupName(@NonNull String resourceGroupName) { + public Builder withResourceGroupName(String resourceGroupName) { this.resourceGroupName = resourceGroupName; return this; } - public Builder addFullDatabases(@NonNull String databaseName) { + public Builder addFullDatabases(String databaseName) { if (this.fullDatabases == null) { this.fullDatabases = new HashSet(); } @@ -76,7 +93,7 @@ public Builder addFullDatabases(@NonNull String databaseName) { return this; } - public Builder addPartialDatabases(@NonNull String databaseName) { + public Builder addPartialDatabases(String databaseName) { if (this.partialDatabases == null) { this.partialDatabases = new HashSet(); } @@ -84,7 +101,7 @@ public Builder addPartialDatabases(@NonNull String databaseName) { return this; } - public Builder addAvailableNode(@NonNull NodeInfo node) { + public Builder addAvailableNode(NodeInfo node) { if (this.nodes == null) { this.nodes = new HashSet(); } @@ -92,7 +109,7 @@ public Builder addAvailableNode(@NonNull NodeInfo node) { return this; } - public Builder withConfig(@NonNull ResourceGroupConfig resourceGroupConfig) { + public Builder withConfig(ResourceGroupConfig resourceGroupConfig) { this.resourceGroupConfig = resourceGroupConfig; return this; } @@ -104,7 +121,7 @@ public ResourceGroupInfo build() { /** * Check if this resource group is the default resource group. - * + * * @return true if this resource group is the default resource group. */ public boolean isDefaultResourceGroup() { @@ -113,7 +130,7 @@ public boolean isDefaultResourceGroup() { /** * Check if this resource group is the recycle resource group. - * + * * @return true if this resource group is the recycle resource group. */ public boolean isRecycleResourceGroup() { diff --git a/examples/src/main/java/io/milvus/v1/resourcegroup/ResourceGroupManagement.java b/examples/src/main/java/io/milvus/v1/resourcegroup/ResourceGroupManagement.java index 7c7a3f0fe..7d8ba1508 100644 --- a/examples/src/main/java/io/milvus/v1/resourcegroup/ResourceGroupManagement.java +++ b/examples/src/main/java/io/milvus/v1/resourcegroup/ResourceGroupManagement.java @@ -19,36 +19,21 @@ package io.milvus.v1.resourcegroup; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - import io.milvus.client.MilvusClient; +import io.milvus.common.resourcegroup.ResourceGroupConfig; +import io.milvus.common.resourcegroup.ResourceGroupLimit; +import io.milvus.common.resourcegroup.ResourceGroupTransfer; +import io.milvus.exception.MilvusException; +import io.milvus.grpc.*; import io.milvus.param.R; import io.milvus.param.RpcStatus; import io.milvus.param.collection.GetLoadStateParam; import io.milvus.param.collection.ShowCollectionsParam; import io.milvus.param.control.GetReplicasParam; -import io.milvus.param.resourcegroup.CreateResourceGroupParam; -import io.milvus.param.resourcegroup.DescribeResourceGroupParam; -import io.milvus.param.resourcegroup.DropResourceGroupParam; -import io.milvus.param.resourcegroup.ListResourceGroupsParam; -import io.milvus.param.resourcegroup.TransferReplicaParam; -import io.milvus.param.resourcegroup.UpdateResourceGroupsParam; -import io.milvus.common.resourcegroup.ResourceGroupConfig; -import io.milvus.common.resourcegroup.ResourceGroupLimit; -import io.milvus.common.resourcegroup.ResourceGroupTransfer; -import io.milvus.exception.MilvusException; -import io.milvus.grpc.DescribeResourceGroupResponse; -import io.milvus.grpc.GetLoadStateResponse; -import io.milvus.grpc.GetReplicasResponse; -import io.milvus.grpc.ListDatabasesResponse; -import io.milvus.grpc.ListResourceGroupsResponse; -import io.milvus.grpc.LoadState; -import io.milvus.grpc.ShowCollectionsResponse; +import io.milvus.param.resourcegroup.*; + +import java.util.*; +import java.util.stream.Collectors; public class ResourceGroupManagement { @@ -65,7 +50,7 @@ public ResourceGroupManagement(MilvusClient client) { /** * list all resource groups. - * + * * @return map of resource group name and resource group info. */ public Map listResourceGroups() throws Exception { @@ -134,7 +119,7 @@ public Map listResourceGroups() throws Exception { /** * Initialize the cluster with a recycle resource group. - * + * * @param defaultResourceGroupNodeNum The number of query nodes to initialize * the default resource group. */ @@ -173,7 +158,7 @@ public void createResourceGroup(String resourceGroupName, Integer requestNodeNum /** * Drop a resource group, before drop resource group, you should scale the * resource group to 0 first. - * + * * @param resourceGroupName */ public void dropResourceGroup(String resourceGroupName) throws Exception { @@ -184,7 +169,7 @@ public void dropResourceGroup(String resourceGroupName) throws Exception { /** * Scale to the number of nodes in a resource group. - * + * * @param resourceGroupName * @param requestNodeNum */ @@ -209,7 +194,7 @@ public void scaleResourceGroupTo(String resourceGroupName, Integer requestNodeNu /** * Transfer a database to specified resource group. * Only support single replica now. - * + * * @param dbName The name of the database to transfer. * @param resourceGroupName The name of the target resource group. */ @@ -238,7 +223,7 @@ public void transferDataBaseToResourceGroup(String dbName, String resourceGroupN /** * get the resource group name of the collection. - * + * * @param dbName * @param collection * @return @@ -278,7 +263,7 @@ private String getCollectionResourceGroupName(String dbName, String collection) } /** - * + * * @param * @param response * @return diff --git a/examples/src/main/java/io/milvus/v2/AddFieldExample.java b/examples/src/main/java/io/milvus/v2/AddFieldExample.java index 636c813c6..e23be0da9 100644 --- a/examples/src/main/java/io/milvus/v2/AddFieldExample.java +++ b/examples/src/main/java/io/milvus/v2/AddFieldExample.java @@ -35,7 +35,9 @@ import io.milvus.v2.service.vector.request.QueryReq; import io.milvus.v2.service.vector.response.QueryResp; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public class AddFieldExample { private static final MilvusClientV2 client; @@ -46,6 +48,7 @@ public class AddFieldExample { .build(); client = new MilvusClientV2(config); } + private static final String COLLECTION_NAME = "java_sdk_example_add_field_v2"; private static final String ID_FIELD = "id"; private static final String VECTOR_FIELD = "vector"; diff --git a/examples/src/main/java/io/milvus/v2/ArrayFieldExample.java b/examples/src/main/java/io/milvus/v2/ArrayFieldExample.java index a8ea79eaf..e9164755a 100644 --- a/examples/src/main/java/io/milvus/v2/ArrayFieldExample.java +++ b/examples/src/main/java/io/milvus/v2/ArrayFieldExample.java @@ -126,7 +126,7 @@ public static void main(String[] args) { List strArray = new ArrayList<>(); int capacity = random.nextInt(5) + 5; for (int k = 0; k < capacity; k++) { - intArray.add((i+k)%100); + intArray.add((i + k) % 100); strArray.add(String.format("string-%d-%d", i, k)); } row.add("array_int32", JsonUtils.toJsonTree(intArray).getAsJsonArray()); @@ -145,7 +145,7 @@ public static void main(String[] args) { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - System.out.printf("%d rows in collection\n", (long)countR.getQueryResults().get(0).getEntity().get("count(*)")); + System.out.printf("%d rows in collection\n", (long) countR.getQueryResults().get(0).getEntity().get("count(*)")); // Query by filtering expression queryWithExpr(client, "array_int32[0] == 99"); diff --git a/examples/src/main/java/io/milvus/v2/BinaryVectorExample.java b/examples/src/main/java/io/milvus/v2/BinaryVectorExample.java index a43003b9a..782c74277 100644 --- a/examples/src/main/java/io/milvus/v2/BinaryVectorExample.java +++ b/examples/src/main/java/io/milvus/v2/BinaryVectorExample.java @@ -74,8 +74,8 @@ public static void main(String[] args) { .build()); List indexes = new ArrayList<>(); - Map extraParams = new HashMap<>(); - extraParams.put("nlist",64); + Map extraParams = new HashMap<>(); + extraParams.put("nlist", 64); indexes.add(IndexParam.builder() .fieldName(VECTOR_FIELD) .indexType(IndexParam.IndexType.BIN_IVF_FLAT) @@ -117,7 +117,7 @@ public static void main(String[] args) { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - System.out.printf("%d rows persisted\n", (long)countR.getQueryResults().get(0).getEntity().get("count(*)")); + System.out.printf("%d rows persisted\n", (long) countR.getQueryResults().get(0).getEntity().get("count(*)")); // Pick some vectors from the inserted vectors to search // Ensure the returned top1 item's ID should be equal to target vector's ID @@ -127,8 +127,8 @@ public static void main(String[] args) { ByteBuffer targetVector = vectors.get(k); System.out.printf("\nANN search for vector ID=%d:\n", k); CommonUtils.printBinaryVector(targetVector); - Map params = new HashMap<>(); - params.put("nprobe",16); + Map params = new HashMap<>(); + params.put("nprobe", 16); SearchResp searchResp = client.search(SearchReq.builder() .collectionName(COLLECTION_NAME) .data(Collections.singletonList(new BinaryVec(targetVector))) @@ -150,7 +150,7 @@ public static void main(String[] args) { } SearchResp.SearchResult firstResult = results.get(0); - if ((long)firstResult.getId() != k) { + if ((long) firstResult.getId() != k) { throw new RuntimeException(String.format("The top1 ID %d is not equal to target vector's ID %d", firstResult.getId(), k)); } diff --git a/examples/src/main/java/io/milvus/v2/CDCExample.java b/examples/src/main/java/io/milvus/v2/CDCExample.java index 9222297dc..fd2e53cb2 100644 --- a/examples/src/main/java/io/milvus/v2/CDCExample.java +++ b/examples/src/main/java/io/milvus/v2/CDCExample.java @@ -74,8 +74,13 @@ public static void main(String[] args) { .build(); ReplicateConfiguration configuration = ReplicateConfiguration.builder() - .clusters(new ArrayList(){{ add(milvusClusterA); add(milvusClusterB); }}) - .crossClusterTopologies(new ArrayList(){{ add(topology); }} ) + .clusters(new ArrayList() {{ + add(milvusClusterA); + add(milvusClusterB); + }}) + .crossClusterTopologies(new ArrayList() {{ + add(topology); + }}) .build(); UpdateReplicateConfigurationReq updateReq = UpdateReplicateConfigurationReq.builder() diff --git a/examples/src/main/java/io/milvus/v2/ClientPoolExample.java b/examples/src/main/java/io/milvus/v2/ClientPoolExample.java index b4b90cea0..35f99dcdf 100644 --- a/examples/src/main/java/io/milvus/v2/ClientPoolExample.java +++ b/examples/src/main/java/io/milvus/v2/ClientPoolExample.java @@ -57,6 +57,7 @@ private static void printKeyClientNumber(MilvusClientV2Pool pool, String key) { System.out.printf("Key '%s': %d idle clients and %d active clients%n", key, pool.getIdleClientNumber(key), pool.getActiveClientNumber(key)); } + private static void printClientNumber(MilvusClientV2Pool pool) { System.out.println("======================================================================"); System.out.printf("Total %d idle clients and %d active clients%n", @@ -137,7 +138,7 @@ public static Thread runInsertThread(MilvusClientV2Pool pool, String dbName, int Gson gson = new Gson(); for (int i = 0; i < repeatRequests; i++) { MilvusClientV2 client = null; - while(client == null) { + while (client == null) { try { // getClient() might exceeds the borrowMaxWaitMillis and throw exception // retry to call until it return a client @@ -176,7 +177,7 @@ public static Thread runSearchThread(MilvusClientV2Pool pool, String dbName, int Thread t = new Thread(() -> { for (int i = 0; i < repeatRequests; i++) { MilvusClientV2 client = null; - while(client == null) { + while (client == null) { try { // getClient() might exceeds the borrowMaxWaitMillis and throw exception // retry to call until it return a client @@ -222,7 +223,7 @@ public static void verifyRowCount(MilvusClientV2Pool pool, long expectedCount) { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - long rowCount = (long)countR.getQueryResults().get(0).getEntity().get("count(*)"); + long rowCount = (long) countR.getQueryResults().get(0).getEntity().get("count(*)"); System.out.printf("%d rows persisted in collection '%s' of database '%s'%n", rowCount, CollectionName, dbName); if (rowCount != expectedCount) { @@ -331,7 +332,7 @@ public static void main(String[] args) throws InterruptedException { printClientNumber(pool); // check row count of each collection, there are threadCount*repeatRequests rows were inserted by multiple threads - verifyRowCount(pool, threadCount*repeatRequests); + verifyRowCount(pool, threadCount * repeatRequests); // drop collections dropCollections(pool); // drop databases, only after database is empty, it is able to be dropped @@ -339,7 +340,7 @@ public static void main(String[] args) throws InterruptedException { long end = System.currentTimeMillis(); System.out.printf("%d insert requests and %d search requests finished in %.3f seconds%n", - threadCount*repeatRequests*3, threadCount*repeatRequests*3, (end-start)*0.001); + threadCount * repeatRequests * 3, threadCount * repeatRequests * 3, (end - start) * 0.001); printClientNumber(pool); pool.clear(); // clear idle clients diff --git a/examples/src/main/java/io/milvus/v2/ConsistencyLevelExample.java b/examples/src/main/java/io/milvus/v2/ConsistencyLevelExample.java index d57cf81bd..056953847 100644 --- a/examples/src/main/java/io/milvus/v2/ConsistencyLevelExample.java +++ b/examples/src/main/java/io/milvus/v2/ConsistencyLevelExample.java @@ -146,7 +146,7 @@ private static void testSessionLevel() throws Exception { row.add("vector", gson.toJsonTree(vector)); // insert by a MilvusClient - String clientName1 = String.format("client_%d", i%10); + String clientName1 = String.format("client_%d", i % 10); MilvusClientV2 client1 = pool.getClient(clientName1); client1.insert(InsertReq.builder() .collectionName(collectionName) @@ -157,7 +157,7 @@ private static void testSessionLevel() throws Exception { // search by another MilvusClient, use the just inserted vector to search // the returned item is expected to be the just inserted item - String clientName2 = String.format("client_%d", i%10+1); + String clientName2 = String.format("client_%d", i % 10 + 1); MilvusClientV2 client2 = pool.getClient(clientName2); SearchResp searchR = client2.search(SearchReq.builder() .collectionName(collectionName) @@ -170,7 +170,7 @@ private static void testSessionLevel() throws Exception { if (results.size() != 1) { throw new RuntimeException("Search result is empty"); } - if (i != (Long)results.get(0).getId()) { + if (i != (Long) results.get(0).getId()) { throw new RuntimeException("The just inserted entity is not found"); } System.out.println("search"); diff --git a/examples/src/main/java/io/milvus/v2/Float16VectorExample.java b/examples/src/main/java/io/milvus/v2/Float16VectorExample.java index 6281e5305..4368c4ae0 100644 --- a/examples/src/main/java/io/milvus/v2/Float16VectorExample.java +++ b/examples/src/main/java/io/milvus/v2/Float16VectorExample.java @@ -52,6 +52,7 @@ public class Float16VectorExample { private static final Integer VECTOR_DIM = 128; private static final MilvusClientV2 client; + static { client = new MilvusClientV2(ConnectConfig.builder() .uri("http://localhost:19530") @@ -162,7 +163,7 @@ private static void searchVectors(List taargetIDs, List target } Map entity = topResult.getEntity(); ByteBuffer vectorBuf = (ByteBuffer) entity.get(vectorFieldName); - ByteBuffer targetVectorBuf = (ByteBuffer)targetVectors.get(i).getData(); + ByteBuffer targetVectorBuf = (ByteBuffer) targetVectors.get(i).getData(); if (!vectorBuf.equals(targetVectorBuf)) { throw new RuntimeException("The top1 output vector is incorrect"); } diff --git a/examples/src/main/java/io/milvus/v2/FullTextSearchExample.java b/examples/src/main/java/io/milvus/v2/FullTextSearchExample.java index 03d43db75..b92e8f4e4 100644 --- a/examples/src/main/java/io/milvus/v2/FullTextSearchExample.java +++ b/examples/src/main/java/io/milvus/v2/FullTextSearchExample.java @@ -29,8 +29,8 @@ import io.milvus.v2.common.IndexParam; import io.milvus.v2.service.collection.request.AddFieldReq; import io.milvus.v2.service.collection.request.CreateCollectionReq; -import io.milvus.v2.service.collection.request.DropCollectionReq; import io.milvus.v2.service.collection.request.CreateCollectionReq.Function; +import io.milvus.v2.service.collection.request.DropCollectionReq; import io.milvus.v2.service.vector.request.InsertReq; import io.milvus.v2.service.vector.request.QueryReq; import io.milvus.v2.service.vector.request.SearchReq; @@ -38,7 +38,10 @@ import io.milvus.v2.service.vector.response.QueryResp; import io.milvus.v2.service.vector.response.SearchResp; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; public class FullTextSearchExample { private static final String COLLECTION_NAME = "java_sdk_example_text_match_v2"; @@ -146,7 +149,7 @@ public static void main(String[] args) { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - System.out.printf("%d rows in collection\n", (long)countR.getQueryResults().get(0).getEntity().get("count(*)")); + System.out.printf("%d rows in collection\n", (long) countR.getQueryResults().get(0).getEntity().get("count(*)")); // Query by filtering expression searchByText(client, "moon and earth distance"); diff --git a/examples/src/main/java/io/milvus/v2/GeneralExample.java b/examples/src/main/java/io/milvus/v2/GeneralExample.java index e20d4af02..458729725 100644 --- a/examples/src/main/java/io/milvus/v2/GeneralExample.java +++ b/examples/src/main/java/io/milvus/v2/GeneralExample.java @@ -27,12 +27,7 @@ import io.milvus.v2.common.ConsistencyLevel; import io.milvus.v2.common.DataType; import io.milvus.v2.common.IndexParam; -import io.milvus.v2.service.collection.request.AddFieldReq; -import io.milvus.v2.service.collection.request.CreateCollectionReq; -import io.milvus.v2.service.collection.request.DescribeCollectionReq; -import io.milvus.v2.service.collection.request.DropCollectionReq; -import io.milvus.v2.service.collection.request.LoadCollectionReq; -import io.milvus.v2.service.collection.request.ReleaseCollectionReq; +import io.milvus.v2.service.collection.request.*; import io.milvus.v2.service.collection.response.DescribeCollectionResp; import io.milvus.v2.service.collection.response.ListCollectionsResp; import io.milvus.v2.service.partition.request.CreatePartitionReq; @@ -44,15 +39,11 @@ import io.milvus.v2.service.vector.response.InsertResp; import io.milvus.v2.service.vector.response.SearchResp; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; +import java.util.*; public class GeneralExample { private static final MilvusClientV2 client; + static { client = new MilvusClientV2(ConnectConfig.builder() .uri("http://localhost:19530") @@ -96,8 +87,8 @@ private static void createCollection() { .build()); List indexes = new ArrayList<>(); - Map extraParams = new HashMap<>(); - extraParams.put("nlist",128); + Map extraParams = new HashMap<>(); + extraParams.put("nlist", 128); indexes.add(IndexParam.builder() .fieldName(VECTOR_FIELD) .indexName(INDEX_NAME) @@ -193,8 +184,8 @@ private static void searchFace(String filter) { } long begin = System.currentTimeMillis(); - Map params = new HashMap<>(); - params.put("nprobe",10); + Map params = new HashMap<>(); + params.put("nprobe", 10); SearchResp resp = client.search(SearchReq.builder() .collectionName(COLLECTION_NAME) .limit(SEARCH_K) diff --git a/examples/src/main/java/io/milvus/v2/GeometryExample.java b/examples/src/main/java/io/milvus/v2/GeometryExample.java index a1b529bf1..e7f6ca526 100644 --- a/examples/src/main/java/io/milvus/v2/GeometryExample.java +++ b/examples/src/main/java/io/milvus/v2/GeometryExample.java @@ -36,10 +36,13 @@ import io.milvus.v2.service.vector.request.QueryReq; import io.milvus.v2.service.vector.response.QueryResp; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public class GeometryExample { private static final MilvusClientV2 client; + static { client = new MilvusClientV2(ConnectConfig.builder() .uri("http://localhost:19530") @@ -120,7 +123,7 @@ private static void printRowCount() { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - System.out.printf("%d rows persisted\n", (long)countR.getQueryResults().get(0).getEntity().get("count(*)")); + System.out.printf("%d rows persisted\n", (long) countR.getQueryResults().get(0).getEntity().get("count(*)")); } private static void query(String filter) { diff --git a/examples/src/main/java/io/milvus/v2/HybridSearchExample.java b/examples/src/main/java/io/milvus/v2/HybridSearchExample.java index ab729e239..fd90e56d9 100644 --- a/examples/src/main/java/io/milvus/v2/HybridSearchExample.java +++ b/examples/src/main/java/io/milvus/v2/HybridSearchExample.java @@ -21,20 +21,16 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; -import io.milvus.v2.common.DataType; import io.milvus.v1.CommonUtils; import io.milvus.v2.client.ConnectConfig; import io.milvus.v2.client.MilvusClientV2; import io.milvus.v2.common.ConsistencyLevel; +import io.milvus.v2.common.DataType; import io.milvus.v2.common.IndexParam; import io.milvus.v2.service.collection.request.AddFieldReq; import io.milvus.v2.service.collection.request.CreateCollectionReq; import io.milvus.v2.service.collection.request.DropCollectionReq; -import io.milvus.v2.service.vector.request.AnnSearchReq; -import io.milvus.v2.service.vector.request.FunctionScore; -import io.milvus.v2.service.vector.request.HybridSearchReq; -import io.milvus.v2.service.vector.request.InsertReq; -import io.milvus.v2.service.vector.request.QueryReq; +import io.milvus.v2.service.vector.request.*; import io.milvus.v2.service.vector.request.data.BaseVector; import io.milvus.v2.service.vector.request.data.BinaryVec; import io.milvus.v2.service.vector.request.data.FloatVec; @@ -107,10 +103,10 @@ private static void createCollection() { .build()); List indexes = new ArrayList<>(); - Map fvParams = new HashMap<>(); - fvParams.put("nlist",128); - fvParams.put("m",16); - fvParams.put("nbits",8); + Map fvParams = new HashMap<>(); + fvParams.put("nlist", 128); + fvParams.put("m", 16); + fvParams.put("nbits", 8); indexes.add(IndexParam.builder() .fieldName(FLOAT_VECTOR_FIELD) .indexType(IndexParam.IndexType.IVF_PQ) @@ -122,9 +118,9 @@ private static void createCollection() { .indexType(IndexParam.IndexType.BIN_FLAT) .metricType(BINARY_VECTOR_METRIC) .build()); - Map fv16Params = new HashMap<>(); - fv16Params.put("M",16); - fv16Params.put("efConstruction",64); + Map fv16Params = new HashMap<>(); + fv16Params.put("M", 16); + fv16Params.put("efConstruction", 64); indexes.add(IndexParam.builder() .fieldName(FLOAT16_VECTOR_FIELD) .indexType(IndexParam.IndexType.HNSW) @@ -177,7 +173,7 @@ private static void printRowCount() { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - System.out.printf("%d rows persisted\n", (long)countR.getQueryResults().get(0).getEntity().get("count(*)")); + System.out.printf("%d rows persisted\n", (long) countR.getQueryResults().get(0).getEntity().get("count(*)")); } private static void hybridSearch() { diff --git a/examples/src/main/java/io/milvus/v2/Int8VectorExample.java b/examples/src/main/java/io/milvus/v2/Int8VectorExample.java index 5d6ed4481..828e11b75 100644 --- a/examples/src/main/java/io/milvus/v2/Int8VectorExample.java +++ b/examples/src/main/java/io/milvus/v2/Int8VectorExample.java @@ -21,7 +21,6 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; -import io.milvus.v1.CommonUtils; import io.milvus.v2.client.ConnectConfig; import io.milvus.v2.client.MilvusClientV2; import io.milvus.v2.common.ConsistencyLevel; @@ -33,7 +32,6 @@ import io.milvus.v2.service.vector.request.InsertReq; import io.milvus.v2.service.vector.request.QueryReq; import io.milvus.v2.service.vector.request.SearchReq; -import io.milvus.v2.service.vector.request.data.BinaryVec; import io.milvus.v2.service.vector.request.data.Int8Vec; import io.milvus.v2.service.vector.response.QueryResp; import io.milvus.v2.service.vector.response.SearchResp; @@ -89,7 +87,7 @@ public static void main(String[] args) { .build()); List indexes = new ArrayList<>(); - Map extraParams = new HashMap<>(); + Map extraParams = new HashMap<>(); extraParams.put("M", 64); extraParams.put("efConstruction", 200); indexes.add(IndexParam.builder() @@ -116,7 +114,7 @@ public static void main(String[] args) { for (long i = 0L; i < rowCount; ++i) { JsonObject row = new JsonObject(); row.addProperty(ID_FIELD, i); - ByteBuffer vector = vectors.get((int)i); + ByteBuffer vector = vectors.get((int) i); row.add(VECTOR_FIELD, gson.toJsonTree(vector.array())); rows.add(row); } @@ -132,7 +130,7 @@ public static void main(String[] args) { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - System.out.printf("%d rows persisted\n", (long)countR.getQueryResults().get(0).getEntity().get("count(*)")); + System.out.printf("%d rows persisted\n", (long) countR.getQueryResults().get(0).getEntity().get("count(*)")); // Pick some vectors from the inserted vectors to search // Ensure the returned top1 item's ID should be equal to target vector's ID @@ -160,9 +158,9 @@ public static void main(String[] args) { } SearchResp.SearchResult firstResult = results.get(0); - if ((long)firstResult.getId() != k) { + if ((long) firstResult.getId() != k) { throw new RuntimeException(String.format("The top1 ID %d is not equal to target vector's ID %d", - (long)firstResult.getId(), k)); + (long) firstResult.getId(), k)); } } System.out.println("Search result is correct"); diff --git a/examples/src/main/java/io/milvus/v2/IteratorExample.java b/examples/src/main/java/io/milvus/v2/IteratorExample.java index 7fae70b5e..d7791313d 100644 --- a/examples/src/main/java/io/milvus/v2/IteratorExample.java +++ b/examples/src/main/java/io/milvus/v2/IteratorExample.java @@ -47,11 +47,13 @@ public class IteratorExample { private static final MilvusClientV2 client; + static { client = new MilvusClientV2(ConnectConfig.builder() .uri("http://localhost:19530") .build()); } + private static final String COLLECTION_NAME = "java_sdk_example_iterator_v2"; private static final String ID_FIELD = "userID"; private static final String AGE_FIELD = "userAge"; @@ -200,7 +202,7 @@ private static void searchIteratorV2(String filter, Map params, Function, List> externalFilterFunc) { System.out.println("\n========== searchIteratorV2() =========="); System.out.println(String.format("expr='%s', params='%s', batchSize=%d, topK=%d", - filter, params==null ? "" : params.toString(), batchSize, topK)); + filter, params == null ? "" : params.toString(), batchSize, topK)); SearchIteratorV2 searchIterator = client.searchIteratorV2(SearchIteratorReqV2.builder() .collectionName(COLLECTION_NAME) .outputFields(Lists.newArrayList(AGE_FIELD)) @@ -208,7 +210,7 @@ private static void searchIteratorV2(String filter, Map params, .vectorFieldName(VECTOR_FIELD) .vectors(Collections.singletonList(new FloatVec(CommonUtils.generateFloatVector(VECTOR_DIM)))) .filter(filter) - .searchParams(params==null ? new HashMap<>() : params) + .searchParams(params == null ? new HashMap<>() : params) .limit(topK) .metricType(IndexParam.MetricType.L2) .consistencyLevel(ConsistencyLevel.BOUNDED) @@ -235,21 +237,21 @@ private static void searchIteratorV2(String filter, Map params, public static void main(String[] args) { buildCollection(); - queryIterator("userID < 300",50, 5,400); + queryIterator("userID < 300", 50, 5, 400); searchIteratorV1("userAge > 50 &&userAge < 100", "{\"range_filter\": 15.0, \"radius\": 20.0}", 100, 500); searchIteratorV1("", "", 10, 99); searchIteratorV2("userAge > 10 &&userAge < 20", null, 50, 120, null); - Map extraParams = new HashMap<>(); - extraParams.put("radius",15.0); + Map extraParams = new HashMap<>(); + extraParams.put("radius", 15.0); searchIteratorV2("", extraParams, 50, 100, null); // use external function to filter the result - Function, List> externalFilterFunc = (List src)->{ + Function, List> externalFilterFunc = (List src) -> { List newRes = new ArrayList<>(); for (SearchResp.SearchResult res : src) { - long id = (long)res.getId(); - if (id%2 == 0) { + long id = (long) res.getId(); + if (id % 2 == 0) { newRes.add(res); } } diff --git a/examples/src/main/java/io/milvus/v2/JsonFieldExample.java b/examples/src/main/java/io/milvus/v2/JsonFieldExample.java index 6dca633b4..2818776cd 100644 --- a/examples/src/main/java/io/milvus/v2/JsonFieldExample.java +++ b/examples/src/main/java/io/milvus/v2/JsonFieldExample.java @@ -101,7 +101,7 @@ public static void main(String[] args) { // Create INVERTED index for a specific entry of JSON field // Index for JSON field is supported from milvus v2.5.7 and fully supported in v2.5.13+ // Read the doc for more info: https://milvus.io/docs/json-indexing.md - Map p1 = new HashMap<>(); + Map p1 = new HashMap<>(); p1.put("json_path", "metadata[\"flags\"]"); p1.put("json_cast_type", "array_double"); indexes.add(IndexParam.builder() @@ -113,8 +113,8 @@ public static void main(String[] args) { // Create NGRAM index for a specific entry of JSON field // NGRAM index for JSON field is supported from milvus v2.6.2 // Read the doc for more info: https://milvus.io/docs/ngram.md - Map p2 = new HashMap<>(); - p2.put("json_path","metadata[\"path\"]"); + Map p2 = new HashMap<>(); + p2.put("json_path", "metadata[\"path\"]"); p2.put("json_cast_type", "varchar"); p2.put("min_gram", 3); p2.put("max_gram", 5); @@ -149,7 +149,7 @@ public static void main(String[] args) { JsonObject metadata = new JsonObject(); metadata.addProperty("path", String.format("\\root/abc_%d/path_%d", i, i)); metadata.addProperty("size", i); - if (i%7 == 0) { + if (i % 7 == 0) { metadata.addProperty("special", true); } metadata.add("flags", gson.toJsonTree(Arrays.asList(i, i + 1, i + 2))); @@ -158,8 +158,8 @@ public static void main(String[] args) { // System.out.println(metadata); // dynamic fields - if (i%2 == 0) { - row.addProperty("dynamic1", (double)i/3); + if (i % 2 == 0) { + row.addProperty("dynamic1", (double) i / 3); } else { row.addProperty("dynamic2", "ok"); } @@ -176,7 +176,7 @@ public static void main(String[] args) { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - System.out.printf("%d rows persisted\n", (long)countR.getQueryResults().get(0).getEntity().get("count(*)")); + System.out.printf("%d rows persisted\n", (long) countR.getQueryResults().get(0).getEntity().get("count(*)")); // Search and output JSON field List searchVectors = new ArrayList<>(); @@ -203,7 +203,7 @@ public static void main(String[] args) { System.out.println(result); } - long pk = (long)results.get(0).getId(); + long pk = (long) results.get(0).getId(); if (pk != i) { throw new RuntimeException(String.format("The top1 ID %d is not equal to target vector's ID %d", pk, i)); } @@ -213,7 +213,7 @@ public static void main(String[] args) { metadata, expectedMetadatas.get(i))); } List vector = (List) results.get(0).getEntity().get(VECTOR_FIELD); - CommonUtils.compareFloatVectors(vector, (List)searchVectors.get(i).getData()); + CommonUtils.compareFloatVectors(vector, (List) searchVectors.get(i).getData()); } // Query by filtering JSON diff --git a/examples/src/main/java/io/milvus/v2/NullAndDefaultExample.java b/examples/src/main/java/io/milvus/v2/NullAndDefaultExample.java index d2b50876a..cd7c9a96d 100644 --- a/examples/src/main/java/io/milvus/v2/NullAndDefaultExample.java +++ b/examples/src/main/java/io/milvus/v2/NullAndDefaultExample.java @@ -35,7 +35,10 @@ import io.milvus.v2.service.vector.request.QueryReq; import io.milvus.v2.service.vector.response.QueryResp; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; public class NullAndDefaultExample { private static final String COLLECTION_NAME = "java_sdk_example_nullable_v2"; @@ -144,7 +147,7 @@ public static void main(String[] args) { } // some values are default value - if (i%3==0) { + if (i % 3 == 0) { row.addProperty("default_test", 1.0); } @@ -172,7 +175,7 @@ public static void main(String[] args) { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - System.out.printf("%d rows in collection\n", (long)countR.getQueryResults().get(0).getEntity().get("count(*)")); + System.out.printf("%d rows in collection\n", (long) countR.getQueryResults().get(0).getEntity().get("count(*)")); // Query by filtering expression queryWithExpr(client, "id >= 0"); // show all items diff --git a/examples/src/main/java/io/milvus/v2/RankerExample.java b/examples/src/main/java/io/milvus/v2/RankerExample.java index 46ac8ac9e..2e325afb9 100644 --- a/examples/src/main/java/io/milvus/v2/RankerExample.java +++ b/examples/src/main/java/io/milvus/v2/RankerExample.java @@ -39,7 +39,10 @@ import io.milvus.v2.service.vector.response.QueryResp; import io.milvus.v2.service.vector.response.SearchResp; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; public class RankerExample { private static final MilvusClientV2 client; @@ -61,6 +64,7 @@ private static class Person { public String name; public int fromYear; public int toYear; + public Person(String name, int from, int to) { this.name = name; this.fromYear = from; @@ -186,7 +190,7 @@ private static void printRowCount() { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - System.out.printf("%d rows persisted\n", (long)countR.getQueryResults().get(0).getEntity().get("count(*)")); + System.out.printf("%d rows persisted\n", (long) countR.getQueryResults().get(0).getEntity().get("count(*)")); } private static void dropCollection() { diff --git a/examples/src/main/java/io/milvus/v2/SimpleExample.java b/examples/src/main/java/io/milvus/v2/SimpleExample.java index 25fbcbe4c..d30859aa1 100644 --- a/examples/src/main/java/io/milvus/v2/SimpleExample.java +++ b/examples/src/main/java/io/milvus/v2/SimpleExample.java @@ -19,14 +19,22 @@ package io.milvus.v2; -import com.google.gson.*; -import io.milvus.v2.client.*; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import io.milvus.v2.client.ConnectConfig; +import io.milvus.v2.client.MilvusClientV2; import io.milvus.v2.common.ConsistencyLevel; import io.milvus.v2.service.collection.request.CreateCollectionReq; import io.milvus.v2.service.collection.request.DropCollectionReq; -import io.milvus.v2.service.vector.request.*; +import io.milvus.v2.service.vector.request.GetReq; +import io.milvus.v2.service.vector.request.InsertReq; +import io.milvus.v2.service.vector.request.QueryReq; +import io.milvus.v2.service.vector.request.SearchReq; import io.milvus.v2.service.vector.request.data.FloatVec; -import io.milvus.v2.service.vector.response.*; +import io.milvus.v2.service.vector.response.GetResp; +import io.milvus.v2.service.vector.response.InsertResp; +import io.milvus.v2.service.vector.response.QueryResp; +import io.milvus.v2.service.vector.response.SearchResp; import java.util.*; @@ -57,7 +65,7 @@ public static void main(String[] args) { for (int i = 0; i < 100; i++) { JsonObject row = new JsonObject(); row.addProperty("id", i); - row.add("vector", gson.toJsonTree(new float[]{i, (float) i /2, (float) i /3, (float) i /4})); + row.add("vector", gson.toJsonTree(new float[]{i, (float) i / 2, (float) i / 3, (float) i / 4})); row.addProperty(String.format("dynamic_%d", i), "this is dynamic value"); // this value is stored in dynamic field rows.add(row); } @@ -73,7 +81,7 @@ public static void main(String[] args) { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - System.out.printf("%d rows persisted\n", (long)countR.getQueryResults().get(0).getEntity().get("count(*)")); + System.out.printf("%d rows persisted\n", (long) countR.getQueryResults().get(0).getEntity().get("count(*)")); // Retrieve List ids = Arrays.asList(1L, 50L); @@ -99,7 +107,7 @@ public static void main(String[] args) { System.out.println("\nSearch results:"); for (List results : searchResults) { for (SearchResp.SearchResult result : results) { - System.out.printf("ID: %d, Score: %f, %s\n", (long)result.getId(), result.getScore(), result.getEntity().toString()); + System.out.printf("ID: %d, Score: %f, %s\n", (long) result.getId(), result.getScore(), result.getEntity().toString()); } } @@ -128,7 +136,7 @@ public static void main(String[] args) { System.out.println("\nSearch with template results:"); for (List results : searchResults2) { for (SearchResp.SearchResult result : results) { - System.out.printf("ID: %d, Score: %f, %s\n", (long)result.getId(), result.getScore(), result.getEntity().toString()); + System.out.printf("ID: %d, Score: %f, %s\n", (long) result.getId(), result.getScore(), result.getEntity().toString()); } } }); diff --git a/examples/src/main/java/io/milvus/v2/SparseVectorExample.java b/examples/src/main/java/io/milvus/v2/SparseVectorExample.java index ebc69ae34..8ffd9b954 100644 --- a/examples/src/main/java/io/milvus/v2/SparseVectorExample.java +++ b/examples/src/main/java/io/milvus/v2/SparseVectorExample.java @@ -110,7 +110,7 @@ public static void main(String[] args) { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - System.out.printf("%d rows persisted\n", (long)countR.getQueryResults().get(0).getEntity().get("count(*)")); + System.out.printf("%d rows persisted\n", (long) countR.getQueryResults().get(0).getEntity().get("count(*)")); // Pick some vectors from the inserted vectors to search // Ensure the returned top1 item's ID should be equal to target vector's ID @@ -119,8 +119,8 @@ public static void main(String[] args) { int k = ran.nextInt(rowCount); SortedMap targetVector = vectors.get(k); System.out.println("\nTarget vector: " + targetVector); - Map params = new HashMap<>(); - params.put("drop_ratio_search",0.2); + Map params = new HashMap<>(); + params.put("drop_ratio_search", 0.2); SearchResp searchResp = client.search(SearchReq.builder() .collectionName(COLLECTION_NAME) .data(Collections.singletonList(new SparseFloatVec(targetVector))) @@ -140,7 +140,7 @@ public static void main(String[] args) { } SearchResp.SearchResult firstResult = results.get(0); - if ((long)firstResult.getId() != k) { + if ((long) firstResult.getId() != k) { throw new RuntimeException(String.format("The top1 ID %d is not equal to target vector's ID %d", firstResult.getId(), k)); } diff --git a/examples/src/main/java/io/milvus/v2/StageFileManagerExample.java b/examples/src/main/java/io/milvus/v2/StageFileManagerExample.java index c554075fd..d7a8bc07e 100644 --- a/examples/src/main/java/io/milvus/v2/StageFileManagerExample.java +++ b/examples/src/main/java/io/milvus/v2/StageFileManagerExample.java @@ -31,6 +31,7 @@ */ public class StageFileManagerExample { private static final StageFileManager stageFileManager; + static { StageFileManagerParam stageFileManagerParam = StageFileManagerParam.newBuilder() .withCloudEndpoint("https://api.cloud.zilliz.com") diff --git a/examples/src/main/java/io/milvus/v2/StageManagerExample.java b/examples/src/main/java/io/milvus/v2/StageManagerExample.java index 70c10444b..d700c7e8e 100644 --- a/examples/src/main/java/io/milvus/v2/StageManagerExample.java +++ b/examples/src/main/java/io/milvus/v2/StageManagerExample.java @@ -32,6 +32,7 @@ */ public class StageManagerExample { private static final StageManager stageManager; + static { StageManagerParam stageManagerParam = StageManagerParam.newBuilder() .withCloudEndpoint("https://api.cloud.zilliz.com") diff --git a/examples/src/main/java/io/milvus/v2/StructExample.java b/examples/src/main/java/io/milvus/v2/StructExample.java index b05af173a..dca2b5db0 100644 --- a/examples/src/main/java/io/milvus/v2/StructExample.java +++ b/examples/src/main/java/io/milvus/v2/StructExample.java @@ -47,6 +47,7 @@ public class StructExample { private static final MilvusClientV2 client; + static { client = new MilvusClientV2(ConnectConfig.builder() .uri("http://localhost:19530") @@ -184,9 +185,10 @@ private static void insertData(int rowCount) { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - System.out.printf("%d rows persisted\n", (long)countR.getQueryResults().get(0).getEntity().get("count(*)")); + System.out.printf("%d rows persisted\n", (long) countR.getQueryResults().get(0).getEntity().get("count(*)")); } + private static List query(String filter) { System.out.println("==================================================="); System.out.println("Query with filter expression: " + filter); @@ -244,10 +246,10 @@ public static void main(String[] args) { // in the insertData() method, we inserted 5 structures for each row // in query results, each struct is represented as a Map Map fetchedEntity = result.getEntity(); - List> structs = (List>)fetchedEntity.get(STRUCT_FIELD); + List> structs = (List>) fetchedEntity.get(STRUCT_FIELD); EmbeddingList embList = new EmbeddingList(); for (Map struct : structs) { - List vector = (List)struct.get(CLIP_VECTOR_FIELD); + List vector = (List) struct.get(CLIP_VECTOR_FIELD); embList.add(new FloatVec(vector)); } search(CLIP_VECTOR_FIELD, Collections.singletonList(embList)); diff --git a/examples/src/main/java/io/milvus/v2/TextMatchExample.java b/examples/src/main/java/io/milvus/v2/TextMatchExample.java index 461d9025a..ae5ac6559 100644 --- a/examples/src/main/java/io/milvus/v2/TextMatchExample.java +++ b/examples/src/main/java/io/milvus/v2/TextMatchExample.java @@ -73,7 +73,7 @@ private static void searchWithFilter(MilvusClientV2 client, String filter) { List> searchResults = searchResp.getSearchResults(); for (List results : searchResults) { for (SearchResp.SearchResult result : results) { - System.out.printf("ID: %d, Score: %f, %s\n", (long)result.getId(), result.getScore(), result.getEntity().toString()); + System.out.printf("ID: %d, Score: %f, %s\n", (long) result.getId(), result.getScore(), result.getEntity().toString()); } } System.out.println("============================================================="); @@ -162,7 +162,7 @@ public static void main(String[] args) { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - System.out.printf("%d rows in collection\n", (long)countR.getQueryResults().get(0).getEntity().get("count(*)")); + System.out.printf("%d rows in collection\n", (long) countR.getQueryResults().get(0).getEntity().get("count(*)")); // TEXT_MATCH requires the data is persisted client.flush(FlushReq.builder().collectionNames(Collections.singletonList(COLLECTION_NAME)).build()); diff --git a/examples/src/main/java/io/milvus/v2/UpsertExample.java b/examples/src/main/java/io/milvus/v2/UpsertExample.java index a61f780dc..dfd55bc93 100644 --- a/examples/src/main/java/io/milvus/v2/UpsertExample.java +++ b/examples/src/main/java/io/milvus/v2/UpsertExample.java @@ -41,6 +41,7 @@ public class UpsertExample { private static final MilvusClientV2 client; + static { client = new MilvusClientV2(ConnectConfig.builder() .uri("http://localhost:19530") @@ -159,7 +160,7 @@ private static void fullUpsert(Object id) { // Upsert, update all fields value // If autoID is true, the server will return a new primary key for the updated entity JsonObject row = new JsonObject(); - row.addProperty(ID_FIELD, (Long)id); // primary key must be input so that it can know which entity to be updated + row.addProperty(ID_FIELD, (Long) id); // primary key must be input so that it can know which entity to be updated List vectorUpdated = Arrays.asList(1.0f, 1.0f, 1.0f, 1.0f); row.add(VECTOR_FIELD, gson.toJsonTree(vectorUpdated)); String textUpdated = "this field has been updated"; @@ -285,7 +286,7 @@ private static void partialUpsert(List ids, boolean updateVector) { if (entity.get(NULLABLE_FIELD) != null) { throw new RuntimeException("Nullable field is not correctly updated for filter: " + filter); } - JsonObject newJson = (JsonObject)entity.get(JSON_FIELD); + JsonObject newJson = (JsonObject) entity.get(JSON_FIELD); if (!newJson.has("updated") && !newJson.get("updated").equals("yes")) { throw new RuntimeException("JSON field is not correctly updated for filter: " + filter); } @@ -312,7 +313,7 @@ private static void doUpsert(boolean autoID) { List ids = createCollection(autoID); // Update the entire row of the No.2 entity - fullUpsert((Long)ids.get(1)); + fullUpsert((Long) ids.get(1)); // Partially update the vectors of No.5 and No.6 entities partialUpsert(ids.subList(4, 6), true); diff --git a/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterLocalExample.java b/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterLocalExample.java index 563e86308..a4aa1c537 100644 --- a/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterLocalExample.java +++ b/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterLocalExample.java @@ -231,7 +231,7 @@ private static void readCsvSampleData(String filePath, BulkWriter writer) throws /** * @param collectionSchema collection info - * @param dropIfExist if collection already exist, will drop firstly and then create again + * @param dropIfExist if collection already exist, will drop firstly and then create again */ private static void createCollection(String collectionName, CreateCollectionReq.CollectionSchema collectionSchema, boolean dropIfExist) { System.out.println("\n===================== create collection ===================="); diff --git a/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterRemoteExample.java b/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterRemoteExample.java index ce7de0ecd..4bd811423 100644 --- a/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterRemoteExample.java +++ b/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterRemoteExample.java @@ -47,12 +47,7 @@ import io.milvus.v2.common.ConsistencyLevel; import io.milvus.v2.common.DataType; import io.milvus.v2.common.IndexParam; -import io.milvus.v2.service.collection.request.AddFieldReq; -import io.milvus.v2.service.collection.request.CreateCollectionReq; -import io.milvus.v2.service.collection.request.DropCollectionReq; -import io.milvus.v2.service.collection.request.HasCollectionReq; -import io.milvus.v2.service.collection.request.LoadCollectionReq; -import io.milvus.v2.service.collection.request.RefreshLoadReq; +import io.milvus.v2.service.collection.request.*; import io.milvus.v2.service.index.request.CreateIndexReq; import io.milvus.v2.service.vector.request.QueryReq; import io.milvus.v2.service.vector.response.QueryResp; @@ -61,13 +56,7 @@ import java.io.IOException; import java.net.URL; import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.TimeUnit; @@ -243,13 +232,13 @@ private static List> genOriginalData(int count) { for (int i = 0; i < count; ++i) { Map row = new HashMap<>(); // scalar field - row.put("id", (long)i); + row.put("id", (long) i); row.put("bool", i % 5 == 0); row.put("int8", i % 128); row.put("int16", i % 1000); row.put("int32", i % 100000); - row.put("float", (float)i / 3); - row.put("double", (double)i / 7); + row.put("float", (float) i / 3); + row.put("double", (double) i / 7); row.put("varchar", "varchar_" + i); row.put("json", String.format("{\"dummy\": %s, \"ok\": \"name_%s\"}", i, i)); @@ -275,7 +264,7 @@ private static List> genOriginalData(int count) { { Map row = new HashMap<>(); // scalar field - row.put("id", (long)data.size()); + row.put("id", (long) data.size()); row.put("bool", null); row.put("int8", null); row.put("int16", 16); @@ -312,7 +301,7 @@ private static List genImportData(List> original JsonObject rowObject = new JsonObject(); // scalar field - rowObject.addProperty("id", (Number)row.get("id")); + rowObject.addProperty("id", (Number) row.get("id")); if (row.get("bool") != null) { // nullable value can be missed rowObject.addProperty("bool", (Boolean) row.get("bool")); } @@ -328,7 +317,7 @@ private static List genImportData(List> original // Note: for JSON field, use gson.fromJson() to construct a real JsonObject // don't use rowObject.addProperty("json", jsonContent) since the value is treated as a string, not a JsonObject Object jsonContent = row.get("json"); - rowObject.add("json", jsonContent == null ? null : GSON_INSTANCE.fromJson((String)jsonContent, JsonElement.class)); + rowObject.add("json", jsonContent == null ? null : GSON_INSTANCE.fromJson((String) jsonContent, JsonElement.class)); // vector field rowObject.add("float_vector", GSON_INSTANCE.toJsonTree(row.get("float_vector"))); @@ -488,7 +477,7 @@ private static void callBulkInsert(List> batchFiles) throws Interru /** * @param collectionSchema collection info - * @param dropIfExist if collection already exist, will drop firstly and then create again + * @param dropIfExist if collection already exist, will drop firstly and then create again */ private static void createCollection(String collectionName, CreateCollectionReq.CollectionSchema collectionSchema, boolean dropIfExist) { System.out.println("\n===================== create collection ===================="); @@ -523,7 +512,7 @@ private static void comparePrint(CreateCollectionReq.CollectionSchema collection expectedValue = field.getDefaultValue(); // for Int8/Int16 value, the default value is Short type, the returned value is Integer type if (expectedValue instanceof Short) { - expectedValue = ((Short)expectedValue).intValue(); + expectedValue = ((Short) expectedValue).intValue(); } } } @@ -541,19 +530,19 @@ private static void comparePrint(CreateCollectionReq.CollectionSchema collection boolean matched; if (fetchedValue instanceof Float) { - matched = Math.abs((Float)fetchedValue - (Float)expectedValue) < 1e-4; + matched = Math.abs((Float) fetchedValue - (Float) expectedValue) < 1e-4; } else if (fetchedValue instanceof Double) { - matched = Math.abs((Double)fetchedValue - (Double)expectedValue) < 1e-8; + matched = Math.abs((Double) fetchedValue - (Double) expectedValue) < 1e-8; } else if (fetchedValue instanceof JsonElement) { - JsonElement expectedJson = GSON_INSTANCE.fromJson((String)expectedValue, JsonElement.class); + JsonElement expectedJson = GSON_INSTANCE.fromJson((String) expectedValue, JsonElement.class); matched = fetchedValue.equals(expectedJson); } else if (fetchedValue instanceof ByteBuffer) { - byte[] bb = ((ByteBuffer)fetchedValue).array(); - matched = Arrays.equals(bb, (byte[])expectedValue); + byte[] bb = ((ByteBuffer) fetchedValue).array(); + matched = Arrays.equals(bb, (byte[]) expectedValue); } else if (fetchedValue instanceof List) { matched = fetchedValue.equals(expectedValue); // currently, for array field, null value, the server returns an empty list - if (((List) fetchedValue).isEmpty() && expectedValue==null) { + if (((List) fetchedValue).isEmpty() && expectedValue == null) { matched = true; } } else { @@ -572,7 +561,7 @@ private static void comparePrint(CreateCollectionReq.CollectionSchema collection private static void verifyImportData(CreateCollectionReq.CollectionSchema collectionSchema, List> rows) { createIndex(); - List QUERY_IDS = Lists.newArrayList(1L, (long)rows.get(rows.size()-1).get("id")); + List QUERY_IDS = Lists.newArrayList(1L, (long) rows.get(rows.size() - 1).get("id")); System.out.printf("Load collection and query items %s%n", QUERY_IDS); loadCollection(); @@ -586,8 +575,8 @@ private static void verifyImportData(CreateCollectionReq.CollectionSchema collec } for (QueryResp.QueryResult result : results) { Map fetchedEntity = result.getEntity(); - long id = (Long)fetchedEntity.get("id"); - Map originalEntity = rows.get((int)id); + long id = (Long) fetchedEntity.get("id"); + Map originalEntity = rows.get((int) id); comparePrint(collectionSchema, originalEntity, fetchedEntity, "bool"); comparePrint(collectionSchema, originalEntity, fetchedEntity, "int8"); comparePrint(collectionSchema, originalEntity, fetchedEntity, "int16"); @@ -687,7 +676,7 @@ private static Long getCollectionRowCount() { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - return (long)countR.getQueryResults().get(0).getEntity().get("count(*)"); + return (long) countR.getQueryResults().get(0).getEntity().get("count(*)"); } private static void exampleCloudImport() { @@ -762,7 +751,7 @@ private static CreateCollectionReq.CollectionSchema buildAllTypesSchema() { schemaV2.addField(AddFieldReq.builder() .fieldName("int8") .dataType(DataType.Int8) - .defaultValue((short)88) + .defaultValue((short) 88) .build()); schemaV2.addField(AddFieldReq.builder() .fieldName("int16") @@ -778,7 +767,7 @@ private static CreateCollectionReq.CollectionSchema buildAllTypesSchema() { .fieldName("float") .dataType(DataType.Float) .isNullable(true) - .defaultValue((float)3.14159) + .defaultValue((float) 3.14159) .build()); schemaV2.addField(AddFieldReq.builder() .fieldName("double") diff --git a/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterStageExample.java b/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterStageExample.java index 7f6b5c213..00e35269b 100644 --- a/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterStageExample.java +++ b/examples/src/main/java/io/milvus/v2/bulkwriter/BulkWriterStageExample.java @@ -38,24 +38,14 @@ import io.milvus.v2.common.ConsistencyLevel; import io.milvus.v2.common.DataType; import io.milvus.v2.common.IndexParam; -import io.milvus.v2.service.collection.request.AddFieldReq; -import io.milvus.v2.service.collection.request.CreateCollectionReq; -import io.milvus.v2.service.collection.request.DropCollectionReq; -import io.milvus.v2.service.collection.request.HasCollectionReq; -import io.milvus.v2.service.collection.request.LoadCollectionReq; -import io.milvus.v2.service.collection.request.RefreshLoadReq; +import io.milvus.v2.service.collection.request.*; import io.milvus.v2.service.index.request.CreateIndexReq; import io.milvus.v2.service.vector.request.QueryReq; import io.milvus.v2.service.vector.response.QueryResp; import java.io.IOException; import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.TimeUnit; @@ -171,13 +161,13 @@ private static List> genOriginalData(int count) { for (int i = 0; i < count; ++i) { Map row = new HashMap<>(); // scalar field - row.put("id", (long)i); + row.put("id", (long) i); row.put("bool", i % 5 == 0); row.put("int8", i % 128); row.put("int16", i % 1000); row.put("int32", i % 100000); - row.put("float", (float)i / 3); - row.put("double", (double)i / 7); + row.put("float", (float) i / 3); + row.put("double", (double) i / 7); row.put("varchar", "varchar_" + i); row.put("json", String.format("{\"dummy\": %s, \"ok\": \"name_%s\"}", i, i)); @@ -203,7 +193,7 @@ private static List> genOriginalData(int count) { { Map row = new HashMap<>(); // scalar field - row.put("id", (long)data.size()); + row.put("id", (long) data.size()); row.put("bool", null); row.put("int8", null); row.put("int16", 16); @@ -240,7 +230,7 @@ private static List genImportData(List> original JsonObject rowObject = new JsonObject(); // scalar field - rowObject.addProperty("id", (Number)row.get("id")); + rowObject.addProperty("id", (Number) row.get("id")); if (row.get("bool") != null) { // nullable value can be missed rowObject.addProperty("bool", (Boolean) row.get("bool")); } @@ -256,7 +246,7 @@ private static List genImportData(List> original // Note: for JSON field, use gson.fromJson() to construct a real JsonObject // don't use rowObject.addProperty("json", jsonContent) since the value is treated as a string, not a JsonObject Object jsonContent = row.get("json"); - rowObject.add("json", jsonContent == null ? null : GSON_INSTANCE.fromJson((String)jsonContent, JsonElement.class)); + rowObject.add("json", jsonContent == null ? null : GSON_INSTANCE.fromJson((String) jsonContent, JsonElement.class)); // vector field rowObject.add("float_vector", GSON_INSTANCE.toJsonTree(row.get("float_vector"))); @@ -322,7 +312,7 @@ private static StageBulkWriter buildStageBulkWriter(CreateCollectionReq.Collecti /** * @param collectionSchema collection info - * @param dropIfExist if collection already exist, will drop firstly and then create again + * @param dropIfExist if collection already exist, will drop firstly and then create again */ private static void createCollection(String collectionName, CreateCollectionReq.CollectionSchema collectionSchema, boolean dropIfExist) { System.out.println("\n===================== create collection ===================="); @@ -357,7 +347,7 @@ private static void comparePrint(CreateCollectionReq.CollectionSchema collection expectedValue = field.getDefaultValue(); // for Int8/Int16 value, the default value is Short type, the returned value is Integer type if (expectedValue instanceof Short) { - expectedValue = ((Short)expectedValue).intValue(); + expectedValue = ((Short) expectedValue).intValue(); } } } @@ -375,19 +365,19 @@ private static void comparePrint(CreateCollectionReq.CollectionSchema collection boolean matched; if (fetchedValue instanceof Float) { - matched = Math.abs((Float)fetchedValue - (Float)expectedValue) < 1e-4; + matched = Math.abs((Float) fetchedValue - (Float) expectedValue) < 1e-4; } else if (fetchedValue instanceof Double) { - matched = Math.abs((Double)fetchedValue - (Double)expectedValue) < 1e-8; + matched = Math.abs((Double) fetchedValue - (Double) expectedValue) < 1e-8; } else if (fetchedValue instanceof JsonElement) { - JsonElement expectedJson = GSON_INSTANCE.fromJson((String)expectedValue, JsonElement.class); + JsonElement expectedJson = GSON_INSTANCE.fromJson((String) expectedValue, JsonElement.class); matched = fetchedValue.equals(expectedJson); } else if (fetchedValue instanceof ByteBuffer) { - byte[] bb = ((ByteBuffer)fetchedValue).array(); - matched = Arrays.equals(bb, (byte[])expectedValue); + byte[] bb = ((ByteBuffer) fetchedValue).array(); + matched = Arrays.equals(bb, (byte[]) expectedValue); } else if (fetchedValue instanceof List) { matched = fetchedValue.equals(expectedValue); // currently, for array field, null value, the server returns an empty list - if (((List) fetchedValue).isEmpty() && expectedValue==null) { + if (((List) fetchedValue).isEmpty() && expectedValue == null) { matched = true; } } else { @@ -406,7 +396,7 @@ private static void comparePrint(CreateCollectionReq.CollectionSchema collection private static void verifyImportData(CreateCollectionReq.CollectionSchema collectionSchema, List> rows) { createIndex(); - List QUERY_IDS = Lists.newArrayList(1L, (long)rows.get(rows.size()-1).get("id")); + List QUERY_IDS = Lists.newArrayList(1L, (long) rows.get(rows.size() - 1).get("id")); System.out.printf("Load collection and query items %s%n", QUERY_IDS); loadCollection(); @@ -420,8 +410,8 @@ private static void verifyImportData(CreateCollectionReq.CollectionSchema collec } for (QueryResp.QueryResult result : results) { Map fetchedEntity = result.getEntity(); - long id = (Long)fetchedEntity.get("id"); - Map originalEntity = rows.get((int)id); + long id = (Long) fetchedEntity.get("id"); + Map originalEntity = rows.get((int) id); comparePrint(collectionSchema, originalEntity, fetchedEntity, "bool"); comparePrint(collectionSchema, originalEntity, fetchedEntity, "int8"); comparePrint(collectionSchema, originalEntity, fetchedEntity, "int16"); @@ -521,7 +511,7 @@ private static Long getCollectionRowCount() { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - return (long)countR.getQueryResults().get(0).getEntity().get("count(*)"); + return (long) countR.getQueryResults().get(0).getEntity().get("count(*)"); } private static CreateCollectionReq.CollectionSchema buildAllTypesSchema() { @@ -543,7 +533,7 @@ private static CreateCollectionReq.CollectionSchema buildAllTypesSchema() { schemaV2.addField(AddFieldReq.builder() .fieldName("int8") .dataType(DataType.Int8) - .defaultValue((short)88) + .defaultValue((short) 88) .build()); schemaV2.addField(AddFieldReq.builder() .fieldName("int16") @@ -559,7 +549,7 @@ private static CreateCollectionReq.CollectionSchema buildAllTypesSchema() { .fieldName("float") .dataType(DataType.Float) .isNullable(true) - .defaultValue((float)3.14159) + .defaultValue((float) 3.14159) .build()); schemaV2.addField(AddFieldReq.builder() .fieldName("double") diff --git a/examples/src/main/java/io/milvus/v2/bulkwriter/CsvDataObject.java b/examples/src/main/java/io/milvus/v2/bulkwriter/CsvDataObject.java index 7ba12a857..815a08ce3 100644 --- a/examples/src/main/java/io/milvus/v2/bulkwriter/CsvDataObject.java +++ b/examples/src/main/java/io/milvus/v2/bulkwriter/CsvDataObject.java @@ -38,12 +38,15 @@ public class CsvDataObject { public String getVector() { return vector; } + public String getPath() { return path; } + public String getLabel() { return label; } + public List toFloatArray() { return GSON_INSTANCE.fromJson(vector, new TypeToken>() { }.getType()); diff --git a/pom.xml b/pom.xml index 80fbf9373..21c7dfb53 100644 --- a/pom.xml +++ b/pom.xml @@ -100,7 +100,6 @@ 1.7.36 4.13.2 5.10.1 - 1.18.22 4.12.0 3.1.0 3.7.0 diff --git a/sdk-bulkwriter/pom.xml b/sdk-bulkwriter/pom.xml index b840ec7b6..48c9cd2d6 100644 --- a/sdk-bulkwriter/pom.xml +++ b/sdk-bulkwriter/pom.xml @@ -101,12 +101,6 @@ junit-jupiter test - - org.projectlombok - lombok - ${lombok.version} - provided - org.apache.parquet parquet-avro diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/BulkWriter.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/BulkWriter.java index 897c41586..d23a78dec 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/BulkWriter.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/BulkWriter.java @@ -127,7 +127,7 @@ private void createWriterByType() throws IOException { switch (fileType) { case PARQUET: - this.fileWriter = new ParquetFileWriter(collectionSchema, filePathPrefix.toString()); + this.fileWriter = new ParquetFileWriter(collectionSchema, filePathPrefix.toString()); break; case JSON: this.fileWriter = new JSONFileWriter(collectionSchema, filePathPrefix.toString()); @@ -223,7 +223,7 @@ protected Map verifyRow(JsonObject row) { } JsonElement obj = row.get(fieldName); - if (obj == null ) { + if (obj == null) { obj = JsonNull.INSTANCE; } if (outputFieldNames.contains(fieldName)) { @@ -288,7 +288,7 @@ protected Map verifyRow(JsonObject row) { case Float16Vector: case BFloat16Vector: case SparseFloatVector: - case Int8Vector:{ + case Int8Vector: { Pair objectAndSize = verifyVector(obj, field); rowValues.put(fieldName, objectAndSize.getLeft()); rowSize += objectAndSize.getRight(); @@ -369,21 +369,21 @@ private Pair verifyVector(JsonElement object, CreateCollectionR return Pair.of(vector, ((List) vector).size() * 4); case BinaryVector: case Int8Vector: - return Pair.of(vector, ((ByteBuffer)vector).limit()); + return Pair.of(vector, ((ByteBuffer) vector).limit()); case Float16Vector: case BFloat16Vector: // for JSON and CSV, float16/bfloat16 vector is parsed as float values in text if (this.fileType == BulkFileType.CSV || this.fileType == BulkFileType.JSON) { - ByteBuffer bv = (ByteBuffer)vector; + ByteBuffer bv = (ByteBuffer) vector; bv.order(ByteOrder.LITTLE_ENDIAN); // ensure LITTLE_ENDIAN List v = (dataType == DataType.Float16Vector) ? Float16Utils.fp16BufferToVector(bv) : Float16Utils.bf16BufferToVector(bv); return Pair.of(v, v.size() * 4); } // for PARQUET, float16/bfloat16 vector is parsed as binary - return Pair.of(vector, ((ByteBuffer)vector).limit() * 2); + return Pair.of(vector, ((ByteBuffer) vector).limit() * 2); case SparseFloatVector: - return Pair.of(vector, ((SortedMap)vector).size() * 12); + return Pair.of(vector, ((SortedMap) vector).size() * 12); default: ExceptionUtils.throwUnExpectedException("Unknown vector type"); } @@ -417,7 +417,7 @@ private Pair verifyArray(JsonElement object, CreateCollectionRe int rowSize = 0; DataType elementType = field.getElementType(); if (TypeSize.contains(elementType)) { - rowSize = TypeSize.getSize(elementType) * ((List)array).size(); + rowSize = TypeSize.getSize(elementType) * ((List) array).size(); } else if (elementType == DataType.VarChar) { for (String str : (List) array) { rowSize += str.length(); diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/LocalBulkWriter.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/LocalBulkWriter.java index 04fba4806..52dc55d3e 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/LocalBulkWriter.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/LocalBulkWriter.java @@ -41,9 +41,9 @@ public class LocalBulkWriter extends BulkWriter { private static final Logger logger = LoggerFactory.getLogger(LocalBulkWriter.class); - private Map workingThread; - private ReentrantLock workingThreadLock; - private List> localFiles; + private final Map workingThread; + private final ReentrantLock workingThreadLock; + private final List> localFiles; public LocalBulkWriter(LocalBulkWriterParam bulkWriterParam) throws IOException { super(bulkWriterParam.getCollectionSchema(), bulkWriterParam.getChunkSize(), bulkWriterParam.getFileType(), bulkWriterParam.getLocalPath(), bulkWriterParam.getConfig()); @@ -93,7 +93,7 @@ protected List commitIfFileReady(boolean createNewFile) { String filePath = super.getFileWriter().getFilePath(); String msg = String.format("Prepare to commit file:%s, current_file_total_row_count: %s, current_file_total_size:%s, create_new_file:%s", - filePath ,super.getTotalRowCount(), super.getTotalSize(), createNewFile); + filePath, super.getTotalRowCount(), super.getTotalSize(), createNewFile); logger.info(msg); List fileList = Lists.newArrayList(filePath); diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/LocalBulkWriterParam.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/LocalBulkWriterParam.java index 2bdc00a98..638c4bf6e 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/LocalBulkWriterParam.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/LocalBulkWriterParam.java @@ -25,9 +25,6 @@ import io.milvus.param.ParamUtils; import io.milvus.param.collection.CollectionSchemaParam; import io.milvus.v2.service.collection.request.CreateCollectionReq; -import lombok.Getter; -import lombok.NonNull; -import lombok.ToString; import java.util.HashMap; import java.util.Map; @@ -35,8 +32,6 @@ /** * Parameters for bulkWriter interface. */ -@Getter -@ToString public class LocalBulkWriterParam { private final CreateCollectionReq.CollectionSchema collectionSchema; private final String localPath; @@ -44,7 +39,7 @@ public class LocalBulkWriterParam { private final BulkFileType fileType; private final Map config; - private LocalBulkWriterParam(@NonNull Builder builder) { + private LocalBulkWriterParam(Builder builder) { this.collectionSchema = builder.collectionSchema; this.localPath = builder.localPath; this.chunkSize = builder.chunkSize; @@ -52,6 +47,36 @@ private LocalBulkWriterParam(@NonNull Builder builder) { this.config = builder.config; } + public CreateCollectionReq.CollectionSchema getCollectionSchema() { + return collectionSchema; + } + + public String getLocalPath() { + return localPath; + } + + public long getChunkSize() { + return chunkSize; + } + + public BulkFileType getFileType() { + return fileType; + } + + public Map getConfig() { + return config; + } + + @Override + public String toString() { + return "LocalBulkWriterParam{" + + "collectionSchema=" + collectionSchema + + ", localPath='" + localPath + '\'' + + ", chunkSize=" + chunkSize + + ", fileType=" + fileType + + '}'; + } + public static Builder newBuilder() { return new Builder(); } @@ -64,7 +89,7 @@ public static final class Builder { private String localPath; private long chunkSize = 128 * 1024 * 1024; private BulkFileType fileType = BulkFileType.PARQUET; - private Map config = new HashMap<>(); + private final Map config = new HashMap<>(); private Builder() { } @@ -75,7 +100,7 @@ private Builder() { * @param collectionSchema collection schema * @return Builder */ - public Builder withCollectionSchema(@NonNull CollectionSchemaParam collectionSchema) { + public Builder withCollectionSchema(CollectionSchemaParam collectionSchema) { this.collectionSchema = V2AdapterUtils.convertV1Schema(collectionSchema); return this; } @@ -86,7 +111,7 @@ public Builder withCollectionSchema(@NonNull CollectionSchemaParam collectionSch * @param collectionSchema collection schema * @return Builder */ - public Builder withCollectionSchema(@NonNull CreateCollectionReq.CollectionSchema collectionSchema) { + public Builder withCollectionSchema(CreateCollectionReq.CollectionSchema collectionSchema) { this.collectionSchema = collectionSchema; return this; } @@ -97,7 +122,7 @@ public Builder withCollectionSchema(@NonNull CreateCollectionReq.CollectionSchem * @param localPath collection name * @return Builder */ - public Builder withLocalPath(@NonNull String localPath) { + public Builder withLocalPath(String localPath) { this.localPath = localPath; return this; } @@ -132,5 +157,4 @@ public LocalBulkWriterParam build() throws ParamException { return new LocalBulkWriterParam(this); } } - } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/RemoteBulkWriter.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/RemoteBulkWriter.java index 98a418037..2564287ca 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/RemoteBulkWriter.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/RemoteBulkWriter.java @@ -47,11 +47,11 @@ public class RemoteBulkWriter extends LocalBulkWriter { private static final Logger logger = LoggerFactory.getLogger(RemoteBulkWriter.class); - private String remotePath; - private StorageConnectParam connectParam; + private final String remotePath; + private final StorageConnectParam connectParam; private StorageClient storageClient; - private List> remoteFiles; + private final List> remoteFiles; public RemoteBulkWriter(RemoteBulkWriterParam bulkWriterParam) throws IOException { super(bulkWriterParam.getCollectionSchema(), diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/RemoteBulkWriterParam.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/RemoteBulkWriterParam.java index 9c88973a1..b82fce6e5 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/RemoteBulkWriterParam.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/RemoteBulkWriterParam.java @@ -19,17 +19,13 @@ package io.milvus.bulkwriter; +import io.milvus.bulkwriter.common.clientenum.BulkFileType; import io.milvus.bulkwriter.common.utils.V2AdapterUtils; import io.milvus.bulkwriter.connect.StorageConnectParam; -import io.milvus.bulkwriter.common.clientenum.BulkFileType; import io.milvus.exception.ParamException; import io.milvus.param.ParamUtils; import io.milvus.param.collection.CollectionSchemaParam; import io.milvus.v2.service.collection.request.CreateCollectionReq; -import lombok.Getter; -import lombok.NonNull; -import lombok.ToString; -import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; @@ -37,8 +33,6 @@ /** * Parameters for bulkWriter interface. */ -@Getter -@ToString public class RemoteBulkWriterParam { private final CreateCollectionReq.CollectionSchema collectionSchema; private final StorageConnectParam connectParam; @@ -47,7 +41,7 @@ public class RemoteBulkWriterParam { private final BulkFileType fileType; private final Map config; - private RemoteBulkWriterParam(@NonNull Builder builder) { + private RemoteBulkWriterParam(Builder builder) { this.collectionSchema = builder.collectionSchema; this.connectParam = builder.connectParam; this.remotePath = builder.remotePath; @@ -56,6 +50,40 @@ private RemoteBulkWriterParam(@NonNull Builder builder) { this.config = builder.config; } + public CreateCollectionReq.CollectionSchema getCollectionSchema() { + return collectionSchema; + } + + public StorageConnectParam getConnectParam() { + return connectParam; + } + + public String getRemotePath() { + return remotePath; + } + + public long getChunkSize() { + return chunkSize; + } + + public BulkFileType getFileType() { + return fileType; + } + + public Map getConfig() { + return config; + } + + @Override + public String toString() { + return "RemoteBulkWriterParam{" + + "collectionSchema=" + collectionSchema + + ", remotePath='" + remotePath + '\'' + + ", chunkSize=" + chunkSize + + ", fileType=" + fileType + + '}'; + } + public static Builder newBuilder() { return new Builder(); } @@ -69,7 +97,7 @@ public static final class Builder { private String remotePath; private long chunkSize = 128 * 1024 * 1024; private BulkFileType fileType = BulkFileType.PARQUET; - private Map config = new HashMap<>(); + private final Map config = new HashMap<>(); private Builder() { } @@ -80,7 +108,7 @@ private Builder() { * @param collectionSchema collection info * @return Builder */ - public Builder withCollectionSchema(@NonNull CollectionSchemaParam collectionSchema) { + public Builder withCollectionSchema(CollectionSchemaParam collectionSchema) { this.collectionSchema = V2AdapterUtils.convertV1Schema(collectionSchema); return this; } @@ -91,12 +119,12 @@ public Builder withCollectionSchema(@NonNull CollectionSchemaParam collectionSch * @param collectionSchema collection schema * @return Builder */ - public Builder withCollectionSchema(@NonNull CreateCollectionReq.CollectionSchema collectionSchema) { + public Builder withCollectionSchema(CreateCollectionReq.CollectionSchema collectionSchema) { this.collectionSchema = collectionSchema; return this; } - public Builder withConnectParam(@NotNull StorageConnectParam connectParam) { + public Builder withConnectParam(StorageConnectParam connectParam) { this.connectParam = connectParam; return this; } @@ -107,7 +135,7 @@ public Builder withConnectParam(@NotNull StorageConnectParam connectParam) { * @param remotePath remote path * @return Builder */ - public Builder withRemotePath(@NonNull String remotePath) { + public Builder withRemotePath(String remotePath) { this.remotePath = remotePath; return this; } @@ -117,7 +145,7 @@ public Builder withChunkSize(long chunkSize) { return this; } - public Builder withFileType(@NonNull BulkFileType fileType) { + public Builder withFileType(BulkFileType fileType) { this.fileType = fileType; return this; } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageBulkWriter.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageBulkWriter.java index 3917bdceb..ff4ee56d2 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageBulkWriter.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageBulkWriter.java @@ -39,10 +39,10 @@ public class StageBulkWriter extends LocalBulkWriter { private static final Logger logger = LoggerFactory.getLogger(StageBulkWriter.class); - private String remotePath; - private List> remoteFiles; - private StageFileManager stageFileManager; - private StageBulkWriterParam stageBulkWriterParam; + private final String remotePath; + private final List> remoteFiles; + private final StageFileManager stageFileManager; + private final StageBulkWriterParam stageBulkWriterParam; public StageBulkWriter(StageBulkWriterParam bulkWriterParam) throws IOException { super(bulkWriterParam.getCollectionSchema(), diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageBulkWriterParam.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageBulkWriterParam.java index 8425fda56..84319d8ed 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageBulkWriterParam.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageBulkWriterParam.java @@ -25,10 +25,6 @@ import io.milvus.param.ParamUtils; import io.milvus.param.collection.CollectionSchemaParam; import io.milvus.v2.service.collection.request.CreateCollectionReq; -import lombok.Getter; -import lombok.NonNull; -import lombok.ToString; -import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; @@ -36,8 +32,6 @@ /** * Parameters for stageBulkWriter interface. */ -@Getter -@ToString public class StageBulkWriterParam { private final CreateCollectionReq.CollectionSchema collectionSchema; private final String remotePath; @@ -49,7 +43,7 @@ public class StageBulkWriterParam { private final String apiKey; private final String stageName; - private StageBulkWriterParam(@NonNull Builder builder) { + private StageBulkWriterParam(Builder builder) { this.collectionSchema = builder.collectionSchema; this.remotePath = builder.remotePath; this.chunkSize = builder.chunkSize; @@ -61,6 +55,50 @@ private StageBulkWriterParam(@NonNull Builder builder) { this.stageName = builder.stageName; } + public CreateCollectionReq.CollectionSchema getCollectionSchema() { + return collectionSchema; + } + + public String getRemotePath() { + return remotePath; + } + + public long getChunkSize() { + return chunkSize; + } + + public BulkFileType getFileType() { + return fileType; + } + + public Map getConfig() { + return config; + } + + public String getCloudEndpoint() { + return cloudEndpoint; + } + + public String getApiKey() { + return apiKey; + } + + public String getStageName() { + return stageName; + } + + @Override + public String toString() { + return "StageBulkWriterParam{" + + "collectionSchema=" + collectionSchema + + ", remotePath='" + remotePath + '\'' + + ", chunkSize=" + chunkSize + + ", fileType=" + fileType + + ", cloudEndpoint='" + cloudEndpoint + '\'' + + ", stageName='" + stageName + '\'' + + '}'; + } + public static Builder newBuilder() { return new Builder(); } @@ -73,7 +111,7 @@ public static final class Builder { private String remotePath; private long chunkSize = 128 * 1024 * 1024; private BulkFileType fileType = BulkFileType.PARQUET; - private Map config = new HashMap<>(); + private final Map config = new HashMap<>(); private String cloudEndpoint; private String apiKey; @@ -89,7 +127,7 @@ private Builder() { * @param collectionSchema collection info * @return Builder */ - public Builder withCollectionSchema(@NonNull CollectionSchemaParam collectionSchema) { + public Builder withCollectionSchema(CollectionSchemaParam collectionSchema) { this.collectionSchema = V2AdapterUtils.convertV1Schema(collectionSchema); return this; } @@ -100,7 +138,7 @@ public Builder withCollectionSchema(@NonNull CollectionSchemaParam collectionSch * @param collectionSchema collection schema * @return Builder */ - public Builder withCollectionSchema(@NonNull CreateCollectionReq.CollectionSchema collectionSchema) { + public Builder withCollectionSchema(CreateCollectionReq.CollectionSchema collectionSchema) { this.collectionSchema = collectionSchema; return this; } @@ -111,7 +149,7 @@ public Builder withCollectionSchema(@NonNull CreateCollectionReq.CollectionSchem * @param remotePath remote path * @return Builder */ - public Builder withRemotePath(@NonNull String remotePath) { + public Builder withRemotePath(String remotePath) { this.remotePath = remotePath; return this; } @@ -121,7 +159,7 @@ public Builder withChunkSize(long chunkSize) { return this; } - public Builder withFileType(@NonNull BulkFileType fileType) { + public Builder withFileType(BulkFileType fileType) { this.fileType = fileType; return this; } @@ -131,17 +169,17 @@ public Builder withConfig(String key, Object val) { return this; } - public Builder withCloudEndpoint(@NotNull String cloudEndpoint) { + public Builder withCloudEndpoint(String cloudEndpoint) { this.cloudEndpoint = cloudEndpoint; return this; } - public Builder withApiKey(@NotNull String apiKey) { + public Builder withApiKey(String apiKey) { this.apiKey = apiKey; return this; } - public Builder withStageName(@NotNull String stageName) { + public Builder withStageName(String stageName) { this.stageName = stageName; return this; } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageFileManager.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageFileManager.java index 4311e7fce..9aec466a9 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageFileManager.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageFileManager.java @@ -42,12 +42,7 @@ import java.time.Instant; import java.util.Date; import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; @@ -131,12 +126,12 @@ public CompletableFuture uploadFilesAsync(UploadFilesRequest * tasks to complete within a timeout period. If tasks do not finish within * the timeout, it will forcefully shut down the executor. *

- * + *

* Usage recommendation: *

    *
  • Call this method when the StageFileManager is no longer needed.
  • *
- * + *

* Thread interruption is respected, and the interrupt status is restored if interrupted during shutdown. */ public void shutdownGracefully() { diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageFileManagerParam.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageFileManagerParam.java index 8cb0b623e..c64b4873d 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageFileManagerParam.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageFileManagerParam.java @@ -22,29 +22,48 @@ import io.milvus.bulkwriter.common.clientenum.ConnectType; import io.milvus.exception.ParamException; import io.milvus.param.ParamUtils; -import lombok.Getter; -import lombok.NonNull; -import lombok.ToString; -import org.jetbrains.annotations.NotNull; /** * Parameters for stageFileManager interface. */ -@Getter -@ToString public class StageFileManagerParam { private final String cloudEndpoint; private final String apiKey; private final String stageName; private final ConnectType connectType; - private StageFileManagerParam(@NonNull Builder builder) { + private StageFileManagerParam(Builder builder) { this.cloudEndpoint = builder.cloudEndpoint; this.apiKey = builder.apiKey; this.stageName = builder.stageName; this.connectType = builder.connectType; } + public String getCloudEndpoint() { + return cloudEndpoint; + } + + public String getApiKey() { + return apiKey; + } + + public String getStageName() { + return stageName; + } + + public ConnectType getConnectType() { + return connectType; + } + + @Override + public String toString() { + return "StageFileManagerParam{" + + "cloudEndpoint='" + cloudEndpoint + '\'' + + ", stageName='" + stageName + '\'' + + ", connectType=" + connectType + + '}'; + } + public static Builder newBuilder() { return new Builder(); } @@ -69,17 +88,17 @@ private Builder() { * For overseas regions, it is: https://api.cloud.zilliz.com * For regions in China, it is: https://api.cloud.zilliz.com.cn */ - public Builder withCloudEndpoint(@NotNull String cloudEndpoint) { + public Builder withCloudEndpoint(String cloudEndpoint) { this.cloudEndpoint = cloudEndpoint; return this; } - public Builder withApiKey(@NotNull String apiKey) { + public Builder withApiKey(String apiKey) { this.apiKey = apiKey; return this; } - public Builder withStageName(@NotNull String stageName) { + public Builder withStageName(String stageName) { this.stageName = stageName; return this; } @@ -90,7 +109,7 @@ public Builder withStageName(@NotNull String stageName) { * otherwise, the public endpoint will be used. * You can also force the use of either the internal or public endpoint. */ - public Builder withConnectType(@NotNull ConnectType connectType) { + public Builder withConnectType(ConnectType connectType) { this.connectType = connectType; return this; } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageManagerParam.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageManagerParam.java index 0145499d7..8dbb8e2f8 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageManagerParam.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/StageManagerParam.java @@ -21,25 +21,34 @@ import io.milvus.exception.ParamException; import io.milvus.param.ParamUtils; -import lombok.Getter; -import lombok.NonNull; -import lombok.ToString; -import org.jetbrains.annotations.NotNull; /** * Parameters for stageManager interface. */ -@Getter -@ToString public class StageManagerParam { private final String cloudEndpoint; private final String apiKey; - private StageManagerParam(@NonNull Builder builder) { + private StageManagerParam(Builder builder) { this.cloudEndpoint = builder.cloudEndpoint; this.apiKey = builder.apiKey; } + public String getCloudEndpoint() { + return cloudEndpoint; + } + + public String getApiKey() { + return apiKey; + } + + @Override + public String toString() { + return "StageManagerParam{" + + "cloudEndpoint='" + cloudEndpoint + '\'' + + '}'; + } + public static Builder newBuilder() { return new Builder(); } @@ -60,12 +69,12 @@ private Builder() { * For overseas regions, it is: https://api.cloud.zilliz.com * For regions in China, it is: https://api.cloud.zilliz.com.cn */ - public Builder withCloudEndpoint(@NotNull String cloudEndpoint) { + public Builder withCloudEndpoint(String cloudEndpoint) { this.cloudEndpoint = cloudEndpoint; return this; } - public Builder withApiKey(@NotNull String apiKey) { + public Builder withApiKey(String apiKey) { this.apiKey = apiKey; return this; } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/clientenum/BulkFileType.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/clientenum/BulkFileType.java index 728fb1871..86ed78cd1 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/clientenum/BulkFileType.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/clientenum/BulkFileType.java @@ -19,20 +19,25 @@ package io.milvus.bulkwriter.common.clientenum; -import lombok.Getter; - -@Getter public enum BulkFileType { PARQUET(1, ".parquet"), JSON(2, ".json"), CSV(3, ".csv"), ; - private Integer code; - private String suffix; + private final Integer code; + private final String suffix; BulkFileType(Integer code, String suffix) { this.code = code; this.suffix = suffix; } + + public Integer getCode() { + return code; + } + + public String getSuffix() { + return suffix; + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/clientenum/CloudStorage.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/clientenum/CloudStorage.java index 2aba4216a..0a896cc5c 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/clientenum/CloudStorage.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/clientenum/CloudStorage.java @@ -20,35 +20,32 @@ package io.milvus.bulkwriter.common.clientenum; import io.milvus.exception.ParamException; -import lombok.Getter; import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.util.Lists; import java.util.List; public enum CloudStorage { - MINIO("minio","%s", "minioAddress"), - AWS("aws","s3.amazonaws.com", null), - GCP("gcp" ,"storage.googleapis.com", null), + MINIO("minio", "%s", "minioAddress"), + AWS("aws", "s3.amazonaws.com", null), + GCP("gcp", "storage.googleapis.com", null), - AZ("az" ,"%s.blob.core.windows.net", "accountName"), - AZURE("azure" ,"%s.blob.core.windows.net", "accountName"), + AZ("az", "%s.blob.core.windows.net", "accountName"), + AZURE("azure", "%s.blob.core.windows.net", "accountName"), - ALI("ali","oss-%s.aliyuncs.com", "region"), - ALIYUN("aliyun","oss-%s.aliyuncs.com", "region"), - ALIBABA("alibaba","oss-%s.aliyuncs.com", "region"), - ALICLOU("alicloud","oss-%s.aliyuncs.com", "region"), + ALI("ali", "oss-%s.aliyuncs.com", "region"), + ALIYUN("aliyun", "oss-%s.aliyuncs.com", "region"), + ALIBABA("alibaba", "oss-%s.aliyuncs.com", "region"), + ALICLOU("alicloud", "oss-%s.aliyuncs.com", "region"), - TC("tc","cos.%s.myqcloud.com", "region"), - TENCENT("tencent","cos.%s.myqcloud.com", "region") - ; + TC("tc", "cos.%s.myqcloud.com", "region"), + TENCENT("tencent", "cos.%s.myqcloud.com", "region"); - @Getter - private String cloudName; + private final String cloudName; - private String endpoint; + private final String endpoint; - private String replace; + private final String replace; CloudStorage(String cloudName, String endpoint, String replace) { this.cloudName = cloudName; @@ -56,6 +53,10 @@ public enum CloudStorage { this.replace = replace; } + public String getCloudName() { + return cloudName; + } + public static boolean isAliCloud(String cloudName) { List aliCloudStorages = Lists.newArrayList( CloudStorage.ALI, CloudStorage.ALIYUN, CloudStorage.ALIBABA, CloudStorage.ALICLOU @@ -87,7 +88,7 @@ public static CloudStorage getCloudStorage(String cloudName) { } public String getEndpoint(String... replaceParams) { - if (StringUtils.isEmpty(replace)) { + if (StringUtils.isEmpty(replace)) { return endpoint; } if (replaceParams.length == 0) { diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/utils/GeneratorUtils.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/utils/GeneratorUtils.java index dccb3ce1b..0b18d72bd 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/utils/GeneratorUtils.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/utils/GeneratorUtils.java @@ -72,7 +72,7 @@ public static List generatorInt32Value(int count) { public static List generatorFloatValue(int count) { List result = new ArrayList<>(); for (int i = 0; i < count; ++i) { - result.add( (float)i / 3); + result.add((float) i / 3); } return result; } @@ -80,7 +80,7 @@ public static List generatorFloatValue(int count) { public static List generatorDoubleValue(int count) { List result = new ArrayList<>(); for (int i = 0; i < count; ++i) { - result.add((double)i / 7); + result.add((double) i / 7); } return result; } @@ -135,7 +135,7 @@ public static List> generatorFloatVector(int dim, int count) { for (int i = 0; i < count; ++i) { List result = new ArrayList<>(); for (int j = 0; j < dim; ++j) { - result.add( (float)j / 3); + result.add((float) j / 3); } floatVector.add(result); } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/utils/ParquetUtils.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/utils/ParquetUtils.java index f444b4e0a..025b3d8b4 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/utils/ParquetUtils.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/utils/ParquetUtils.java @@ -19,12 +19,12 @@ package io.milvus.bulkwriter.common.utils; +import io.milvus.v2.service.collection.request.CreateCollectionReq; import org.apache.hadoop.conf.Configuration; import org.apache.parquet.schema.LogicalTypeAnnotation; import org.apache.parquet.schema.MessageType; import org.apache.parquet.schema.PrimitiveType; import org.apache.parquet.schema.Types; -import io.milvus.v2.service.collection.request.CreateCollectionReq; import java.util.List; diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/utils/V2AdapterUtils.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/utils/V2AdapterUtils.java index 6f7b0ed6c..a20ef6cf0 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/utils/V2AdapterUtils.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/common/utils/V2AdapterUtils.java @@ -19,7 +19,6 @@ package io.milvus.bulkwriter.common.utils; -import io.milvus.grpc.DataType; import io.milvus.param.collection.CollectionSchemaParam; import io.milvus.param.collection.FieldType; import io.milvus.v2.service.collection.request.CreateCollectionReq; @@ -66,7 +65,7 @@ public class V2AdapterUtils { // } private static CreateCollectionReq.FieldSchema convertV1Field(FieldType fieldType) { - Integer maxLength = fieldType.getMaxLength() > 0 ? fieldType.getMaxLength():65535; + Integer maxLength = fieldType.getMaxLength() > 0 ? fieldType.getMaxLength() : 65535; Integer dimension = fieldType.getDimension() > 0 ? fieldType.getDimension() : null; Integer maxCapacity = fieldType.getMaxCapacity() > 0 ? fieldType.getMaxCapacity() : null; io.milvus.v2.common.DataType elementType = fieldType.getElementType() == null ? null : io.milvus.v2.common.DataType.valueOf(fieldType.getElementType().name()); diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/connect/AzureConnectParam.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/connect/AzureConnectParam.java index 8546457cb..5716d6f52 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/connect/AzureConnectParam.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/connect/AzureConnectParam.java @@ -22,28 +22,49 @@ import com.azure.core.credential.TokenCredential; import io.milvus.exception.ParamException; import io.milvus.param.ParamUtils; -import lombok.Getter; -import lombok.NonNull; -import lombok.ToString; +import org.jetbrains.annotations.NotNull; /** * Parameters for RemoteBulkWriter interface. */ -@Getter -@ToString public class AzureConnectParam extends StorageConnectParam { private final String containerName; private final String connStr; private final String accountUrl; private final TokenCredential credential; - private AzureConnectParam(@NonNull Builder builder) { + private AzureConnectParam(Builder builder) { this.containerName = builder.containerName; this.connStr = builder.connStr; this.accountUrl = builder.accountUrl; this.credential = builder.credential; } + public String getContainerName() { + return containerName; + } + + public String getConnStr() { + return connStr; + } + + public String getAccountUrl() { + return accountUrl; + } + + public TokenCredential getCredential() { + return credential; + } + + @Override + public String toString() { + return "AzureConnectParam{" + + "containerName='" + containerName + '\'' + + ", connStr='" + connStr + '\'' + + ", accountUrl='" + accountUrl + '\'' + + '}'; + } + public static Builder newBuilder() { return new Builder(); } @@ -64,7 +85,7 @@ private Builder() { * @param containerName The target container name * @return Builder */ - public Builder withContainerName(@NonNull String containerName) { + public Builder withContainerName(@NotNull String containerName) { this.containerName = containerName; return this; } @@ -76,18 +97,18 @@ public Builder withContainerName(@NonNull String containerName) { * ... * @return Builder */ - public Builder withConnStr(@NonNull String connStr) { + public Builder withConnStr(@NotNull String connStr) { this.connStr = connStr; return this; } /** * @param accountUrl A string in format like "https://[storage-account].blob.core.windows.net" - * Read this link for more info: - * ... + * Read this link for more info: + * ... * @return Builder */ - public Builder withAccountUrl(@NonNull String accountUrl) { + public Builder withAccountUrl(@NotNull String accountUrl) { this.accountUrl = accountUrl; return this; } @@ -95,10 +116,10 @@ public Builder withAccountUrl(@NonNull String accountUrl) { /** * * @param credential Account access key for the account, read this link for more info: - * ... + * ... * @return Builder */ - public Builder withCredential(@NonNull TokenCredential credential) { + public Builder withCredential(@NotNull TokenCredential credential) { this.credential = credential; return this; } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/connect/S3ConnectParam.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/connect/S3ConnectParam.java index e39d84a39..afb764935 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/connect/S3ConnectParam.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/connect/S3ConnectParam.java @@ -21,17 +21,12 @@ import io.milvus.exception.ParamException; import io.milvus.param.ParamUtils; -import lombok.Getter; -import lombok.NonNull; -import lombok.ToString; import okhttp3.OkHttpClient; import org.jetbrains.annotations.NotNull; /** * Parameters for RemoteBulkWriter interface. */ -@Getter -@ToString public class S3ConnectParam extends StorageConnectParam { private final String bucketName; private final String endpoint; @@ -42,7 +37,7 @@ public class S3ConnectParam extends StorageConnectParam { private final OkHttpClient httpClient; private final String cloudName; - private S3ConnectParam(@NonNull Builder builder) { + private S3ConnectParam(@NotNull Builder builder) { this.bucketName = builder.bucketName; this.endpoint = builder.endpoint; this.accessKey = builder.accessKey; @@ -53,6 +48,51 @@ private S3ConnectParam(@NonNull Builder builder) { this.cloudName = builder.cloudName; } + public String getBucketName() { + return bucketName; + } + + public String getEndpoint() { + return endpoint; + } + + public String getAccessKey() { + return accessKey; + } + + public String getSecretKey() { + return secretKey; + } + + public String getSessionToken() { + return sessionToken; + } + + public String getRegion() { + return region; + } + + public OkHttpClient getHttpClient() { + return httpClient; + } + + public String getCloudName() { + return cloudName; + } + + @Override + public String toString() { + return "S3ConnectParam{" + + "bucketName='" + bucketName + '\'' + + ", endpoint='" + endpoint + '\'' + + ", accessKey='" + accessKey + '\'' + + ", secretKey='" + secretKey + '\'' + + ", sessionToken='" + sessionToken + '\'' + + ", region='" + region + '\'' + + ", cloudName='" + cloudName + '\'' + + '}'; + } + public static Builder newBuilder() { return new Builder(); } @@ -90,7 +130,7 @@ public Builder withCloudName(@NotNull String cloudName) { * @param bucketName bucket info * @return Builder */ - public Builder withBucketName(@NonNull String bucketName) { + public Builder withBucketName(@NotNull String bucketName) { this.bucketName = bucketName; return this; } @@ -101,32 +141,32 @@ public Builder withBucketName(@NonNull String bucketName) { * @param endpoint endpoint info * @return Builder */ - public Builder withEndpoint(@NonNull String endpoint) { + public Builder withEndpoint(@NotNull String endpoint) { this.endpoint = endpoint; return this; } - public Builder withAccessKey(@NonNull String accessKey) { + public Builder withAccessKey(@NotNull String accessKey) { this.accessKey = accessKey; return this; } - public Builder withSecretKey(@NonNull String secretKey) { + public Builder withSecretKey(@NotNull String secretKey) { this.secretKey = secretKey; return this; } - public Builder withSessionToken(@NonNull String sessionToken) { + public Builder withSessionToken(@NotNull String sessionToken) { this.sessionToken = sessionToken; return this; } - public Builder withRegion(@NonNull String region) { + public Builder withRegion(@NotNull String region) { this.region = region; return this; } - public Builder withHttpClient(@NonNull OkHttpClient httpClient) { + public Builder withHttpClient(@NotNull OkHttpClient httpClient) { this.httpClient = httpClient; return this; } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/model/CompleteMultipartUploadOutputModel.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/model/CompleteMultipartUploadOutputModel.java index 654f3c8eb..9f1a4f2bc 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/model/CompleteMultipartUploadOutputModel.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/model/CompleteMultipartUploadOutputModel.java @@ -19,7 +19,8 @@ public class CompleteMultipartUploadOutputModel { @Element(name = "ETag") private String etag; - public CompleteMultipartUploadOutputModel() {} + public CompleteMultipartUploadOutputModel() { + } public String location() { return location; diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/model/UploadFilesResult.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/model/UploadFilesResult.java index 43fe1de0f..f13ec9587 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/model/UploadFilesResult.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/model/UploadFilesResult.java @@ -1,15 +1,71 @@ package io.milvus.bulkwriter.model; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor public class UploadFilesResult { private String stageName; private String path; + + public UploadFilesResult() { + } + + public UploadFilesResult(String stageName, String path) { + this.stageName = stageName; + this.path = path; + } + + private UploadFilesResult(UploadFilesResultBuilder builder) { + this.stageName = builder.stageName; + this.path = builder.path; + } + + public String getStageName() { + return stageName; + } + + public void setStageName(String stageName) { + this.stageName = stageName; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Override + public String toString() { + return "UploadFilesResult{" + + "stageName='" + stageName + '\'' + + ", path='" + path + '\'' + + '}'; + } + + public static UploadFilesResultBuilder builder() { + return new UploadFilesResultBuilder(); + } + + public static class UploadFilesResultBuilder { + private String stageName; + private String path; + + private UploadFilesResultBuilder() { + this.stageName = ""; + this.path = ""; + } + + public UploadFilesResultBuilder stageName(String stageName) { + this.stageName = stageName; + return this; + } + + public UploadFilesResultBuilder path(String path) { + this.path = path; + return this; + } + + public UploadFilesResult build() { + return new UploadFilesResult(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/describe/BaseDescribeImportRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/describe/BaseDescribeImportRequest.java index 9fae25d6c..ee98abe80 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/describe/BaseDescribeImportRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/describe/BaseDescribeImportRequest.java @@ -19,22 +19,61 @@ package io.milvus.bulkwriter.request.describe; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - import java.io.Serializable; -@Data -@SuperBuilder(toBuilder = true) -@AllArgsConstructor -@NoArgsConstructor public class BaseDescribeImportRequest implements Serializable { private static final long serialVersionUID = -787626534606813089L; + /** * If you are calling the cloud API, this parameter should be set to your API_KEY. * If you are using Milvus directly, this parameter should be set to your userName:password. */ private String apiKey; + + public BaseDescribeImportRequest() { + } + + public BaseDescribeImportRequest(String apiKey) { + this.apiKey = apiKey; + } + + protected BaseDescribeImportRequest(BaseDescribeImportRequestBuilder builder) { + this.apiKey = builder.apiKey; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + @Override + public String toString() { + return "BaseDescribeImportRequest{" + + "apiKey='" + apiKey + '\'' + + '}'; + } + + public static BaseDescribeImportRequestBuilder builder() { + return new BaseDescribeImportRequestBuilder<>(); + } + + public static class BaseDescribeImportRequestBuilder> { + private String apiKey = ""; + + protected BaseDescribeImportRequestBuilder() { + this.apiKey = ""; + } + + public T apiKey(String apiKey) { + this.apiKey = apiKey; + return (T) this; + } + + public BaseDescribeImportRequest build() { + return new BaseDescribeImportRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/describe/CloudDescribeImportRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/describe/CloudDescribeImportRequest.java index ea15a95de..e3f49228b 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/describe/CloudDescribeImportRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/describe/CloudDescribeImportRequest.java @@ -19,17 +19,74 @@ package io.milvus.bulkwriter.request.describe; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor public class CloudDescribeImportRequest extends BaseDescribeImportRequest { private static final long serialVersionUID = -6479634844757426430L; private String clusterId; private String jobId; + + public CloudDescribeImportRequest() { + } + + public CloudDescribeImportRequest(String clusterId, String jobId) { + this.clusterId = clusterId; + this.jobId = jobId; + } + + protected CloudDescribeImportRequest(CloudDescribeImportRequestBuilder builder) { + super(builder); + this.clusterId = builder.clusterId; + this.jobId = builder.jobId; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + @Override + public String toString() { + return "CloudDescribeImportRequest{" + + "clusterId='" + clusterId + '\'' + + ", jobId='" + jobId + '\'' + + '}'; + } + + public static CloudDescribeImportRequestBuilder builder() { + return new CloudDescribeImportRequestBuilder(); + } + + public static class CloudDescribeImportRequestBuilder extends BaseDescribeImportRequestBuilder { + private String clusterId; + private String jobId; + + private CloudDescribeImportRequestBuilder() { + this.clusterId = ""; + this.jobId = ""; + } + + public CloudDescribeImportRequestBuilder clusterId(String clusterId) { + this.clusterId = clusterId; + return this; + } + + public CloudDescribeImportRequestBuilder jobId(String jobId) { + this.jobId = jobId; + return this; + } + + public CloudDescribeImportRequest build() { + return new CloudDescribeImportRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/describe/MilvusDescribeImportRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/describe/MilvusDescribeImportRequest.java index 2cfa6059e..3f8a2e1ac 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/describe/MilvusDescribeImportRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/describe/MilvusDescribeImportRequest.java @@ -19,16 +19,55 @@ package io.milvus.bulkwriter.request.describe; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor public class MilvusDescribeImportRequest extends BaseDescribeImportRequest { private static final long serialVersionUID = 6123645882882199210L; private String jobId; + + public MilvusDescribeImportRequest() { + } + + public MilvusDescribeImportRequest(String jobId) { + this.jobId = jobId; + } + + protected MilvusDescribeImportRequest(MilvusDescribeImportRequestBuilder builder) { + super(builder); + this.jobId = builder.jobId; + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + @Override + public String toString() { + return "MilvusDescribeImportRequest{" + + ", jobId='" + jobId + '\'' + + '}'; + } + + public static MilvusDescribeImportRequestBuilder builder() { + return new MilvusDescribeImportRequestBuilder(); + } + + public static class MilvusDescribeImportRequestBuilder extends BaseDescribeImportRequestBuilder { + private String jobId; + + private MilvusDescribeImportRequestBuilder() { + this.jobId = ""; + } + + public MilvusDescribeImportRequestBuilder jobId(String jobId) { + this.jobId = jobId; + return this; + } + + public MilvusDescribeImportRequest build() { + return new MilvusDescribeImportRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/BaseImportRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/BaseImportRequest.java index 99fd7e194..fc745e9b4 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/BaseImportRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/BaseImportRequest.java @@ -19,18 +19,10 @@ package io.milvus.bulkwriter.request.import_; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - import java.io.Serializable; +import java.util.HashMap; import java.util.Map; -@Data -@SuperBuilder(toBuilder = true) -@AllArgsConstructor -@NoArgsConstructor public class BaseImportRequest implements Serializable { private static final long serialVersionUID = 8192049841043084620L; /** @@ -40,4 +32,69 @@ public class BaseImportRequest implements Serializable { private String apiKey; private Map options; + + public BaseImportRequest() { + } + + public BaseImportRequest(String apiKey, Map options) { + this.apiKey = apiKey; + this.options = options; + } + + protected BaseImportRequest(BaseImportRequestBuilder builder) { + this.apiKey = builder.apiKey; + this.options = builder.options; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public Map getOptions() { + return options; + } + + public void setOptions(Map options) { + this.options = options; + } + + @Override + public String toString() { + return "BaseImportRequest{" + + "apiKey='" + apiKey + '\'' + + "options=" + options + + '}'; + } + + public static BaseImportRequestBuilder builder() { + return new BaseImportRequestBuilder<>(); + } + + public static class BaseImportRequestBuilder> { + private String apiKey = ""; + private Map options; + + protected BaseImportRequestBuilder() { + this.apiKey = ""; + this.options = new HashMap<>(); + } + + public T apiKey(String apiKey) { + this.apiKey = apiKey; + return (T) this; + } + + public T options(Map options) { + this.options = options; + return (T) this; + } + + public BaseImportRequest build() { + return new BaseImportRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/CloudImportRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/CloudImportRequest.java index 0fd2819d6..0574a0e55 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/CloudImportRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/CloudImportRequest.java @@ -19,17 +19,9 @@ package io.milvus.bulkwriter.request.import_; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - +import java.util.ArrayList; import java.util.List; -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor /* If you want to import data into a Zilliz cloud instance and your data is stored in a storage bucket, you can use this method to import the data from the bucket. @@ -47,10 +39,10 @@ public class CloudImportRequest extends BaseImportRequest { /** * If the collection has partitionKey enabled: - * - The partitionName parameter cannot be specified for import. + * - The partitionName parameter cannot be specified for import. * If the collection does not have partitionKey enabled: - * - You may specify partitionName for the import. - * - Defaults to the "default" partition if not specified. + * - You may specify partitionName for the import. + * - Defaults to the "default" partition if not specified. */ private String partitionName; @@ -58,21 +50,21 @@ public class CloudImportRequest extends BaseImportRequest { * Data import can be configured in multiple ways using `objectUrls`: *

* 1. Multi-path import (multiple folders or files): - * "objectUrls": [ - * ["s3://bucket-name/parquet-folder-1/1.parquet"], - * ["s3://bucket-name/parquet-folder-2/1.parquet"], - * ["s3://bucket-name/parquet-folder-3/"] - * ] + * "objectUrls": [ + * ["s3://bucket-name/parquet-folder-1/1.parquet"], + * ["s3://bucket-name/parquet-folder-2/1.parquet"], + * ["s3://bucket-name/parquet-folder-3/"] + * ] *

* 2. Folder import: - * "objectUrls": [ - * ["s3://bucket-name/parquet-folder/"] - * ] + * "objectUrls": [ + * ["s3://bucket-name/parquet-folder/"] + * ] *

* 3. Single file import: - * "objectUrls": [ - * ["s3://bucket-name/parquet-folder/1.parquet"] - * ] + * "objectUrls": [ + * ["s3://bucket-name/parquet-folder/1.parquet"] + * ] */ private List> objectUrls; @@ -80,20 +72,218 @@ public class CloudImportRequest extends BaseImportRequest { * Use `objectUrls` instead for more flexible multi-path configuration. *

* Folder import: - * "objectUrl": "s3://bucket-name/parquet-folder/" + * "objectUrl": "s3://bucket-name/parquet-folder/" *

* File import: - * "objectUrl": "s3://bucket-name/parquet-folder/1.parquet" + * "objectUrl": "s3://bucket-name/parquet-folder/1.parquet" */ @Deprecated private String objectUrl; - /** Specify `accessKey` and `secretKey`; for short-term credentials, also include `token`. */ + /** + * Specify `accessKey` and `secretKey`; for short-term credentials, also include `token`. + */ private String accessKey; - /** Specify `accessKey` and `secretKey`; for short-term credentials, also include `token`. */ + /** + * Specify `accessKey` and `secretKey`; for short-term credentials, also include `token`. + */ private String secretKey; - /** Specify `accessKey` and `secretKey`; for short-term credentials, also include `token`. */ + /** + * Specify `accessKey` and `secretKey`; for short-term credentials, also include `token`. + */ private String token; + + public CloudImportRequest() { + } + + public CloudImportRequest(String clusterId, String dbName, String collectionName, String partitionName, + List> objectUrls, String accessKey, String secretKey, String token) { + this.clusterId = clusterId; + this.dbName = dbName; + this.collectionName = collectionName; + this.partitionName = partitionName; + this.objectUrls = objectUrls; + this.accessKey = accessKey; + this.secretKey = secretKey; + this.token = token; + } + + protected CloudImportRequest(CloudImportRequestBuilder builder) { + super(builder); + this.clusterId = builder.clusterId; + this.dbName = builder.dbName; + this.collectionName = builder.collectionName; + this.partitionName = builder.partitionName; + this.objectUrls = builder.objectUrls; + this.objectUrl = builder.objectUrl; + this.accessKey = builder.accessKey; + this.secretKey = builder.secretKey; + this.token = builder.token; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getDbName() { + return dbName; + } + + public void setDbName(String dbName) { + this.dbName = dbName; + } + + public String getCollectionName() { + return collectionName; + } + + public void setCollectionName(String collectionName) { + this.collectionName = collectionName; + } + + public String getPartitionName() { + return partitionName; + } + + public void setPartitionName(String partitionName) { + this.partitionName = partitionName; + } + + public List> getObjectUrls() { + return objectUrls; + } + + public void setObjectUrls(List> objectUrls) { + this.objectUrls = objectUrls; + } + + public String getObjectUrl() { + return objectUrl; + } + + public void setObjectUrl(String objectUrl) { + this.objectUrl = objectUrl; + } + + public String getAccessKey() { + return accessKey; + } + + public void setAccessKey(String accessKey) { + this.accessKey = accessKey; + } + + public String getSecretKey() { + return secretKey; + } + + public void setSecretKey(String secretKey) { + this.secretKey = secretKey; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + @Override + public String toString() { + return "CloudImportRequest{" + + "clusterId='" + clusterId + '\'' + + ", dbName='" + dbName + '\'' + + ", collectionName='" + collectionName + '\'' + + ", partitionName='" + partitionName + '\'' + + ", objectUrls=" + objectUrls + + ", objectUrl='" + objectUrl + '\'' + + ", accessKey='" + accessKey + '\'' + + ", secretKey='" + secretKey + '\'' + + ", token='" + token + '\'' + + '}'; + } + + public static CloudImportRequestBuilder builder() { + return new CloudImportRequestBuilder(); + } + + public static class CloudImportRequestBuilder extends BaseImportRequestBuilder { + private String clusterId; + private String dbName; + private String collectionName; + private String partitionName; + private List> objectUrls; + private String objectUrl; + private String accessKey; + private String secretKey; + private String token; + + private CloudImportRequestBuilder() { + this.clusterId = ""; + this.dbName = ""; + this.collectionName = ""; + this.partitionName = ""; + this.objectUrls = new ArrayList<>(); + this.objectUrl = ""; + this.accessKey = ""; + this.secretKey = ""; + this.token = ""; + } + + public CloudImportRequestBuilder clusterId(String clusterId) { + this.clusterId = clusterId; + return this; + } + + public CloudImportRequestBuilder dbName(String dbName) { + this.dbName = dbName; + return this; + } + + public CloudImportRequestBuilder collectionName(String collectionName) { + this.collectionName = collectionName; + return this; + } + + public CloudImportRequestBuilder partitionName(String partitionName) { + this.partitionName = partitionName; + return this; + } + + public CloudImportRequestBuilder objectUrls(List> objectUrls) { + this.objectUrls = objectUrls; + return this; + } + + public CloudImportRequestBuilder objectUrl(String objectUrl) { + this.objectUrl = objectUrl; + return this; + } + + public CloudImportRequestBuilder accessKey(String accessKey) { + this.accessKey = accessKey; + return this; + } + + public CloudImportRequestBuilder secretKey(String secretKey) { + this.secretKey = secretKey; + return this; + } + + public CloudImportRequestBuilder token(String token) { + this.token = token; + return this; + } + + public CloudImportRequest build() { + return new CloudImportRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/MilvusImportRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/MilvusImportRequest.java index 7149fbfe5..0cc5ae95a 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/MilvusImportRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/MilvusImportRequest.java @@ -19,17 +19,9 @@ package io.milvus.bulkwriter.request.import_; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - +import java.util.ArrayList; import java.util.List; -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor /* If you want to import data into open-source Milvus, you can use this method to import the data files stored in the bucket where Milvus resides. @@ -45,10 +37,10 @@ public class MilvusImportRequest extends BaseImportRequest { /** * If the collection has partitionKey enabled: - * - The partitionName parameter cannot be specified for import. + * - The partitionName parameter cannot be specified for import. * If the collection does not have partitionKey enabled: - * - You may specify partitionName for the import. - * - Defaults to the "default" partition if not specified. + * - You may specify partitionName for the import. + * - Defaults to the "default" partition if not specified. */ private String partitionName; @@ -56,16 +48,118 @@ public class MilvusImportRequest extends BaseImportRequest { * Data import can be configured in multiple ways using `files`: *

* 1. Multi-path import (multiple files): - * "files": [ - * ["parquet-folder-1/1.parquet"], - * ["parquet-folder-2/1.parquet"], - * ["parquet-folder-3/1.parquet"] - * ] + * "files": [ + * ["parquet-folder-1/1.parquet"], + * ["parquet-folder-2/1.parquet"], + * ["parquet-folder-3/1.parquet"] + * ] *

* 2. Single file import: - * "files": [ - * ["parquet-folder/1.parquet"] - * ] + * "files": [ + * ["parquet-folder/1.parquet"] + * ] */ private List> files; + + public MilvusImportRequest() { + } + + public MilvusImportRequest(String dbName, String collectionName, String partitionName, List> files) { + this.dbName = dbName; + this.collectionName = collectionName; + this.partitionName = partitionName; + this.files = files; + } + + protected MilvusImportRequest(MilvusImportRequestBuilder builder) { + super(builder); + this.dbName = builder.dbName; + this.collectionName = builder.collectionName; + this.partitionName = builder.partitionName; + this.files = builder.files; + } + + public String getDbName() { + return dbName; + } + + public void setDbName(String dbName) { + this.dbName = dbName; + } + + public String getCollectionName() { + return collectionName; + } + + public void setCollectionName(String collectionName) { + this.collectionName = collectionName; + } + + public String getPartitionName() { + return partitionName; + } + + public void setPartitionName(String partitionName) { + this.partitionName = partitionName; + } + + public List> getFiles() { + return files; + } + + public void setFiles(List> files) { + this.files = files; + } + + @Override + public String toString() { + return "MilvusImportRequest{" + + "dbName='" + dbName + '\'' + + ", collectionName='" + collectionName + '\'' + + ", partitionName='" + partitionName + '\'' + + ", files=" + files + + '}'; + } + + public static MilvusImportRequestBuilder builder() { + return new MilvusImportRequestBuilder(); + } + + public static class MilvusImportRequestBuilder extends BaseImportRequestBuilder { + private String dbName; + private String collectionName; + private String partitionName; + private List> files; + + private MilvusImportRequestBuilder() { + this.dbName = ""; + this.collectionName = ""; + this.partitionName = ""; + this.files = new ArrayList<>(); + } + + public MilvusImportRequestBuilder dbName(String dbName) { + this.dbName = dbName; + return this; + } + + public MilvusImportRequestBuilder collectionName(String collectionName) { + this.collectionName = collectionName; + return this; + } + + public MilvusImportRequestBuilder partitionName(String partitionName) { + this.partitionName = partitionName; + return this; + } + + public MilvusImportRequestBuilder files(List> files) { + this.files = files; + return this; + } + + public MilvusImportRequest build() { + return new MilvusImportRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/StageImportRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/StageImportRequest.java index 6a2215f52..e192bc3d7 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/StageImportRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/import_/StageImportRequest.java @@ -19,17 +19,9 @@ package io.milvus.bulkwriter.request.import_; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - +import java.util.ArrayList; import java.util.List; -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor /* If you want to import data into a Zilliz cloud instance and your data is stored in a Zilliz stage, you can use this method to import the data from the stage. @@ -46,10 +38,10 @@ public class StageImportRequest extends BaseImportRequest { /** * If the collection has partitionKey enabled: - * - The partitionName parameter cannot be specified for import. + * - The partitionName parameter cannot be specified for import. * If the collection does not have partitionKey enabled: - * - You may specify partitionName for the import. - * - Defaults to the "default" partition if not specified. + * - You may specify partitionName for the import. + * - Defaults to the "default" partition if not specified. */ private String partitionName; @@ -59,21 +51,160 @@ public class StageImportRequest extends BaseImportRequest { * Data import can be configured in multiple ways using `dataPaths`: *

* 1. Multi-path import (multiple folders or files): - * "dataPaths": [ - * ["parquet-folder-1/1.parquet"], - * ["parquet-folder-2/1.parquet"], - * ["parquet-folder-3/"] - * ] + * "dataPaths": [ + * ["parquet-folder-1/1.parquet"], + * ["parquet-folder-2/1.parquet"], + * ["parquet-folder-3/"] + * ] *

* 2. Folder import: - * "dataPaths": [ - * ["parquet-folder/"] - * ] + * "dataPaths": [ + * ["parquet-folder/"] + * ] *

* 3. Single file import: - * "dataPaths": [ - * ["parquet-folder/1.parquet"] - * ] + * "dataPaths": [ + * ["parquet-folder/1.parquet"] + * ] */ private List> dataPaths; + + public StageImportRequest() { + } + + public StageImportRequest(String clusterId, String dbName, String collectionName, String partitionName, + String stageName, List> dataPaths) { + this.clusterId = clusterId; + this.dbName = dbName; + this.collectionName = collectionName; + this.partitionName = partitionName; + this.stageName = stageName; + this.dataPaths = dataPaths; + } + + protected StageImportRequest(StageImportRequestBuilder builder) { + super(builder); + this.clusterId = builder.clusterId; + this.dbName = builder.dbName; + this.collectionName = builder.collectionName; + this.partitionName = builder.partitionName; + this.stageName = builder.stageName; + this.dataPaths = builder.dataPaths; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getDbName() { + return dbName; + } + + public void setDbName(String dbName) { + this.dbName = dbName; + } + + public String getCollectionName() { + return collectionName; + } + + public void setCollectionName(String collectionName) { + this.collectionName = collectionName; + } + + public String getPartitionName() { + return partitionName; + } + + public void setPartitionName(String partitionName) { + this.partitionName = partitionName; + } + + public String getStageName() { + return stageName; + } + + public void setStageName(String stageName) { + this.stageName = stageName; + } + + public List> getDataPaths() { + return dataPaths; + } + + public void setDataPaths(List> dataPaths) { + this.dataPaths = dataPaths; + } + + @Override + public String toString() { + return "StageImportRequest{" + + "clusterId='" + clusterId + '\'' + + ", dbName='" + dbName + '\'' + + ", collectionName='" + collectionName + '\'' + + ", partitionName='" + partitionName + '\'' + + ", stageName='" + stageName + '\'' + + ", dataPaths=" + dataPaths + + '}'; + } + + public static StageImportRequestBuilder builder() { + return new StageImportRequestBuilder(); + } + + public static class StageImportRequestBuilder extends BaseImportRequestBuilder { + private String clusterId; + private String dbName; + private String collectionName; + private String partitionName; + private String stageName; + private List> dataPaths; + + private StageImportRequestBuilder() { + this.clusterId = ""; + this.dbName = ""; + this.collectionName = ""; + this.partitionName = ""; + this.stageName = ""; + this.dataPaths = new ArrayList<>(); + } + + public StageImportRequestBuilder clusterId(String clusterId) { + this.clusterId = clusterId; + return this; + } + + public StageImportRequestBuilder dbName(String dbName) { + this.dbName = dbName; + return this; + } + + public StageImportRequestBuilder collectionName(String collectionName) { + this.collectionName = collectionName; + return this; + } + + public StageImportRequestBuilder partitionName(String partitionName) { + this.partitionName = partitionName; + return this; + } + + public StageImportRequestBuilder stageName(String stageName) { + this.stageName = stageName; + return this; + } + + public StageImportRequestBuilder dataPaths(List> dataPaths) { + this.dataPaths = dataPaths; + return this; + } + + public StageImportRequest build() { + return new StageImportRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/list/BaseListImportJobsRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/list/BaseListImportJobsRequest.java index d2e8101e2..c6cff72d9 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/list/BaseListImportJobsRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/list/BaseListImportJobsRequest.java @@ -19,18 +19,8 @@ package io.milvus.bulkwriter.request.list; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - import java.io.Serializable; - -@Data -@SuperBuilder(toBuilder = true) -@AllArgsConstructor -@NoArgsConstructor public class BaseListImportJobsRequest implements Serializable { private static final long serialVersionUID = -1890380396466908530L; /** @@ -38,4 +28,51 @@ public class BaseListImportJobsRequest implements Serializable { * If you are using Milvus directly, this parameter should be set to your userName:password. */ private String apiKey; + + protected BaseListImportJobsRequest() { + } + + protected BaseListImportJobsRequest(String apiKey) { + this.apiKey = apiKey; + } + + protected BaseListImportJobsRequest(BaseListImportJobsRequestBuilder builder) { + this.apiKey = builder.apiKey; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + @Override + public String toString() { + return "BaseListImportJobsRequest{" + + "apiKey='" + apiKey + '\'' + + '}'; + } + + public static BaseListImportJobsRequestBuilder builder() { + return new BaseListImportJobsRequestBuilder<>(); + } + + public static class BaseListImportJobsRequestBuilder> { + private String apiKey = ""; + + protected BaseListImportJobsRequestBuilder() { + this.apiKey = ""; + } + + public T apiKey(String apiKey) { + this.apiKey = apiKey; + return (T) this; + } + + public BaseListImportJobsRequest build() { + return new BaseListImportJobsRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/list/CloudListImportJobsRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/list/CloudListImportJobsRequest.java index e614dfb51..a03608b5c 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/list/CloudListImportJobsRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/list/CloudListImportJobsRequest.java @@ -19,18 +19,93 @@ package io.milvus.bulkwriter.request.list; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor public class CloudListImportJobsRequest extends BaseListImportJobsRequest { private static final long serialVersionUID = -3380786382584854649L; private String clusterId; private Integer pageSize; private Integer currentPage; + + protected CloudListImportJobsRequest() { + } + + protected CloudListImportJobsRequest(String clusterId, Integer pageSize, Integer currentPage) { + this.clusterId = clusterId; + this.pageSize = pageSize; + this.currentPage = currentPage; + } + + protected CloudListImportJobsRequest(CloudListImportJobsRequestBuilder builder) { + super(builder); + this.clusterId = builder.clusterId; + this.pageSize = builder.pageSize; + this.currentPage = builder.currentPage; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Integer getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(Integer currentPage) { + this.currentPage = currentPage; + } + + @Override + public String toString() { + return "CloudListImportJobsRequest{" + + "clusterId='" + clusterId + '\'' + + "pageSize=" + pageSize + + "currentPage=" + currentPage + + '}'; + } + + public static CloudListImportJobsRequestBuilder builder() { + return new CloudListImportJobsRequestBuilder(); + } + + public static class CloudListImportJobsRequestBuilder extends BaseListImportJobsRequestBuilder { + private String clusterId; + private Integer pageSize; + private Integer currentPage; + + private CloudListImportJobsRequestBuilder() { + this.clusterId = ""; + this.pageSize = 0; + this.currentPage = 0; + } + + public CloudListImportJobsRequestBuilder clusterId(String clusterId) { + this.clusterId = clusterId; + return this; + } + + public CloudListImportJobsRequestBuilder pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + public CloudListImportJobsRequestBuilder currentPage(Integer currentPage) { + this.currentPage = currentPage; + return this; + } + + public CloudListImportJobsRequest build() { + return new CloudListImportJobsRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/list/MilvusListImportJobsRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/list/MilvusListImportJobsRequest.java index 4cb4bb935..fd6a7aef8 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/list/MilvusListImportJobsRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/list/MilvusListImportJobsRequest.java @@ -19,16 +19,55 @@ package io.milvus.bulkwriter.request.list; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor public class MilvusListImportJobsRequest extends BaseListImportJobsRequest { private static final long serialVersionUID = 8957739122547766268L; private String collectionName; + + protected MilvusListImportJobsRequest() { + } + + protected MilvusListImportJobsRequest(String collectionName) { + this.collectionName = collectionName; + } + + protected MilvusListImportJobsRequest(MilvusListImportJobsRequestBuilder builder) { + super(builder); + this.collectionName = builder.collectionName; + } + + public String getCollectionName() { + return collectionName; + } + + public void setCollectionName(String collectionName) { + this.collectionName = collectionName; + } + + @Override + public String toString() { + return "MilvusListImportJobsRequest{" + + "collectionName='" + collectionName + '\'' + + '}'; + } + + public static MilvusListImportJobsRequestBuilder builder() { + return new MilvusListImportJobsRequestBuilder(); + } + + public static class MilvusListImportJobsRequestBuilder extends BaseListImportJobsRequestBuilder { + private String collectionName; + + private MilvusListImportJobsRequestBuilder() { + this.collectionName = ""; + } + + public MilvusListImportJobsRequestBuilder collectionName(String collectionName) { + this.collectionName = collectionName; + return this; + } + + public MilvusListImportJobsRequest build() { + return new MilvusListImportJobsRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ApplyStageRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ApplyStageRequest.java index 8ddeba45c..332c56150 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ApplyStageRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ApplyStageRequest.java @@ -19,16 +19,73 @@ package io.milvus.bulkwriter.request.stage; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor public class ApplyStageRequest extends BaseStageRequest { private String stageName; private String path; + + protected ApplyStageRequest() { + } + + protected ApplyStageRequest(String stageName, String path) { + this.stageName = stageName; + this.path = path; + } + + protected ApplyStageRequest(ApplyStageRequestBuilder builder) { + super(builder); + this.stageName = builder.stageName; + this.path = builder.path; + } + + public String getStageName() { + return stageName; + } + + public void setStageName(String stageName) { + this.stageName = stageName; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Override + public String toString() { + return "ApplyStageRequest{" + + "stageName='" + stageName + '\'' + + ", path='" + path + '\'' + + '}'; + } + + public static ApplyStageRequestBuilder builder() { + return new ApplyStageRequestBuilder(); + } + + public static class ApplyStageRequestBuilder extends BaseStageRequestBuilder { + private String stageName; + private String path; + + private ApplyStageRequestBuilder() { + this.stageName = ""; + this.path = ""; + } + + public ApplyStageRequestBuilder stageName(String stageName) { + this.stageName = stageName; + return this; + } + + public ApplyStageRequestBuilder path(String path) { + this.path = path; + return this; + } + + public ApplyStageRequest build() { + return new ApplyStageRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/BaseStageRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/BaseStageRequest.java index a0f732eac..05877b62f 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/BaseStageRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/BaseStageRequest.java @@ -19,24 +19,80 @@ package io.milvus.bulkwriter.request.stage; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - import java.io.Serializable; +import java.util.HashMap; import java.util.Map; -@Data -@SuperBuilder(toBuilder = true) -@AllArgsConstructor -@NoArgsConstructor public class BaseStageRequest implements Serializable { private static final long serialVersionUID = 8192049841043084620L; /** * If you are calling the cloud API, this parameter needs to be filled in; otherwise, you can ignore it. */ private String apiKey; - private Map options; + + protected BaseStageRequest() { + } + + protected BaseStageRequest(String apiKey, Map options) { + this.apiKey = apiKey; + this.options = options; + } + + protected BaseStageRequest(BaseStageRequestBuilder builder) { + this.apiKey = builder.apiKey; + this.options = builder.options; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public Map getOptions() { + return options; + } + + public void setOptions(Map options) { + this.options = options; + } + + @Override + public String toString() { + return "BaseStageRequest{" + + "apiKey='" + apiKey + '\'' + + "options=" + options + + '}'; + } + + public static BaseStageRequestBuilder builder() { + return new BaseStageRequestBuilder<>(); + } + + public static class BaseStageRequestBuilder> { + private String apiKey; + private Map options; + + protected BaseStageRequestBuilder() { + this.apiKey = ""; + this.options = new HashMap<>(); + } + + public T apiKey(String apiKey) { + this.apiKey = apiKey; + return (T) this; + } + + public T options(Map options) { + this.options = options; + return (T) this; + } + + public BaseStageRequest build() { + return new BaseStageRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/CreateStageRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/CreateStageRequest.java index 9420ea13b..2ea8b11a9 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/CreateStageRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/CreateStageRequest.java @@ -19,17 +19,91 @@ package io.milvus.bulkwriter.request.stage; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor public class CreateStageRequest { private String projectId; private String regionId; private String stageName; + + public CreateStageRequest() { + } + + public CreateStageRequest(String projectId, String regionId, String stageName) { + this.projectId = projectId; + this.regionId = regionId; + this.stageName = stageName; + } + + protected CreateStageRequest(CreateStageRequestBuilder builder) { + this.projectId = builder.projectId; + this.regionId = builder.regionId; + this.stageName = builder.stageName; + } + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public String getRegionId() { + return regionId; + } + + public void setRegionId(String regionId) { + this.regionId = regionId; + } + + public String getStageName() { + return stageName; + } + + public void setStageName(String stageName) { + this.stageName = stageName; + } + + @Override + public String toString() { + return "CreateStageRequest{" + + "projectId='" + projectId + '\'' + + ", regionId='" + regionId + '\'' + + ", stageName='" + stageName + '\'' + + '}'; + } + + public static CreateStageRequestBuilder builder() { + return new CreateStageRequestBuilder(); + } + + public static class CreateStageRequestBuilder { + private String projectId; + private String regionId; + private String stageName; + + private CreateStageRequestBuilder() { + this.projectId = ""; + this.regionId = ""; + this.stageName = ""; + } + + public CreateStageRequestBuilder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + public CreateStageRequestBuilder regionId(String regionId) { + this.regionId = regionId; + return this; + } + + public CreateStageRequestBuilder stageName(String stageName) { + this.stageName = stageName; + return this; + } + + public CreateStageRequest build() { + return new CreateStageRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/DeleteStageRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/DeleteStageRequest.java index f90d3d19c..330454da9 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/DeleteStageRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/DeleteStageRequest.java @@ -19,15 +19,53 @@ package io.milvus.bulkwriter.request.stage; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor public class DeleteStageRequest { private String stageName; + + public DeleteStageRequest() { + } + + public DeleteStageRequest(String stageName) { + this.stageName = stageName; + } + + protected DeleteStageRequest(DeleteStageRequestBuilder builder) { + this.stageName = builder.stageName; + } + + public String getStageName() { + return stageName; + } + + public void setStageName(String stageName) { + this.stageName = stageName; + } + + @Override + public String toString() { + return "DeleteStageRequest{" + + "stageName='" + stageName + '\'' + + '}'; + } + + public static DeleteStageRequestBuilder builder() { + return new DeleteStageRequestBuilder(); + } + + public static class DeleteStageRequestBuilder { + private String stageName; + + private DeleteStageRequestBuilder() { + this.stageName = ""; + } + + public DeleteStageRequestBuilder stageName(String stageName) { + this.stageName = stageName; + return this; + } + + public DeleteStageRequest build() { + return new DeleteStageRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ListStagesRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ListStagesRequest.java index 6b24cd60e..9aa4b8a0f 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ListStagesRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/ListStagesRequest.java @@ -19,17 +19,92 @@ package io.milvus.bulkwriter.request.stage; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor + public class ListStagesRequest { private String projectId; private Integer pageSize; private Integer currentPage; + + public ListStagesRequest() { + } + + public ListStagesRequest(String projectId, Integer pageSize, Integer currentPage) { + this.projectId = projectId; + this.pageSize = pageSize; + this.currentPage = currentPage; + } + + protected ListStagesRequest(ListStagesRequestBuilder builder) { + this.projectId = builder.projectId; + this.pageSize = builder.pageSize; + this.currentPage = builder.currentPage; + } + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Integer getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(Integer currentPage) { + this.currentPage = currentPage; + } + + @Override + public String toString() { + return "ListStagesRequest{" + + "projectId='" + projectId + '\'' + + ", pageSize=" + pageSize + + ", currentPage=" + currentPage + + '}'; + } + + public static ListStagesRequestBuilder builder() { + return new ListStagesRequestBuilder(); + } + + public static class ListStagesRequestBuilder { + private String projectId; + private Integer pageSize; + private Integer currentPage; + + private ListStagesRequestBuilder() { + this.projectId = ""; + this.pageSize = 0; + this.currentPage = 0; + } + + public ListStagesRequestBuilder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + public ListStagesRequestBuilder pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + public ListStagesRequestBuilder currentPage(Integer currentPage) { + this.currentPage = currentPage; + return this; + } + + public ListStagesRequest build() { + return new ListStagesRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/UploadFilesRequest.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/UploadFilesRequest.java index d749d12d4..ed87779a3 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/UploadFilesRequest.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/stage/UploadFilesRequest.java @@ -19,15 +19,6 @@ package io.milvus.bulkwriter.request.stage; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor public class UploadFilesRequest { /** * The full path of a local file or directory: @@ -42,4 +33,69 @@ public class UploadFilesRequest { * To upload to a specific folder, end the path with a /, e.g., data/ */ private String targetStagePath; + + public UploadFilesRequest() { + } + + public UploadFilesRequest(String sourceFilePath, String targetStagePath) { + this.sourceFilePath = sourceFilePath; + this.targetStagePath = targetStagePath; + } + + protected UploadFilesRequest(UploadFilesRequestBuilder builder) { + this.sourceFilePath = builder.sourceFilePath; + this.targetStagePath = builder.targetStagePath; + } + + public String getSourceFilePath() { + return sourceFilePath; + } + + public void setSourceFilePath(String sourceFilePath) { + this.sourceFilePath = sourceFilePath; + } + + public String getTargetStagePath() { + return targetStagePath; + } + + public void setTargetStagePath(String targetStagePath) { + this.targetStagePath = targetStagePath; + } + + @Override + public String toString() { + return "UploadFilesRequest{" + + "sourceFilePath='" + sourceFilePath + '\'' + + ", targetStagePath='" + targetStagePath + '\'' + + '}'; + } + + public static UploadFilesRequestBuilder builder() { + return new UploadFilesRequestBuilder(); + } + + public static class UploadFilesRequestBuilder { + private String sourceFilePath; + private String targetStagePath; + + private UploadFilesRequestBuilder() { + this.sourceFilePath = ""; + this.targetStagePath = ""; + } + + public UploadFilesRequestBuilder sourceFilePath(String sourceFilePath) { + this.sourceFilePath = sourceFilePath; + return this; + } + + public UploadFilesRequestBuilder targetStagePath(String targetStagePath) { + this.targetStagePath = targetStagePath; + return this; + } + + public UploadFilesRequest build() { + return new UploadFilesRequest(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ApplyStageResponse.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ApplyStageResponse.java index de13d981f..b41b9fe56 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ApplyStageResponse.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ApplyStageResponse.java @@ -1,55 +1,367 @@ package io.milvus.bulkwriter.response; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - import java.io.Serializable; -@Data -@SuperBuilder -@AllArgsConstructor -@NoArgsConstructor public class ApplyStageResponse implements Serializable { private String endpoint; - private String cloud; - private String region; - private String bucketName; - private String uploadPath; - private Credentials credentials; - private Condition condition; - private String stageName; - private String stagePrefix; - @AllArgsConstructor - @NoArgsConstructor - @Data - @Builder + public ApplyStageResponse() { + } + + public ApplyStageResponse(String endpoint, String cloud, String region, String bucketName, String uploadPath, + Credentials credentials, Condition condition, String stageName, String stagePrefix) { + this.endpoint = endpoint; + this.cloud = cloud; + this.region = region; + this.bucketName = bucketName; + this.uploadPath = uploadPath; + this.credentials = credentials; + this.condition = condition; + this.stageName = stageName; + this.stagePrefix = stagePrefix; + } + + private ApplyStageResponse(ApplyStageResponseBuilder builder) { + this.endpoint = builder.endpoint; + this.cloud = builder.cloud; + this.region = builder.region; + this.bucketName = builder.bucketName; + this.uploadPath = builder.uploadPath; + this.credentials = builder.credentials; + this.condition = builder.condition; + this.stageName = builder.stageName; + this.stagePrefix = builder.stagePrefix; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public String getCloud() { + return cloud; + } + + public void setCloud(String cloud) { + this.cloud = cloud; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getBucketName() { + return bucketName; + } + + public void setBucketName(String bucketName) { + this.bucketName = bucketName; + } + + public String getUploadPath() { + return uploadPath; + } + + public void setUploadPath(String uploadPath) { + this.uploadPath = uploadPath; + } + + public Credentials getCredentials() { + return credentials; + } + + public void setCredentials(Credentials credentials) { + this.credentials = credentials; + } + + public Condition getCondition() { + return condition; + } + + public void setCondition(Condition condition) { + this.condition = condition; + } + + public String getStageName() { + return stageName; + } + + public void setStageName(String stageName) { + this.stageName = stageName; + } + + public String getStagePrefix() { + return stagePrefix; + } + + public void setStagePrefix(String stagePrefix) { + this.stagePrefix = stagePrefix; + } + + @Override + public String toString() { + return "ApplyStageResponse{" + + ", endpoint='" + endpoint + '\'' + + ", cloud='" + cloud + '\'' + + ", region='" + region + '\'' + + ", bucketName='" + bucketName + '\'' + + ", uploadPath='" + uploadPath + '\'' + + ", credentials=" + credentials + + ", condition=" + condition + + ", stageName='" + stageName + '\'' + + ", stagePrefix='" + stagePrefix + '\'' + + '}'; + } + + public static ApplyStageResponseBuilder builder() { + return new ApplyStageResponseBuilder(); + } + + public static class ApplyStageResponseBuilder { + private String endpoint; + private String cloud; + private String region; + private String bucketName; + private String uploadPath; + private Credentials credentials; + private Condition condition; + private String stageName; + private String stagePrefix; + + private ApplyStageResponseBuilder() { + this.endpoint = ""; + this.cloud = ""; + this.region = ""; + this.bucketName = ""; + this.uploadPath = ""; + this.credentials = new Credentials(); + this.condition = new Condition(); + this.stageName = ""; + this.stagePrefix = ""; + } + + public ApplyStageResponseBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + public ApplyStageResponseBuilder cloud(String cloud) { + this.cloud = cloud; + return this; + } + + public ApplyStageResponseBuilder region(String region) { + this.region = region; + return this; + } + + public ApplyStageResponseBuilder bucketName(String bucketName) { + this.bucketName = bucketName; + return this; + } + + public ApplyStageResponseBuilder uploadPath(String uploadPath) { + this.uploadPath = uploadPath; + return this; + } + + public ApplyStageResponseBuilder credentials(Credentials credentials) { + this.credentials = credentials; + return this; + } + + public ApplyStageResponseBuilder condition(Condition condition) { + this.condition = condition; + return this; + } + + public ApplyStageResponseBuilder stageName(String stageName) { + this.stageName = stageName; + return this; + } + + public ApplyStageResponseBuilder stagePrefix(String stagePrefix) { + this.stagePrefix = stagePrefix; + return this; + } + + public ApplyStageResponse build() { + return new ApplyStageResponse(this); + } + } + public static class Credentials implements Serializable { private static final long serialVersionUID = 623702599895113789L; private String tmpAK; private String tmpSK; private String sessionToken; private String expireTime; + + public Credentials() { + } + + public Credentials(String tmpAK, String tmpSK, String sessionToken, String expireTime) { + this.tmpAK = tmpAK; + this.tmpSK = tmpSK; + this.sessionToken = sessionToken; + this.expireTime = expireTime; + } + + private Credentials(CredentialsBuilder builder) { + this.tmpAK = builder.tmpAK; + this.tmpSK = builder.tmpSK; + this.sessionToken = builder.sessionToken; + this.expireTime = builder.expireTime; + } + + public String getTmpAK() { + return tmpAK; + } + + public void setTmpAK(String tmpAK) { + this.tmpAK = tmpAK; + } + + public String getTmpSK() { + return tmpSK; + } + + public void setTmpSK(String tmpSK) { + this.tmpSK = tmpSK; + } + + public String getSessionToken() { + return sessionToken; + } + + public void setSessionToken(String sessionToken) { + this.sessionToken = sessionToken; + } + + public String getExpireTime() { + return expireTime; + } + + public void setExpireTime(String expireTime) { + this.expireTime = expireTime; + } + + @Override + public String toString() { + return "Credentials{" + + ", tmpAK='" + tmpAK + '\'' + + ", expireTime='" + expireTime + '\'' + + '}'; + } + + public static CredentialsBuilder builder() { + return new CredentialsBuilder(); + } + + public static class CredentialsBuilder { + private String tmpAK; + private String tmpSK; + private String sessionToken; + private String expireTime; + + private CredentialsBuilder() { + this.tmpAK = ""; + this.tmpSK = ""; + this.sessionToken = ""; + this.expireTime = ""; + } + + public CredentialsBuilder tmpAK(String tmpAK) { + this.tmpAK = tmpAK; + return this; + } + + public CredentialsBuilder tmpSK(String tmpSK) { + this.tmpSK = tmpSK; + return this; + } + + public CredentialsBuilder sessionToken(String sessionToken) { + this.sessionToken = sessionToken; + return this; + } + + public CredentialsBuilder expireTime(String expireTime) { + this.expireTime = expireTime; + return this; + } + + public Credentials build() { + return new Credentials(this); + } + } } - @AllArgsConstructor - @NoArgsConstructor - @Data - @Builder public static class Condition implements Serializable { private static final long serialVersionUID = -2613029991242322109L; private Long maxContentLength; + + public Condition() { + } + + public Condition(Long maxContentLength) { + this.maxContentLength = maxContentLength; + } + + private Condition(ConditionBuilder builder) { + this.maxContentLength = builder.maxContentLength; + } + + public Long getMaxContentLength() { + return maxContentLength; + } + + public void setMaxContentLength(Long maxContentLength) { + this.maxContentLength = maxContentLength; + } + + @Override + public String toString() { + return "Condition{" + + ", maxContentLength=" + maxContentLength + + '}'; + } + + public static ConditionBuilder builder() { + return new ConditionBuilder(); + } + + public static class ConditionBuilder { + private Long maxContentLength; + + private ConditionBuilder() { + this.maxContentLength = 0L; + } + + public ConditionBuilder maxContentLength(Long maxContentLength) { + this.maxContentLength = maxContentLength; + return this; + } + + public Condition build() { + return new Condition(this); + } + } } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/BulkImportResponse.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/BulkImportResponse.java index ead640d16..f3af05eea 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/BulkImportResponse.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/BulkImportResponse.java @@ -19,19 +19,56 @@ package io.milvus.bulkwriter.response; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.io.Serializable; -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor public class BulkImportResponse implements Serializable { private static final long serialVersionUID = -7162743560382861611L; - private String jobId; + + public BulkImportResponse() { + } + + public BulkImportResponse(String jobId) { + this.jobId = jobId; + } + + private BulkImportResponse(BulkImportResponseBuilder builder) { + this.jobId = builder.jobId; + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + @Override + public String toString() { + return "BulkImportResponse{" + + "jobId='" + jobId + '\'' + + '}'; + } + + public static BulkImportResponseBuilder builder() { + return new BulkImportResponseBuilder(); + } + + public static class BulkImportResponseBuilder { + private String jobId; + + private BulkImportResponseBuilder() { + this.jobId = ""; + } + + public BulkImportResponseBuilder jobId(String jobId) { + this.jobId = jobId; + return this; + } + + public BulkImportResponse build() { + return new BulkImportResponse(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/GetImportProgressResponse.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/GetImportProgressResponse.java index 7444bcfb9..e6a87de71 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/GetImportProgressResponse.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/GetImportProgressResponse.java @@ -19,52 +19,377 @@ package io.milvus.bulkwriter.response; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.io.Serializable; +import java.util.ArrayList; import java.util.List; -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor public class GetImportProgressResponse implements Serializable { - private static final long serialVersionUID = -2302203037749197132L; - private String jobId; - private String collectionName; - private String fileName; - private Integer fileSize; - private String state; - private Integer progress; - private String completeTime; - private String reason; - private Integer totalRows; - private List details; - @Data - @Builder - @AllArgsConstructor - @NoArgsConstructor - private static class Detail { + public GetImportProgressResponse() { + } + + public GetImportProgressResponse(String jobId, String collectionName, String fileName, Integer fileSize, + String state, Integer progress, String completeTime, String reason, + Integer totalRows, List details) { + this.jobId = jobId; + this.collectionName = collectionName; + this.fileName = fileName; + this.fileSize = fileSize; + this.state = state; + this.progress = progress; + this.completeTime = completeTime; + this.reason = reason; + this.totalRows = totalRows; + this.details = details; + } + + private GetImportProgressResponse(GetImportProgressResponseBuilder builder) { + this.jobId = builder.jobId; + this.collectionName = builder.collectionName; + this.fileName = builder.fileName; + this.fileSize = builder.fileSize; + this.state = builder.state; + this.progress = builder.progress; + this.completeTime = builder.completeTime; + this.reason = builder.reason; + this.totalRows = builder.totalRows; + this.details = builder.details; + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public String getCollectionName() { + return collectionName; + } + + public void setCollectionName(String collectionName) { + this.collectionName = collectionName; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public Integer getFileSize() { + return fileSize; + } + + public void setFileSize(Integer fileSize) { + this.fileSize = fileSize; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public Integer getProgress() { + return progress; + } + + public void setProgress(Integer progress) { + this.progress = progress; + } + + public String getCompleteTime() { + return completeTime; + } + + public void setCompleteTime(String completeTime) { + this.completeTime = completeTime; + } + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + public Integer getTotalRows() { + return totalRows; + } + + public void setTotalRows(Integer totalRows) { + this.totalRows = totalRows; + } + + public List getDetails() { + return details; + } + + public void setDetails(List details) { + this.details = details; + } + + @Override + public String toString() { + return "GetImportProgressResponse{" + + "jobId='" + jobId + '\'' + + ", collectionName='" + collectionName + '\'' + + ", fileName='" + fileName + '\'' + + ", fileSize=" + fileSize + + ", state='" + state + '\'' + + ", progress=" + progress + + ", completeTime='" + completeTime + '\'' + + ", reason='" + reason + '\'' + + ", totalRows=" + totalRows + + ", details=" + details + + '}'; + } + + public static Detail.DetailBuilder builder() { + return new Detail.DetailBuilder(); + } + + public static class GetImportProgressResponseBuilder { + private String jobId; + private String collectionName; + private String fileName; + private Integer fileSize; + private String state; + private Integer progress; + private String completeTime; + private String reason; + private Integer totalRows; + private List details; + + private GetImportProgressResponseBuilder() { + this.jobId = ""; + this.collectionName = ""; + this.fileName = ""; + this.fileSize = 0; + this.state = ""; + this.progress = 0; + this.completeTime = ""; + this.reason = ""; + this.totalRows = 0; + this.details = new ArrayList<>(); + } + + public GetImportProgressResponseBuilder jobId(String jobId) { + this.jobId = jobId; + return this; + } + + public GetImportProgressResponseBuilder collectionName(String collectionName) { + this.collectionName = collectionName; + return this; + } + + public GetImportProgressResponseBuilder fileName(String fileName) { + this.fileName = fileName; + return this; + } + + public GetImportProgressResponseBuilder fileSize(Integer fileSize) { + this.fileSize = fileSize; + return this; + } + + public GetImportProgressResponseBuilder state(String state) { + this.state = state; + return this; + } + + public GetImportProgressResponseBuilder progress(Integer progress) { + this.progress = progress; + return this; + } + + public GetImportProgressResponseBuilder completeTime(String completeTime) { + this.completeTime = completeTime; + return this; + } + + public GetImportProgressResponseBuilder reason(String reason) { + this.reason = reason; + return this; + } + + public GetImportProgressResponseBuilder totalRows(Integer totalRows) { + this.totalRows = totalRows; + return this; + } + + public GetImportProgressResponseBuilder details(List details) { + this.details = details; + return this; + } + + public GetImportProgressResponse build() { + return new GetImportProgressResponse(this); + } + } + + public static class Detail { private String fileName; private Integer fileSize; private String state; private Integer progress; private String completeTime; private String reason; + + public Detail() { + } + + public Detail(String fileName, Integer fileSize, String state, Integer progress, String completeTime, String reason) { + this.fileName = fileName; + this.fileSize = fileSize; + this.state = state; + this.progress = progress; + this.completeTime = completeTime; + this.reason = reason; + } + + private Detail(DetailBuilder builder) { + this.fileName = builder.fileName; + this.fileSize = builder.fileSize; + this.state = builder.state; + this.progress = builder.progress; + this.completeTime = builder.completeTime; + this.reason = builder.reason; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public Integer getFileSize() { + return fileSize; + } + + public void setFileSize(Integer fileSize) { + this.fileSize = fileSize; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public Integer getProgress() { + return progress; + } + + public void setProgress(Integer progress) { + this.progress = progress; + } + + public String getCompleteTime() { + return completeTime; + } + + public void setCompleteTime(String completeTime) { + this.completeTime = completeTime; + } + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + @Override + public String toString() { + return "Detail{" + + "fileName='" + fileName + '\'' + + ", fileSize=" + fileSize + + ", state='" + state + '\'' + + ", progress=" + progress + + ", completeTime='" + completeTime + '\'' + + ", reason='" + reason + '\'' + + '}'; + } + + public static DetailBuilder builder() { + return new DetailBuilder(); + } + + public static class DetailBuilder { + private String fileName; + private Integer fileSize; + private String state; + private Integer progress; + private String completeTime; + private String reason; + + private DetailBuilder() { + this.fileName = ""; + this.fileSize = 0; + this.state = ""; + this.progress = 0; + this.completeTime = ""; + this.reason = ""; + } + + public DetailBuilder fileName(String fileName) { + this.fileName = fileName; + return this; + } + + public DetailBuilder fileSize(Integer fileSize) { + this.fileSize = fileSize; + return this; + } + + public DetailBuilder state(String state) { + this.state = state; + return this; + } + + public DetailBuilder progress(Integer progress) { + this.progress = progress; + return this; + } + + public DetailBuilder completeTime(String completeTime) { + this.completeTime = completeTime; + return this; + } + + public DetailBuilder reason(String reason) { + this.reason = reason; + return this; + } + + public Detail build() { + return new Detail(this); + } + } } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ListImportJobsResponse.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ListImportJobsResponse.java index f2e9a6558..95aed9348 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ListImportJobsResponse.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/ListImportJobsResponse.java @@ -19,27 +19,114 @@ package io.milvus.bulkwriter.response; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.io.Serializable; +import java.util.ArrayList; import java.util.List; -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor public class ListImportJobsResponse implements Serializable { - private static final long serialVersionUID = -8400893490624599225L; - private Integer count; - private Integer currentPage; - private Integer pageSize; - private List records; + + public ListImportJobsResponse() { + } + + public ListImportJobsResponse(Integer count, Integer currentPage, Integer pageSize, List records) { + this.count = count; + this.currentPage = currentPage; + this.pageSize = pageSize; + this.records = records; + } + + private ListImportJobsResponse(ListImportJobsResponseBuilder builder) { + this.count = builder.count; + this.currentPage = builder.currentPage; + this.pageSize = builder.pageSize; + this.records = builder.records; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public Integer getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(Integer currentPage) { + this.currentPage = currentPage; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public List getRecords() { + return records; + } + + public void setRecords(List records) { + this.records = records; + } + + @Override + public String toString() { + return "ListImportJobsResponse{" + + ", count=" + count + + ", currentPage=" + currentPage + + ", pageSize=" + pageSize + + '}'; + } + + public static ListImportJobsResponseBuilder builder() { + return new ListImportJobsResponseBuilder(); + } + + public static class ListImportJobsResponseBuilder { + private Integer count; + private Integer currentPage; + private Integer pageSize; + private List records; + + private ListImportJobsResponseBuilder() { + this.count = 0; + this.currentPage = 0; + this.pageSize = 0; + this.records = new ArrayList<>(); + } + + public ListImportJobsResponseBuilder count(Integer count) { + this.count = count; + return this; + } + + public ListImportJobsResponseBuilder currentPage(Integer currentPage) { + this.currentPage = currentPage; + return this; + } + + public ListImportJobsResponseBuilder pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + public ListImportJobsResponseBuilder records(List records) { + this.records = records; + return this; + } + + public ListImportJobsResponse build() { + return new ListImportJobsResponse(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/Record.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/Record.java index 1ca30b4d0..3bf16d131 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/Record.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/Record.java @@ -1,16 +1,90 @@ package io.milvus.bulkwriter.response; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor public class Record { private String collectionName; private String jobId; private String state; + + public Record() { + } + + public Record(String collectionName, String jobId, String state) { + this.collectionName = collectionName; + this.jobId = jobId; + this.state = state; + } + + private Record(RecordBuilder builder) { + this.collectionName = builder.collectionName; + this.jobId = builder.jobId; + this.state = builder.state; + } + + public String getCollectionName() { + return collectionName; + } + + public void setCollectionName(String collectionName) { + this.collectionName = collectionName; + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + @Override + public String toString() { + return "Record{" + + "collectionName='" + collectionName + '\'' + + ", jobId='" + jobId + '\'' + + ", state='" + state + '\'' + + '}'; + } + + public static RecordBuilder builder() { + return new RecordBuilder(); + } + + public static class RecordBuilder { + private String collectionName; + private String jobId; + private String state; + + private RecordBuilder() { + this.collectionName = ""; + this.jobId = ""; + this.state = ""; + } + + public RecordBuilder collectionName(String collectionName) { + this.collectionName = collectionName; + return this; + } + + public RecordBuilder jobId(String jobId) { + this.jobId = jobId; + return this; + } + + public RecordBuilder state(String state) { + this.state = state; + return this; + } + + public Record build() { + return new Record(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/RestfulResponse.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/RestfulResponse.java index 7181c008e..7a1c11c95 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/RestfulResponse.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/RestfulResponse.java @@ -19,23 +19,93 @@ package io.milvus.bulkwriter.response; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.io.Serializable; -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor public class RestfulResponse implements Serializable { private static final long serialVersionUID = -7162743560382861611L; - private int code; - private String message; - private T data; + + public RestfulResponse() { + } + + public RestfulResponse(int code, String message, T data) { + this.code = code; + this.message = message; + this.data = data; + } + + private RestfulResponse(RestfulResponseBuilder builder) { + this.code = builder.code; + this.message = builder.message; + this.data = builder.data; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } + + @Override + public String toString() { + return "RestfulResponse{" + + "code=" + code + + ", message='" + message + '\'' + + '}'; + } + + public static RestfulResponseBuilder builder() { + return new RestfulResponseBuilder<>(); + } + + public static class RestfulResponseBuilder { + private int code; + private String message; + private T data; + + private RestfulResponseBuilder() { + this.code = 0; + this.message = ""; + this.data = null; + } + + public RestfulResponseBuilder code(int code) { + this.code = code; + return this; + } + + public RestfulResponseBuilder message(String message) { + this.message = message; + return this; + } + + public RestfulResponseBuilder data(T data) { + this.data = data; + return this; + } + + public RestfulResponse build() { + return new RestfulResponse<>(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/stage/ListStagesResponse.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/stage/ListStagesResponse.java index ca045ebb1..7e0d302e1 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/stage/ListStagesResponse.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/stage/ListStagesResponse.java @@ -19,24 +19,112 @@ package io.milvus.bulkwriter.response.stage; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - +import java.util.ArrayList; import java.util.List; -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor public class ListStagesResponse { - private Integer count; - private Integer currentPage; - private Integer pageSize; - private List stages; + + public ListStagesResponse() { + } + + public ListStagesResponse(Integer count, Integer currentPage, Integer pageSize, List stages) { + this.count = count; + this.currentPage = currentPage; + this.pageSize = pageSize; + this.stages = stages; + } + + private ListStagesResponse(ListStagesResponseBuilder builder) { + this.count = builder.count; + this.currentPage = builder.currentPage; + this.pageSize = builder.pageSize; + this.stages = builder.stages; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public Integer getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(Integer currentPage) { + this.currentPage = currentPage; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public List getStages() { + return stages; + } + + public void setStages(List stages) { + this.stages = stages; + } + + @Override + public String toString() { + return "ListStagesResponse{" + + ", count=" + count + + ", currentPage=" + currentPage + + ", pageSize=" + pageSize + + '}'; + } + + public static ListStagesResponseBuilder builder() { + return new ListStagesResponseBuilder(); + } + + public static class ListStagesResponseBuilder { + private Integer count; + private Integer currentPage; + private Integer pageSize; + private List stages; + + private ListStagesResponseBuilder() { + this.count = 0; + this.currentPage = 0; + this.pageSize = 0; + this.stages = new ArrayList<>(); + } + + public ListStagesResponseBuilder count(Integer count) { + this.count = count; + return this; + } + + public ListStagesResponseBuilder currentPage(Integer currentPage) { + this.currentPage = currentPage; + return this; + } + + public ListStagesResponseBuilder pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + public ListStagesResponseBuilder stages(List stages) { + this.stages = stages; + return this; + } + + public ListStagesResponse build() { + return new ListStagesResponse(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/stage/StageInfo.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/stage/StageInfo.java index 84899f7f4..41a322a2d 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/stage/StageInfo.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/response/stage/StageInfo.java @@ -1,14 +1,52 @@ package io.milvus.bulkwriter.response.stage; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor public class StageInfo { private String stageName; + + public StageInfo() { + } + + public StageInfo(String stageName) { + this.stageName = stageName; + } + + private StageInfo(StageInfoBuilder builder) { + this.stageName = builder.stageName; + } + + public String getStageName() { + return stageName; + } + + public void setStageName(String stageName) { + this.stageName = stageName; + } + + @Override + public String toString() { + return "StageInfo{" + + "stageName='" + stageName + '\'' + + '}'; + } + + public static StageInfoBuilder builder() { + return new StageInfoBuilder(); + } + + public static class StageInfoBuilder { + private String stageName; + + private StageInfoBuilder() { + this.stageName = ""; + } + + public StageInfoBuilder stageName(String stageName) { + this.stageName = stageName; + return this; + } + + public StageInfo build() { + return new StageInfo(this); + } + } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/restful/BulkImportUtils.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/restful/BulkImportUtils.java index d7c81c1cd..ffaf4f4f0 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/restful/BulkImportUtils.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/restful/BulkImportUtils.java @@ -33,9 +33,11 @@ public class BulkImportUtils extends BaseRestful { public static String bulkImport(String url, BaseImportRequest request) { String requestURL = url + "/v2/vectordb/jobs/import/create"; - Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() {}.getType()); + Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() { + }.getType()); String body = postRequest(requestURL, request.getApiKey(), params, 60 * 1000); - RestfulResponse response = JsonUtils.fromJson(body, new TypeToken>(){}.getType()); + RestfulResponse response = JsonUtils.fromJson(body, new TypeToken>() { + }.getType()); handleResponse(requestURL, response); return body; } @@ -43,9 +45,11 @@ public static String bulkImport(String url, BaseImportRequest request) { public static String getImportProgress(String url, BaseDescribeImportRequest request) { String requestURL = url + "/v2/vectordb/jobs/import/describe"; - Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() {}.getType()); + Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() { + }.getType()); String body = postRequest(requestURL, request.getApiKey(), params, 60 * 1000); - RestfulResponse response = JsonUtils.fromJson(body, new TypeToken>(){}.getType()); + RestfulResponse response = JsonUtils.fromJson(body, new TypeToken>() { + }.getType()); handleResponse(requestURL, response); return body; } @@ -53,9 +57,11 @@ public static String getImportProgress(String url, BaseDescribeImportRequest req public static String listImportJobs(String url, BaseListImportJobsRequest request) { String requestURL = url + "/v2/vectordb/jobs/import/list"; - Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() {}.getType()); + Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() { + }.getType()); String body = postRequest(requestURL, request.getApiKey(), params, 60 * 1000); - RestfulResponse response = JsonUtils.fromJson(body, new TypeToken>(){}.getType()); + RestfulResponse response = JsonUtils.fromJson(body, new TypeToken>() { + }.getType()); handleResponse(requestURL, response); return body; } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/restful/DataStageUtils.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/restful/DataStageUtils.java index fde3d67d7..3a8b109ec 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/restful/DataStageUtils.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/restful/DataStageUtils.java @@ -34,9 +34,11 @@ public class DataStageUtils extends BaseRestful { public static String applyStage(String url, BaseStageRequest request) { String requestURL = url + "/v2/stages/apply"; - Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() {}.getType()); + Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() { + }.getType()); String body = postRequest(requestURL, request.getApiKey(), params, 60 * 1000); - RestfulResponse response = JsonUtils.fromJson(body, new TypeToken>(){}.getType()); + RestfulResponse response = JsonUtils.fromJson(body, new TypeToken>() { + }.getType()); handleResponse(requestURL, response); return new Gson().toJson(response.getData()); } @@ -44,9 +46,11 @@ public static String applyStage(String url, BaseStageRequest request) { public static String listStages(String url, String apiKey, ListStagesRequest request) { String requestURL = url + "/v2/stages"; - Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() {}.getType()); + Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() { + }.getType()); String body = getRequest(requestURL, apiKey, params, 60 * 1000); - RestfulResponse response = JsonUtils.fromJson(body, new TypeToken>(){}.getType()); + RestfulResponse response = JsonUtils.fromJson(body, new TypeToken>() { + }.getType()); handleResponse(requestURL, response); return new Gson().toJson(response.getData()); } @@ -54,18 +58,22 @@ public static String listStages(String url, String apiKey, ListStagesRequest req public static void createStage(String url, String apiKey, CreateStageRequest request) { String requestURL = url + "/v2/stages/create"; - Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() {}.getType()); + Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() { + }.getType()); String body = postRequest(requestURL, apiKey, params, 60 * 1000); - RestfulResponse response = JsonUtils.fromJson(body, new TypeToken>(){}.getType()); + RestfulResponse response = JsonUtils.fromJson(body, new TypeToken>() { + }.getType()); handleResponse(requestURL, response); } public static void deleteStage(String url, String apiKey, DeleteStageRequest request) { String requestURL = url + "/v2/stages/" + request.getStageName(); - Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() {}.getType()); + Map params = JsonUtils.fromJson(JsonUtils.toJson(request), new TypeToken>() { + }.getType()); String body = deleteRequest(requestURL, apiKey, params, 60 * 1000); - RestfulResponse response = JsonUtils.fromJson(body, new TypeToken>(){}.getType()); + RestfulResponse response = JsonUtils.fromJson(body, new TypeToken>() { + }.getType()); handleResponse(requestURL, response); } } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/storage/StorageClient.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/storage/StorageClient.java index 67e91631a..fdb770155 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/storage/StorageClient.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/storage/StorageClient.java @@ -24,6 +24,8 @@ public interface StorageClient { Long getObjectEntity(String bucketName, String objectKey) throws Exception; + boolean checkBucketExist(String bucketName) throws Exception; + void putObject(File file, String bucketName, String objectKey) throws Exception; } diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/storage/client/MinioStorageClient.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/storage/client/MinioStorageClient.java index 2f55c2030..aaec20dd5 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/storage/client/MinioStorageClient.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/storage/client/MinioStorageClient.java @@ -23,14 +23,7 @@ import io.milvus.bulkwriter.common.clientenum.CloudStorage; import io.milvus.bulkwriter.model.CompleteMultipartUploadOutputModel; import io.milvus.bulkwriter.storage.StorageClient; -import io.minio.BucketExistsArgs; -import io.minio.MinioAsyncClient; -import io.minio.ObjectWriteResponse; -import io.minio.PutObjectArgs; -import io.minio.S3Base; -import io.minio.StatObjectArgs; -import io.minio.StatObjectResponse; -import io.minio.Xml; +import io.minio.*; import io.minio.credentials.StaticProvider; import io.minio.errors.ErrorResponseException; import io.minio.errors.InsufficientDataException; diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/writer/CSVFileWriter.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/writer/CSVFileWriter.java index 4a9e46fa6..46b9fd0e2 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/writer/CSVFileWriter.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/writer/CSVFileWriter.java @@ -33,7 +33,7 @@ public CSVFileWriter(CreateCollectionReq.CollectionSchema collectionSchema, Stri } private void initFilePath(String filePathPrefix) { - this.filePath = filePathPrefix + ".csv"; + this.filePath = filePathPrefix + ".csv"; } private void initWriter() throws IOException { @@ -48,8 +48,8 @@ public void appendRow(Map rowValues, boolean firstWrite) throws List fieldNameList = Lists.newArrayList(rowValues.keySet()); try { - String separator = (String)config.getOrDefault("sep", ","); - String nullKey = (String)config.getOrDefault("nullkey", ""); + String separator = (String) config.getOrDefault("sep", ","); + String nullKey = (String) config.getOrDefault("nullkey", ""); if (firstWrite) { writer.write(String.join(separator, fieldNameList)); diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/writer/JSONFileWriter.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/writer/JSONFileWriter.java index 492b798e1..380d901b6 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/writer/JSONFileWriter.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/writer/JSONFileWriter.java @@ -27,7 +27,7 @@ public JSONFileWriter(CreateCollectionReq.CollectionSchema collectionSchema, Str } private void initFilePath(String filePathPrefix) { - this.filePath = filePathPrefix + ".json"; + this.filePath = filePathPrefix + ".json"; } private void initWriter() throws IOException { @@ -38,7 +38,7 @@ private void initWriter() throws IOException { public void appendRow(Map rowValues, boolean firstWrite) throws IOException { Gson gson = new GsonBuilder().serializeNulls().create(); rowValues.keySet().removeIf(key -> key.equals(DYNAMIC_FIELD_NAME) && !this.collectionSchema.isEnableDynamicField()); - rowValues.replaceAll((key, value) -> value instanceof ByteBuffer ? ((ByteBuffer)value).array() : value); + rowValues.replaceAll((key, value) -> value instanceof ByteBuffer ? ((ByteBuffer) value).array() : value); try { if (firstWrite) { diff --git a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/writer/ParquetFileWriter.java b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/writer/ParquetFileWriter.java index 31e598008..1af9e2585 100644 --- a/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/writer/ParquetFileWriter.java +++ b/sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/writer/ParquetFileWriter.java @@ -41,7 +41,7 @@ public ParquetFileWriter(CreateCollectionReq.CollectionSchema collectionSchema, } private void initFilePath(String filePathPrefix) { - this.filePath = filePathPrefix + ".parquet"; + this.filePath = filePathPrefix + ".parquet"; } private void initMessageType() { @@ -116,29 +116,29 @@ private void appendGroup(Group group, String paramName, Object value, CreateColl switch (dataType) { case Int8: case Int16: - group.append(paramName, (Short)value); + group.append(paramName, (Short) value); break; case Int32: - group.append(paramName, (Integer)value); + group.append(paramName, (Integer) value); break; case Int64: - group.append(paramName, (Long)value); + group.append(paramName, (Long) value); break; case Float: - group.append(paramName, (Float)value); + group.append(paramName, (Float) value); break; case Double: - group.append(paramName, (Double)value); + group.append(paramName, (Double) value); break; case Bool: - group.append(paramName, (Boolean)value); + group.append(paramName, (Boolean) value); break; case VarChar: case String: case Geometry: case Timestamptz: case JSON: - group.append(paramName, (String)value); + group.append(paramName, (String) value); break; case FloatVector: addFloatArray(group, paramName, (List) value); diff --git a/sdk-core/pom.xml b/sdk-core/pom.xml index ab961f8ba..a7f33dcee 100644 --- a/sdk-core/pom.xml +++ b/sdk-core/pom.xml @@ -150,12 +150,6 @@ junit-jupiter test - - org.projectlombok - lombok - ${lombok.version} - test - com.squareup.okhttp3 okhttp diff --git a/sdk-core/src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java b/sdk-core/src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java index 4e43b4135..880904bdf 100644 --- a/sdk-core/src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java +++ b/sdk-core/src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java @@ -20,23 +20,36 @@ package io.milvus.client; import com.google.common.collect.Lists; -import com.google.common.util.concurrent.*; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; import com.google.gson.reflect.TypeToken; import io.grpc.StatusRuntimeException; import io.milvus.common.utils.ExceptionUtils; import io.milvus.common.utils.GTsDict; import io.milvus.common.utils.JsonUtils; import io.milvus.common.utils.VectorUtils; -import io.milvus.exception.*; +import io.milvus.exception.ClientNotConnectedException; +import io.milvus.exception.IllegalResponseException; +import io.milvus.exception.ServerException; import io.milvus.grpc.*; import io.milvus.orm.iterator.QueryIterator; import io.milvus.orm.iterator.SearchIterator; import io.milvus.param.*; -import io.milvus.param.alias.*; -import io.milvus.param.bulkinsert.*; +import io.milvus.param.alias.AlterAliasParam; +import io.milvus.param.alias.CreateAliasParam; +import io.milvus.param.alias.DropAliasParam; +import io.milvus.param.alias.ListAliasesParam; +import io.milvus.param.bulkinsert.BulkInsertParam; +import io.milvus.param.bulkinsert.GetBulkInsertStateParam; +import io.milvus.param.bulkinsert.ListBulkInsertTasksParam; import io.milvus.param.collection.*; import io.milvus.param.control.*; -import io.milvus.param.credential.*; +import io.milvus.param.credential.CreateCredentialParam; +import io.milvus.param.credential.DeleteCredentialParam; +import io.milvus.param.credential.ListCredUsersParam; +import io.milvus.param.credential.UpdateCredentialParam; import io.milvus.param.dml.*; import io.milvus.param.highlevel.collection.CreateSimpleCollectionParam; import io.milvus.param.highlevel.collection.ListCollectionsParam; @@ -48,7 +61,6 @@ import io.milvus.param.resourcegroup.*; import io.milvus.param.role.*; import io.milvus.response.*; - import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -413,7 +425,7 @@ private void handleResponse(String requestInfo, io.milvus.grpc.Status status) { logDebug("{} successfully!", requestInfo); } - ///////////////////// API implementation ////////////////////// + /// ////////////////// API implementation ////////////////////// @Override public R hasCollection(HasCollectionParam requestParam) { ExceptionUtils.checkNotNull(requestParam, requestParam.getClass().getSimpleName()); @@ -542,9 +554,9 @@ public R alterDatabase(AlterDatabaseParam requestParam) { try { List propertiesList = ParamUtils.AssembleKvPair(requestParam.getProperties()); AlterDatabaseRequest alterDatabaseRequest = AlterDatabaseRequest.newBuilder() - .setDbName(requestParam.getDatabaseName()) - .addAllProperties(propertiesList) - .build(); + .setDbName(requestParam.getDatabaseName()) + .addAllProperties(propertiesList) + .build(); Status response = blockingStub().alterDatabase(alterDatabaseRequest); handleResponse(title, response); @@ -568,8 +580,8 @@ public R describeDatabase(DescribeDatabaseParam reques String title = String.format("DescribeDatabaseRequest databaseName:%s", requestParam.getDatabaseName()); try { DescribeDatabaseRequest describeDatabaseRequest = DescribeDatabaseRequest.newBuilder() - .setDbName(requestParam.getDatabaseName()) - .build(); + .setDbName(requestParam.getDatabaseName()) + .build(); DescribeDatabaseResponse response = blockingStub().describeDatabase(describeDatabaseRequest); handleResponse(title, response.getStatus()); @@ -1371,7 +1383,8 @@ public R createIndex(CreateIndexParam requestParam) { Map extraParams = requestParam.getExtraParam(); for (Map.Entry entry : extraParams.entrySet()) { if (entry.getKey().equals(Constant.PARAMS)) { - Map tempParams = JsonUtils.fromJson(entry.getValue(), new TypeToken>() {}.getType()); + Map tempParams = JsonUtils.fromJson(entry.getValue(), new TypeToken>() { + }.getType()); for (String key : tempParams.keySet()) { createIndexRequestBuilder.addExtraParams(KeyValuePair.newBuilder() .setKey(key) @@ -3217,7 +3230,7 @@ public R updateResourceGroups(UpdateResourceGroupsParam requestParam) } } - ///////////////////// High Level API////////////////////// + /// ////////////////// High Level API////////////////////// @Override public R createCollection(CreateSimpleCollectionParam requestParam) { if (!clientIsReady()) { @@ -3229,21 +3242,21 @@ public R createCollection(CreateSimpleCollectionParam requestParam) { try { // step1: create collection R createCollectionStatus = createCollection(requestParam.getCreateCollectionParam()); - if(!Objects.equals(createCollectionStatus.getStatus(), R.success().getStatus())){ + if (!Objects.equals(createCollectionStatus.getStatus(), R.success().getStatus())) { logError("CreateCollection failed: {}", createCollectionStatus.getException().getMessage()); return R.failed(createCollectionStatus.getException()); } // step2: create index R createIndexStatus = createIndex(requestParam.getCreateIndexParam()); - if(!Objects.equals(createIndexStatus.getStatus(), R.success().getStatus())){ + if (!Objects.equals(createIndexStatus.getStatus(), R.success().getStatus())) { logError("CreateIndex failed: {}", createIndexStatus.getException().getMessage()); return R.failed(createIndexStatus.getException()); } // step3: load collection R loadCollectionStatus = loadCollection(requestParam.getLoadCollectionParam()); - if(!Objects.equals(loadCollectionStatus.getStatus(), R.success().getStatus())){ + if (!Objects.equals(loadCollectionStatus.getStatus(), R.success().getStatus())) { logError("LoadCollection failed: {}", loadCollectionStatus.getException().getMessage()); return R.failed(loadCollectionStatus.getException()); } @@ -3266,10 +3279,10 @@ public R listCollections(ListCollectionsParam requestPa } logDebug(requestParam.toString()); String title = "ListCollectionsRequest"; - + try { R response = showCollections(requestParam.getShowCollectionsParam()); - if(!Objects.equals(response.getStatus(), R.success().getStatus())){ + if (!Objects.equals(response.getStatus(), R.success().getStatus())) { logError("ListCollections failed: {}", response.getException().getMessage()); return R.failed(response.getException()); } @@ -3293,10 +3306,10 @@ public R insert(InsertRowsParam requestParam) { } logDebug(requestParam.toString()); String title = "InsertRowsRequest"; - + try { R response = insert(requestParam.getInsertParam()); - if(!Objects.equals(response.getStatus(), R.success().getStatus())){ + if (!Objects.equals(response.getStatus(), R.success().getStatus())) { logError("Insert failed: {}", response.getException().getMessage()); return R.failed(response.getException()); } @@ -3426,7 +3439,7 @@ public R query(QuerySimpleParam requestParam) { .withConsistencyLevel(requestParam.getConsistencyLevel()) .build(); R response = query(queryParam); - if(!Objects.equals(response.getStatus(), R.success().getStatus())){ + if (!Objects.equals(response.getStatus(), R.success().getStatus())) { logError("Query failed: {}", response.getException().getMessage()); return R.failed(response.getException()); } @@ -3484,7 +3497,7 @@ public R search(SearchSimpleParam requestParam) { // search R response = search(searchParam); - if(!Objects.equals(response.getStatus(), R.success().getStatus())){ + if (!Objects.equals(response.getStatus(), R.success().getStatus())) { logError("Search failed: {}", response.getException().getMessage()); return R.failed(response.getException()); } @@ -3534,7 +3547,7 @@ public R searchIterator(SearchIteratorParam requestParam) { return R.success(searchIterator); } - ///////////////////// Log Functions////////////////////// + /// ////////////////// Log Functions////////////////////// protected void logDebug(String msg, Object... params) { if (logLevel.ordinal() <= LogLevel.Debug.ordinal()) { logger.debug(msg, params); diff --git a/sdk-core/src/main/java/io/milvus/client/MilvusClient.java b/sdk-core/src/main/java/io/milvus/client/MilvusClient.java index f53899407..dd42214ce 100644 --- a/sdk-core/src/main/java/io/milvus/client/MilvusClient.java +++ b/sdk-core/src/main/java/io/milvus/client/MilvusClient.java @@ -21,33 +21,40 @@ import com.google.common.util.concurrent.ListenableFuture; import io.milvus.grpc.*; +import io.milvus.orm.iterator.QueryIterator; +import io.milvus.orm.iterator.SearchIterator; import io.milvus.param.LogLevel; import io.milvus.param.R; -import io.milvus.param.RpcStatus; import io.milvus.param.RetryParam; -import io.milvus.param.alias.*; -import io.milvus.param.bulkinsert.*; +import io.milvus.param.RpcStatus; +import io.milvus.param.alias.AlterAliasParam; +import io.milvus.param.alias.CreateAliasParam; +import io.milvus.param.alias.DropAliasParam; +import io.milvus.param.alias.ListAliasesParam; +import io.milvus.param.bulkinsert.BulkInsertParam; +import io.milvus.param.bulkinsert.GetBulkInsertStateParam; +import io.milvus.param.bulkinsert.ListBulkInsertTasksParam; import io.milvus.param.collection.*; -import io.milvus.param.highlevel.collection.response.ListCollectionsResponse; import io.milvus.param.control.*; -import io.milvus.param.credential.*; +import io.milvus.param.credential.CreateCredentialParam; +import io.milvus.param.credential.DeleteCredentialParam; +import io.milvus.param.credential.ListCredUsersParam; +import io.milvus.param.credential.UpdateCredentialParam; import io.milvus.param.dml.*; import io.milvus.param.highlevel.collection.CreateSimpleCollectionParam; import io.milvus.param.highlevel.collection.ListCollectionsParam; +import io.milvus.param.highlevel.collection.response.ListCollectionsResponse; import io.milvus.param.highlevel.dml.*; import io.milvus.param.highlevel.dml.response.*; import io.milvus.param.index.*; -import io.milvus.orm.iterator.QueryIterator; -import io.milvus.orm.iterator.SearchIterator; import io.milvus.param.partition.*; -import io.milvus.param.role.*; import io.milvus.param.resourcegroup.*; - -import java.util.concurrent.TimeUnit; - +import io.milvus.param.role.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.concurrent.TimeUnit; + /** * The Milvus Client Interface */ @@ -75,7 +82,7 @@ public interface MilvusClient { /** * Number of retry attempts. * - * @param retryTimes number of retry attempts. + * @param retryTimes number of retry attempts. * @return MilvusClient */ @Deprecated @@ -84,8 +91,8 @@ public interface MilvusClient { /** * Time interval between retry attempts. Default value is 500ms. * - * @param interval time interval between retry attempts. - * @param timeUnit time unit + * @param interval time interval between retry attempts. + * @param timeUnit time unit * @return MilvusClient */ @Deprecated @@ -152,7 +159,7 @@ default void close() { * Alter database with key value pair. (Available from Milvus v2.4.4) * * @param requestParam {@link AlterDatabaseParam} - * @return {status:result code, data:RpcStatus{msg: result message}} + * @return {status:result code, data:RpcStatus{msg: result message}} */ R alterDatabase(AlterDatabaseParam requestParam); @@ -248,9 +255,9 @@ default void close() { /** * Flush all collections. All insertions, deletions, and upserts before `flushAll` will be synced. * - * @param syncFlushAll {flushAll synchronously or asynchronously} + * @param syncFlushAll {flushAll synchronously or asynchronously} * @param syncFlushAllWaitingInterval {wait intervel when flushAll synchronously} - * @param syncFlushAllTimeout {timeout when flushAll synchronously} + * @param syncFlushAllTimeout {timeout when flushAll synchronously} * @return {status:result code,data: FlushAllResponse{flushAllTs}} */ R flushAll(boolean syncFlushAll, long syncFlushAllWaitingInterval, long syncFlushAllTimeout); @@ -761,7 +768,7 @@ default void close() { /** * Update resource groups. - * + * * @param requestParam {@link UpdateResourceGroupsParam} * @return {status:result code, data:RpcStatus{msg: result message}} */ diff --git a/sdk-core/src/main/java/io/milvus/client/MilvusMultiServiceClient.java b/sdk-core/src/main/java/io/milvus/client/MilvusMultiServiceClient.java index 269084eb5..2735a699d 100644 --- a/sdk-core/src/main/java/io/milvus/client/MilvusMultiServiceClient.java +++ b/sdk-core/src/main/java/io/milvus/client/MilvusMultiServiceClient.java @@ -23,21 +23,29 @@ import io.milvus.connection.ClusterFactory; import io.milvus.connection.ServerSetting; import io.milvus.grpc.*; +import io.milvus.orm.iterator.QueryIterator; +import io.milvus.orm.iterator.SearchIterator; import io.milvus.param.*; -import io.milvus.param.alias.*; -import io.milvus.param.bulkinsert.*; +import io.milvus.param.alias.AlterAliasParam; +import io.milvus.param.alias.CreateAliasParam; +import io.milvus.param.alias.DropAliasParam; +import io.milvus.param.alias.ListAliasesParam; +import io.milvus.param.bulkinsert.BulkInsertParam; +import io.milvus.param.bulkinsert.GetBulkInsertStateParam; +import io.milvus.param.bulkinsert.ListBulkInsertTasksParam; import io.milvus.param.collection.*; -import io.milvus.param.highlevel.collection.response.ListCollectionsResponse; import io.milvus.param.control.*; -import io.milvus.param.credential.*; +import io.milvus.param.credential.CreateCredentialParam; +import io.milvus.param.credential.DeleteCredentialParam; +import io.milvus.param.credential.ListCredUsersParam; +import io.milvus.param.credential.UpdateCredentialParam; import io.milvus.param.dml.*; import io.milvus.param.highlevel.collection.CreateSimpleCollectionParam; import io.milvus.param.highlevel.collection.ListCollectionsParam; +import io.milvus.param.highlevel.collection.response.ListCollectionsResponse; import io.milvus.param.highlevel.dml.*; import io.milvus.param.highlevel.dml.response.*; import io.milvus.param.index.*; -import io.milvus.orm.iterator.QueryIterator; -import io.milvus.orm.iterator.SearchIterator; import io.milvus.param.partition.*; import io.milvus.param.resourcegroup.*; import io.milvus.param.role.*; @@ -53,6 +61,7 @@ public class MilvusMultiServiceClient implements MilvusClient { /** * Sets connect param for multi milvus clusters. + * * @param multiConnectParam multi server connect param */ public MilvusMultiServiceClient(MultiConnectParam multiConnectParam) { @@ -178,7 +187,7 @@ public R describeDatabase(DescribeDatabaseParam reques List> response = this.clusterFactory.getAvailableServerSettings().stream() .map(serverSetting -> serverSetting.getClient().describeDatabase(requestParam)) .collect(Collectors.toList()); - return handleResponse(response); + return handleResponse(response); } @Override @@ -598,7 +607,7 @@ public R listBulkInsertTasks(ListBulkInsertTasksParam r return this.clusterFactory.getMaster().getClient().listBulkInsertTasks(requestParam); } - public R checkHealth(){ + public R checkHealth() { return this.clusterFactory.getMaster().getClient().checkHealth(); } @@ -651,7 +660,7 @@ public R transferReplica(TransferReplicaParam requestParam) { return this.clusterFactory.getMaster().getClient().transferReplica(requestParam); } - ///////////////////// High Level API////////////////////// + /// ////////////////// High Level API////////////////////// @Override diff --git a/sdk-core/src/main/java/io/milvus/client/MilvusServiceClient.java b/sdk-core/src/main/java/io/milvus/client/MilvusServiceClient.java index 65980b295..48f45aa43 100644 --- a/sdk-core/src/main/java/io/milvus/client/MilvusServiceClient.java +++ b/sdk-core/src/main/java/io/milvus/client/MilvusServiceClient.java @@ -19,8 +19,8 @@ package io.milvus.client; -import io.grpc.Status; import io.grpc.*; +import io.grpc.Status; import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts; import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder; import io.grpc.netty.shaded.io.netty.handler.ssl.SslContext; @@ -32,11 +32,19 @@ import io.milvus.orm.iterator.QueryIterator; import io.milvus.orm.iterator.SearchIterator; import io.milvus.param.*; -import io.milvus.param.alias.*; -import io.milvus.param.bulkinsert.*; +import io.milvus.param.alias.AlterAliasParam; +import io.milvus.param.alias.CreateAliasParam; +import io.milvus.param.alias.DropAliasParam; +import io.milvus.param.alias.ListAliasesParam; +import io.milvus.param.bulkinsert.BulkInsertParam; +import io.milvus.param.bulkinsert.GetBulkInsertStateParam; +import io.milvus.param.bulkinsert.ListBulkInsertTasksParam; import io.milvus.param.collection.*; import io.milvus.param.control.*; -import io.milvus.param.credential.*; +import io.milvus.param.credential.CreateCredentialParam; +import io.milvus.param.credential.DeleteCredentialParam; +import io.milvus.param.credential.ListCredUsersParam; +import io.milvus.param.credential.UpdateCredentialParam; import io.milvus.param.dml.*; import io.milvus.param.highlevel.collection.CreateSimpleCollectionParam; import io.milvus.param.highlevel.collection.ListCollectionsParam; @@ -48,22 +56,17 @@ import io.milvus.param.resourcegroup.*; import io.milvus.param.role.*; import io.milvus.v2.utils.ClientUtils; -import io.grpc.ProxiedSocketAddress; -import io.grpc.ProxyDetector; import org.apache.commons.lang3.StringUtils; import java.io.File; import java.io.IOException; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.time.LocalDateTime; -import java.net.InetSocketAddress; -import java.net.SocketAddress; -import io.grpc.HttpConnectProxiedSocketAddress; public class MilvusServiceClient extends AbstractMilvusGrpcClient { @@ -93,10 +96,10 @@ public MilvusServiceClient(ConnectParam connectParam) { @Override public ClientCall interceptCall(MethodDescriptor method, CallOptions callOptions, Channel next) { return new ForwardingClientCall - .SimpleForwardingClientCall(next.newCall(method, callOptions)) { + .SimpleForwardingClientCall(next.newCall(method, callOptions)) { @Override public void start(ClientCall.Listener responseListener, Metadata headers) { - if(connectParam.getClientRequestId() != null && !StringUtils.isEmpty(connectParam.getClientRequestId().get())) { + if (connectParam.getClientRequestId() != null && !StringUtils.isEmpty(connectParam.getClientRequestId().get())) { headers.put(Metadata.Key.of("client_request_id", Metadata.ASCII_STRING_MARSHALLER), connectParam.getClientRequestId().get()); } super.start(responseListener, headers); @@ -124,7 +127,7 @@ public void start(ClientCall.Listener responseListener, Metadata headers) if (StringUtils.isNotEmpty(connectParam.getProxyAddress())) { ClientUtils.configureProxy(builder, connectParam.getProxyAddress()); } - if(connectParam.isSecure()){ + if (connectParam.isSecure()) { builder.useTransportSecurity(); } channel = builder.build(); @@ -144,12 +147,12 @@ public void start(ClientCall.Listener responseListener, Metadata headers) .keepAliveWithoutCalls(connectParam.isKeepAliveWithoutCalls()) .idleTimeout(connectParam.getIdleTimeoutMs(), TimeUnit.MILLISECONDS) .intercept(clientInterceptors); - + // Add proxy configuration if proxy address is set if (StringUtils.isNotEmpty(connectParam.getProxyAddress())) { ClientUtils.configureProxy(builder, connectParam.getProxyAddress()); - } - if(connectParam.isSecure()){ + } + if (connectParam.isSecure()) { builder.useTransportSecurity(); } if (StringUtils.isNotEmpty(connectParam.getServerName())) { @@ -169,7 +172,7 @@ public void start(ClientCall.Listener responseListener, Metadata headers) if (StringUtils.isNotEmpty(connectParam.getProxyAddress())) { ClientUtils.configureProxy(builder, connectParam.getProxyAddress()); } - if(connectParam.isSecure()){ + if (connectParam.isSecure()) { builder.useTransportSecurity(); } channel = builder.build(); @@ -187,7 +190,7 @@ public void start(ClientCall.Listener responseListener, Metadata headers) // calls a RPC Connect() to the remote server, and sends the client info to the server // so that the server knows which client is interacting, especially for accesses log. this.timeoutMs = connectParam.getConnectTimeoutMs(); // set this value to connectTimeoutMs to control the retry() - R resp = this.retry(()->connect(connectParam)); + R resp = this.retry(() -> connect(connectParam)); if (resp.getStatus() != R.Status.Success.getCode()) { String msg = "Failed to initialize connection. Error: " + resp.getMessage(); logError(msg); @@ -319,7 +322,7 @@ private R retry(Callable> callable) { // method to check timeout long begin = System.currentTimeMillis(); - Callable timeoutChecker = ()->{ + Callable timeoutChecker = () -> { long current = System.currentTimeMillis(); long cost = (current - begin); if (this.timeoutMs > 0 && cost >= this.timeoutMs) { @@ -340,7 +343,7 @@ private R retry(Callable> callable) { Exception e = resp.getException(); if (e instanceof StatusRuntimeException) { // for rpc exception, some error cannot be retried - StatusRuntimeException rpcException = (StatusRuntimeException)e; + StatusRuntimeException rpcException = (StatusRuntimeException) e; Status.Code code = rpcException.getStatus().getCode(); if (code == Status.DEADLINE_EXCEEDED.getCode() || code == Status.PERMISSION_DENIED.getCode() @@ -358,7 +361,7 @@ private R retry(Callable> callable) { throw new MilvusException(msg, code.value()); } } else if (e instanceof ServerException) { - ServerException serverException = (ServerException)e; + ServerException serverException = (ServerException) e; if (timeoutChecker.call() == Boolean.TRUE) { String msg = String.format("Retry timeout: %dms, maxRetry:%d, retries: %d, reason: %s", this.timeoutMs, maxRetryTimes, k, e); @@ -393,7 +396,7 @@ private R retry(Callable> callable) { } // reset the next interval value - retryIntervalMs = retryIntervalMs*this.retryParam.getBackOffMultiplier(); + retryIntervalMs = retryIntervalMs * this.retryParam.getBackOffMultiplier(); if (retryIntervalMs > this.retryParam.getMaxBackOffMs()) { retryIntervalMs = this.retryParam.getMaxBackOffMs(); } @@ -411,7 +414,7 @@ private R retry(Callable> callable) { * This method is internal used, it calls a RPC Connect() to the remote server, * and sends the client info to the server so that the server knows which client is interacting, * especially for accesses log. - * + *

* The info includes: * 1. username(if Authentication is enabled) * 2. the client computer's name @@ -468,17 +471,17 @@ public void setLogLevel(LogLevel level) { @Override public R hasCollection(HasCollectionParam requestParam) { - return retry(()-> super.hasCollection(requestParam)); + return retry(() -> super.hasCollection(requestParam)); } @Override public R createDatabase(CreateDatabaseParam requestParam) { - return retry(()-> super.createDatabase(requestParam)); + return retry(() -> super.createDatabase(requestParam)); } @Override public R dropDatabase(DropDatabaseParam requestParam) { - return retry(()-> super.dropDatabase(requestParam)); + return retry(() -> super.dropDatabase(requestParam)); } @Override @@ -488,324 +491,324 @@ public R listDatabases() { @Override public R alterDatabase(AlterDatabaseParam requestParam) { - return retry(()-> super.alterDatabase(requestParam)); + return retry(() -> super.alterDatabase(requestParam)); } @Override public R describeDatabase(DescribeDatabaseParam requestParam) { - return retry(()-> super.describeDatabase(requestParam)); + return retry(() -> super.describeDatabase(requestParam)); } @Override public R createCollection(CreateCollectionParam requestParam) { - return retry(()-> super.createCollection(requestParam)); + return retry(() -> super.createCollection(requestParam)); } @Override public R dropCollection(DropCollectionParam requestParam) { - return retry(()-> super.dropCollection(requestParam)); + return retry(() -> super.dropCollection(requestParam)); } @Override public R loadCollection(LoadCollectionParam requestParam) { - return retry(()-> super.loadCollection(requestParam)); + return retry(() -> super.loadCollection(requestParam)); } @Override public R releaseCollection(ReleaseCollectionParam requestParam) { - return retry(()-> super.releaseCollection(requestParam)); + return retry(() -> super.releaseCollection(requestParam)); } @Override public R describeCollection(DescribeCollectionParam requestParam) { - return retry(()-> super.describeCollection(requestParam)); + return retry(() -> super.describeCollection(requestParam)); } @Override public R getCollectionStatistics(GetCollectionStatisticsParam requestParam) { - return retry(()-> super.getCollectionStatistics(requestParam)); + return retry(() -> super.getCollectionStatistics(requestParam)); } @Override public R renameCollection(RenameCollectionParam requestParam) { - return retry(()-> super.renameCollection(requestParam)); + return retry(() -> super.renameCollection(requestParam)); } @Override public R showCollections(ShowCollectionsParam requestParam) { - return retry(()-> super.showCollections(requestParam)); + return retry(() -> super.showCollections(requestParam)); } @Override public R alterCollection(AlterCollectionParam requestParam) { - return retry(()-> super.alterCollection(requestParam)); + return retry(() -> super.alterCollection(requestParam)); } @Override public R flush(FlushParam requestParam) { - return retry(()-> super.flush(requestParam)); + return retry(() -> super.flush(requestParam)); } @Override public R flushAll(boolean syncFlushAll, long syncFlushAllWaitingInterval, long syncFlushAllTimeout) { - return retry(()-> super.flushAll(syncFlushAll, syncFlushAllWaitingInterval, syncFlushAllTimeout)); + return retry(() -> super.flushAll(syncFlushAll, syncFlushAllWaitingInterval, syncFlushAllTimeout)); } @Override public R createPartition(CreatePartitionParam requestParam) { - return retry(()-> super.createPartition(requestParam)); + return retry(() -> super.createPartition(requestParam)); } @Override public R dropPartition(DropPartitionParam requestParam) { - return retry(()-> super.dropPartition(requestParam)); + return retry(() -> super.dropPartition(requestParam)); } @Override public R hasPartition(HasPartitionParam requestParam) { - return retry(()-> super.hasPartition(requestParam)); + return retry(() -> super.hasPartition(requestParam)); } @Override public R loadPartitions(LoadPartitionsParam requestParam) { - return retry(()-> super.loadPartitions(requestParam)); + return retry(() -> super.loadPartitions(requestParam)); } @Override public R releasePartitions(ReleasePartitionsParam requestParam) { - return retry(()-> super.releasePartitions(requestParam)); + return retry(() -> super.releasePartitions(requestParam)); } @Override public R getPartitionStatistics(GetPartitionStatisticsParam requestParam) { - return retry(()-> super.getPartitionStatistics(requestParam)); + return retry(() -> super.getPartitionStatistics(requestParam)); } @Override public R showPartitions(ShowPartitionsParam requestParam) { - return retry(()-> super.showPartitions(requestParam)); + return retry(() -> super.showPartitions(requestParam)); } @Override public R createAlias(CreateAliasParam requestParam) { - return retry(()-> super.createAlias(requestParam)); + return retry(() -> super.createAlias(requestParam)); } @Override public R dropAlias(DropAliasParam requestParam) { - return retry(()-> super.dropAlias(requestParam)); + return retry(() -> super.dropAlias(requestParam)); } @Override public R alterAlias(AlterAliasParam requestParam) { - return retry(()-> super.alterAlias(requestParam)); + return retry(() -> super.alterAlias(requestParam)); } @Override public R listAliases(ListAliasesParam requestParam) { - return retry(()-> super.listAliases(requestParam)); + return retry(() -> super.listAliases(requestParam)); } @Override public R createIndex(CreateIndexParam requestParam) { - return retry(()-> super.createIndex(requestParam)); + return retry(() -> super.createIndex(requestParam)); } @Override public R dropIndex(DropIndexParam requestParam) { - return retry(()-> super.dropIndex(requestParam)); + return retry(() -> super.dropIndex(requestParam)); } @Override public R describeIndex(DescribeIndexParam requestParam) { - return retry(()-> super.describeIndex(requestParam)); + return retry(() -> super.describeIndex(requestParam)); } @Override public R getIndexState(GetIndexStateParam requestParam) { ExceptionUtils.checkNotNull(requestParam, requestParam.getClass().getSimpleName()); - return retry(()-> super.getIndexState(requestParam)); + return retry(() -> super.getIndexState(requestParam)); } @Override public R getIndexBuildProgress(GetIndexBuildProgressParam requestParam) { ExceptionUtils.checkNotNull(requestParam, requestParam.getClass().getSimpleName()); - return retry(()-> super.getIndexBuildProgress(requestParam)); + return retry(() -> super.getIndexBuildProgress(requestParam)); } @Override public R insert(InsertParam requestParam) { - return retry(()-> super.insert(requestParam)); + return retry(() -> super.insert(requestParam)); } @Override public R upsert(UpsertParam requestParam) { - return retry(()-> super.upsert(requestParam)); + return retry(() -> super.upsert(requestParam)); } @Override public R delete(DeleteParam requestParam) { - return retry(()-> super.delete(requestParam)); + return retry(() -> super.delete(requestParam)); } @Override public R search(SearchParam requestParam) { - return retry(()-> super.search(requestParam)); + return retry(() -> super.search(requestParam)); } @Override public R hybridSearch(HybridSearchParam requestParam) { - return retry(()-> super.hybridSearch(requestParam)); + return retry(() -> super.hybridSearch(requestParam)); } @Override public R query(QueryParam requestParam) { - return retry(()-> super.query(requestParam)); + return retry(() -> super.query(requestParam)); } @Override public R getMetrics(GetMetricsParam requestParam) { - return retry(()-> super.getMetrics(requestParam)); + return retry(() -> super.getMetrics(requestParam)); } @Override public R getFlushState(GetFlushStateParam requestParam) { - return retry(()-> super.getFlushState(requestParam)); + return retry(() -> super.getFlushState(requestParam)); } @Override public R getFlushAllState(GetFlushAllStateParam requestParam) { - return retry(()-> super.getFlushAllState(requestParam)); + return retry(() -> super.getFlushAllState(requestParam)); } @Override public R getPersistentSegmentInfo(GetPersistentSegmentInfoParam requestParam) { - return retry(()-> super.getPersistentSegmentInfo(requestParam)); + return retry(() -> super.getPersistentSegmentInfo(requestParam)); } @Override public R getQuerySegmentInfo(GetQuerySegmentInfoParam requestParam) { - return retry(()-> super.getQuerySegmentInfo(requestParam)); + return retry(() -> super.getQuerySegmentInfo(requestParam)); } @Override public R getReplicas(GetReplicasParam requestParam) { - return retry(()-> super.getReplicas(requestParam)); + return retry(() -> super.getReplicas(requestParam)); } @Override public R loadBalance(LoadBalanceParam requestParam) { - return retry(()-> super.loadBalance(requestParam)); + return retry(() -> super.loadBalance(requestParam)); } @Override public R getCompactionState(GetCompactionStateParam requestParam) { - return retry(()-> super.getCompactionState(requestParam)); + return retry(() -> super.getCompactionState(requestParam)); } @Override public R manualCompact(ManualCompactParam requestParam) { - return retry(()-> super.manualCompact(requestParam)); + return retry(() -> super.manualCompact(requestParam)); } @Override public R getCompactionStateWithPlans(GetCompactionPlansParam requestParam) { - return retry(()-> super.getCompactionStateWithPlans(requestParam)); + return retry(() -> super.getCompactionStateWithPlans(requestParam)); } @Override public R createCredential(CreateCredentialParam requestParam) { - return retry(()-> super.createCredential(requestParam)); + return retry(() -> super.createCredential(requestParam)); } @Override public R updateCredential(UpdateCredentialParam requestParam) { - return retry(()-> super.updateCredential(requestParam)); + return retry(() -> super.updateCredential(requestParam)); } @Override public R deleteCredential(DeleteCredentialParam requestParam) { - return retry(()-> super.deleteCredential(requestParam)); + return retry(() -> super.deleteCredential(requestParam)); } @Override public R listCredUsers(ListCredUsersParam requestParam) { - return retry(()-> super.listCredUsers(requestParam)); + return retry(() -> super.listCredUsers(requestParam)); } @Override public R createRole(CreateRoleParam requestParam) { - return retry(()-> super.createRole(requestParam)); + return retry(() -> super.createRole(requestParam)); } @Override public R dropRole(DropRoleParam requestParam) { - return retry(()-> super.dropRole(requestParam)); + return retry(() -> super.dropRole(requestParam)); } @Override public R addUserToRole(AddUserToRoleParam requestParam) { - return retry(()-> super.addUserToRole(requestParam)); + return retry(() -> super.addUserToRole(requestParam)); } @Override public R removeUserFromRole(RemoveUserFromRoleParam requestParam) { - return retry(()-> super.removeUserFromRole(requestParam)); + return retry(() -> super.removeUserFromRole(requestParam)); } @Override public R selectRole(SelectRoleParam requestParam) { - return retry(()-> super.selectRole(requestParam)); + return retry(() -> super.selectRole(requestParam)); } @Override public R selectUser(SelectUserParam requestParam) { - return retry(()-> super.selectUser(requestParam)); + return retry(() -> super.selectUser(requestParam)); } @Override public R grantRolePrivilege(GrantRolePrivilegeParam requestParam) { - return retry(()-> super.grantRolePrivilege(requestParam)); + return retry(() -> super.grantRolePrivilege(requestParam)); } @Override public R revokeRolePrivilege(RevokeRolePrivilegeParam requestParam) { - return retry(()-> super.revokeRolePrivilege(requestParam)); + return retry(() -> super.revokeRolePrivilege(requestParam)); } @Override public R selectGrantForRole(SelectGrantForRoleParam requestParam) { - return retry(()-> super.selectGrantForRole(requestParam)); + return retry(() -> super.selectGrantForRole(requestParam)); } @Override public R selectGrantForRoleAndObject(SelectGrantForRoleAndObjectParam requestParam) { - return retry(()-> super.selectGrantForRoleAndObject(requestParam)); + return retry(() -> super.selectGrantForRoleAndObject(requestParam)); } @Override public R bulkInsert(BulkInsertParam requestParam) { - return retry(()-> super.bulkInsert(requestParam)); + return retry(() -> super.bulkInsert(requestParam)); } @Override public R getBulkInsertState(GetBulkInsertStateParam requestParam) { - return retry(()-> super.getBulkInsertState(requestParam)); + return retry(() -> super.getBulkInsertState(requestParam)); } @Override public R listBulkInsertTasks(ListBulkInsertTasksParam requestParam) { - return retry(()-> super.listBulkInsertTasks(requestParam)); + return retry(() -> super.listBulkInsertTasks(requestParam)); } @Override @@ -820,82 +823,82 @@ public R getVersion() { @Override public R getLoadingProgress(GetLoadingProgressParam requestParam) { - return retry(()-> super.getLoadingProgress(requestParam)); + return retry(() -> super.getLoadingProgress(requestParam)); } @Override public R getLoadState(GetLoadStateParam requestParam) { - return retry(()-> super.getLoadState(requestParam)); + return retry(() -> super.getLoadState(requestParam)); } @Override public R createResourceGroup(CreateResourceGroupParam requestParam) { - return retry(()-> super.createResourceGroup(requestParam)); + return retry(() -> super.createResourceGroup(requestParam)); } @Override public R dropResourceGroup(DropResourceGroupParam requestParam) { - return retry(()-> super.dropResourceGroup(requestParam)); + return retry(() -> super.dropResourceGroup(requestParam)); } @Override public R listResourceGroups(ListResourceGroupsParam requestParam) { - return retry(()-> super.listResourceGroups(requestParam)); + return retry(() -> super.listResourceGroups(requestParam)); } @Override public R describeResourceGroup(DescribeResourceGroupParam requestParam) { - return retry(()-> super.describeResourceGroup(requestParam)); + return retry(() -> super.describeResourceGroup(requestParam)); } @Override public R transferNode(TransferNodeParam requestParam) { - return retry(()-> super.transferNode(requestParam)); + return retry(() -> super.transferNode(requestParam)); } @Override public R transferReplica(TransferReplicaParam requestParam) { - return retry(()-> super.transferReplica(requestParam)); + return retry(() -> super.transferReplica(requestParam)); } @Override public R updateResourceGroups(UpdateResourceGroupsParam requestParam) { - return retry(()-> super.updateResourceGroups(requestParam)); + return retry(() -> super.updateResourceGroups(requestParam)); } @Override public R createCollection(CreateSimpleCollectionParam requestParam) { - return retry(()-> super.createCollection(requestParam)); + return retry(() -> super.createCollection(requestParam)); } @Override public R listCollections(ListCollectionsParam requestParam) { - return retry(()-> super.listCollections(requestParam)); + return retry(() -> super.listCollections(requestParam)); } @Override public R insert(InsertRowsParam requestParam) { - return retry(()-> super.insert(requestParam)); + return retry(() -> super.insert(requestParam)); } @Override public R delete(DeleteIdsParam requestParam) { - return retry(()-> super.delete(requestParam)); + return retry(() -> super.delete(requestParam)); } @Override public R get(GetIdsParam requestParam) { - return retry(()-> super.get(requestParam)); + return retry(() -> super.get(requestParam)); } @Override public R query(QuerySimpleParam requestParam) { - return retry(()-> super.query(requestParam)); + return retry(() -> super.query(requestParam)); } @Override public R search(SearchSimpleParam requestParam) { - return retry(()-> super.search(requestParam)); + return retry(() -> super.search(requestParam)); } @Override diff --git a/sdk-core/src/main/java/io/milvus/common/clientenum/FunctionType.java b/sdk-core/src/main/java/io/milvus/common/clientenum/FunctionType.java index 3f343d67a..26b6ed714 100644 --- a/sdk-core/src/main/java/io/milvus/common/clientenum/FunctionType.java +++ b/sdk-core/src/main/java/io/milvus/common/clientenum/FunctionType.java @@ -28,7 +28,7 @@ public enum FunctionType { private final String name; private final int code; - FunctionType(String name, int code){ + FunctionType(String name, int code) { this.name = name; this.code = code; } diff --git a/sdk-core/src/main/java/io/milvus/common/constant/MilvusClientConstant.java b/sdk-core/src/main/java/io/milvus/common/constant/MilvusClientConstant.java index 56d6734d6..a40d800be 100644 --- a/sdk-core/src/main/java/io/milvus/common/constant/MilvusClientConstant.java +++ b/sdk-core/src/main/java/io/milvus/common/constant/MilvusClientConstant.java @@ -28,6 +28,7 @@ public static class MilvusConsts { public final static String CLOUD_SERVERLESS_URI_REGEX = "^(https://in03-.{20,}zilliz.*.(com|cn))|(https://in0\\d{1}-.{15,}serverless.*zilliz.*.(com|cn))$"; } + public static class StringValue { public final static String COLON = ":"; public final static String DOUBLE_SLASH = "//"; diff --git a/sdk-core/src/main/java/io/milvus/common/resourcegroup/NodeInfo.java b/sdk-core/src/main/java/io/milvus/common/resourcegroup/NodeInfo.java index 5eb15604b..0f9987644 100644 --- a/sdk-core/src/main/java/io/milvus/common/resourcegroup/NodeInfo.java +++ b/sdk-core/src/main/java/io/milvus/common/resourcegroup/NodeInfo.java @@ -19,8 +19,6 @@ package io.milvus.common.resourcegroup; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class NodeInfo { private Long nodeId; private String address; @@ -56,26 +54,6 @@ public void setHostname(String hostname) { this.hostname = hostname; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - NodeInfo nodeInfo = (NodeInfo) obj; - return new EqualsBuilder() - .append(nodeId, nodeInfo.nodeId) - .append(address, nodeInfo.address) - .append(hostname, nodeInfo.hostname) - .isEquals(); - } - - @Override - public int hashCode() { - int result = nodeId != null ? nodeId.hashCode() : 0; - result = 31 * result + (address != null ? address.hashCode() : 0); - result = 31 * result + (hostname != null ? hostname.hashCode() : 0); - return result; - } - @Override public String toString() { return "NodeInfo{" + @@ -94,7 +72,8 @@ public static class Builder { private String address; private String hostname; - private Builder() {} + private Builder() { + } public Builder nodeId(Long nodeId) { this.nodeId = nodeId; diff --git a/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupConfig.java b/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupConfig.java index 128036fc7..17f8323ed 100644 --- a/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupConfig.java +++ b/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupConfig.java @@ -19,10 +19,9 @@ package io.milvus.common.resourcegroup; -import java.util.stream.Collectors; -import java.util.List; import java.util.ArrayList; -import org.apache.commons.lang3.builder.EqualsBuilder; +import java.util.List; +import java.util.stream.Collectors; public class ResourceGroupConfig { private final ResourceGroupLimit requests; @@ -93,7 +92,7 @@ public Builder withLimits(ResourceGroupLimit limits) { /** * Set the transfer from list. - * + * * @param from missing node should be transfer from given resource group at high priority in repeated list. * @return Builder */ @@ -107,7 +106,7 @@ public Builder withFrom(List from) { /** * Set the transfer to list. - * + * * @param to redundant node should be transfer to given resource group at high priority in repeated list. * @return Builder */ @@ -121,6 +120,7 @@ public Builder withTo(List to) { /** * Set the node filter. + * * @param nodeFilter if node filter set, resource group will prefer to accept node which match node filter. * @return Builder */ @@ -194,30 +194,6 @@ public io.milvus.grpc.ResourceGroupConfig toGRPC() { return builder.build(); } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ResourceGroupConfig that = (ResourceGroupConfig) obj; - return new EqualsBuilder() - .append(requests, that.requests) - .append(limits, that.limits) - .append(from, that.from) - .append(to, that.to) - .append(nodeFilter, that.nodeFilter) - .isEquals(); - } - - @Override - public int hashCode() { - int result = requests != null ? requests.hashCode() : 0; - result = 31 * result + (limits != null ? limits.hashCode() : 0); - result = 31 * result + (from != null ? from.hashCode() : 0); - result = 31 * result + (to != null ? to.hashCode() : 0); - result = 31 * result + (nodeFilter != null ? nodeFilter.hashCode() : 0); - return result; - } - @Override public String toString() { return "ResourceGroupConfig{" + diff --git a/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupLimit.java b/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupLimit.java index 8aaf26764..b49227832 100644 --- a/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupLimit.java +++ b/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupLimit.java @@ -19,14 +19,12 @@ package io.milvus.common.resourcegroup; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class ResourceGroupLimit { private Integer nodeNum; /** * Constructor with node number. - * + * * @param nodeNum query node number in this group */ public ResourceGroupLimit(Integer nodeNum) { @@ -38,7 +36,7 @@ public ResourceGroupLimit(Integer nodeNum) { /** * Constructor from grpc - * + * * @param grpcLimit grpc object to set limit of node number */ public ResourceGroupLimit(io.milvus.grpc.ResourceGroupLimit grpcLimit) { @@ -50,7 +48,7 @@ public ResourceGroupLimit(io.milvus.grpc.ResourceGroupLimit grpcLimit) { /** * Transfer to grpc - * + * * @return io.milvus.grpc.ResourceGroupLimit */ public io.milvus.grpc.ResourceGroupLimit toGRPC() { @@ -71,23 +69,4 @@ public String toString() { "nodeNum=" + nodeNum + '}'; } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - ResourceGroupLimit that = (ResourceGroupLimit) obj; - return new EqualsBuilder() - .append(nodeNum, that.nodeNum) - .isEquals(); - } - - @Override - public int hashCode() { - return nodeNum != null ? nodeNum.hashCode() : 0; - } } diff --git a/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupNodeFilter.java b/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupNodeFilter.java index f73cfc6eb..df35659a6 100644 --- a/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupNodeFilter.java +++ b/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupNodeFilter.java @@ -19,16 +19,14 @@ package io.milvus.common.resourcegroup; +import io.milvus.grpc.KeyValuePair; +import io.milvus.param.ParamUtils; + import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.stream.Collectors; -import io.milvus.grpc.KeyValuePair; -import io.milvus.param.ParamUtils; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class ResourceGroupNodeFilter { private final Map nodeLabels; @@ -38,6 +36,7 @@ private ResourceGroupNodeFilter(Builder builder) { /** * Constructor from grpc + * * @param filter grpc filter object */ public ResourceGroupNodeFilter(io.milvus.grpc.ResourceGroupNodeFilter filter) { @@ -53,6 +52,7 @@ public static Builder newBuilder() { /** * Create ResourceGroupNodeFilter from grpc object + * * @param filter grpc filter object * @return ResourceGroupNodeFilter instance */ @@ -67,13 +67,14 @@ public Map getNodeLabels() { public static class Builder { private Map nodeLabels = new HashMap<>(); - + private Builder() { } /** * Set the node label filter - * @param key label name + * + * @param key label name * @param value label value * @return Builder */ @@ -96,6 +97,7 @@ public ResourceGroupNodeFilter build() { /** * Transfer to grpc + * * @return io.milvus.grpc.ResourceGroupNodeFilter */ public io.milvus.grpc.ResourceGroupNodeFilter toGRPC() { @@ -103,7 +105,7 @@ public io.milvus.grpc.ResourceGroupNodeFilter toGRPC() { io.milvus.grpc.ResourceGroupNodeFilter result = io.milvus.grpc.ResourceGroupNodeFilter.newBuilder() .addAllNodeLabels(pair) .build(); - + // Replace @NonNull logic with explicit null check if (result == null) { throw new IllegalStateException("Failed to create GRPC ResourceGroupNodeFilter"); @@ -111,25 +113,6 @@ public io.milvus.grpc.ResourceGroupNodeFilter toGRPC() { return result; } - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - ResourceGroupNodeFilter that = (ResourceGroupNodeFilter) obj; - return new EqualsBuilder() - .append(nodeLabels, that.nodeLabels) - .isEquals(); - } - - @Override - public int hashCode() { - return Objects.hash(nodeLabels); - } - @Override public String toString() { return "ResourceGroupNodeFilter{" + diff --git a/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupTransfer.java b/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupTransfer.java index 11e5b0f3b..847e0ae09 100644 --- a/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupTransfer.java +++ b/sdk-core/src/main/java/io/milvus/common/resourcegroup/ResourceGroupTransfer.java @@ -24,7 +24,7 @@ public class ResourceGroupTransfer { /** * Constructor with resource group name. - * + * * @param resourceGroupName resource group name */ public ResourceGroupTransfer(String resourceGroupName) { @@ -36,7 +36,7 @@ public ResourceGroupTransfer(String resourceGroupName) { /** * Constructor from grpc - * + * * @param grpcTransfer grpc transfer object */ public ResourceGroupTransfer(io.milvus.grpc.ResourceGroupTransfer grpcTransfer) { @@ -48,7 +48,7 @@ public ResourceGroupTransfer(io.milvus.grpc.ResourceGroupTransfer grpcTransfer) /** * Get resource group name - * + * * @return resource group name */ public String getResourceGroupName() { @@ -57,14 +57,14 @@ public String getResourceGroupName() { /** * Transfer to grpc - * + * * @return io.milvus.grpc.ResourceGroupTransfer */ public io.milvus.grpc.ResourceGroupTransfer toGRPC() { io.milvus.grpc.ResourceGroupTransfer result = io.milvus.grpc.ResourceGroupTransfer.newBuilder() .setResourceGroup(resourceGroupName) .build(); - + if (result == null) { throw new IllegalStateException("Failed to create GRPC ResourceGroupTransfer"); } diff --git a/sdk-core/src/main/java/io/milvus/common/utils/Float16Utils.java b/sdk-core/src/main/java/io/milvus/common/utils/Float16Utils.java index 60d646d1e..1ec374f79 100644 --- a/sdk-core/src/main/java/io/milvus/common/utils/Float16Utils.java +++ b/sdk-core/src/main/java/io/milvus/common/utils/Float16Utils.java @@ -9,7 +9,7 @@ public class Float16Utils { /** * Converts a float32 into bf16. May not produce correct values for subnormal floats. - * + *

* This method is copied from microsoft ONNX Runtime: * https://github.com/microsoft/onnxruntime/blob/main/java/src/main/jvm/ai/onnxruntime/platform/Fp16Conversions.java * @@ -26,7 +26,7 @@ public static short floatToBf16(float input) { /** * Upcasts a bf16 value stored in a short into a float32 value. - * + *

* This method is copied from microsoft ONNX Runtime: * https://github.com/microsoft/onnxruntime/blob/main/java/src/main/jvm/ai/onnxruntime/platform/Fp16Conversions.java * @@ -40,7 +40,7 @@ public static float bf16ToFloat(short input) { /** * Rounds a float32 value to a fp16 stored in a short. - * + *

* This method is copied from microsoft ONNX Runtime: * https://github.com/microsoft/onnxruntime/blob/main/java/src/main/jvm/ai/onnxruntime/platform/Fp16Conversions.java * @@ -94,7 +94,7 @@ public static short floatToFp16(float input) { /** * Upcasts a fp16 value stored in a short to a float32 value. - * + *

* This method is copied from microsoft ONNX Runtime: * https://github.com/microsoft/onnxruntime/blob/main/java/src/main/jvm/ai/onnxruntime/platform/Fp16Conversions.java * diff --git a/sdk-core/src/main/java/io/milvus/common/utils/GTsDict.java b/sdk-core/src/main/java/io/milvus/common/utils/GTsDict.java index 60773b588..72a08cd45 100644 --- a/sdk-core/src/main/java/io/milvus/common/utils/GTsDict.java +++ b/sdk-core/src/main/java/io/milvus/common/utils/GTsDict.java @@ -34,7 +34,8 @@ public class GTsDict { // be passed to construct a guarantee_ts to the server. private final static GTsDict TS_DICT = new GTsDict(); - private GTsDict(){} + private GTsDict() { + } public static GTsDict getInstance() { return TS_DICT; diff --git a/sdk-core/src/main/java/io/milvus/common/utils/JsonUtils.java b/sdk-core/src/main/java/io/milvus/common/utils/JsonUtils.java index afe9f0ffa..687d7aa4a 100644 --- a/sdk-core/src/main/java/io/milvus/common/utils/JsonUtils.java +++ b/sdk-core/src/main/java/io/milvus/common/utils/JsonUtils.java @@ -19,7 +19,10 @@ package io.milvus.common.utils; -import com.google.gson.*; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.ToNumberPolicy; import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; diff --git a/sdk-core/src/main/java/io/milvus/common/utils/URLParser.java b/sdk-core/src/main/java/io/milvus/common/utils/URLParser.java index 702687e13..230f518eb 100644 --- a/sdk-core/src/main/java/io/milvus/common/utils/URLParser.java +++ b/sdk-core/src/main/java/io/milvus/common/utils/URLParser.java @@ -49,7 +49,7 @@ public URLParser(String url) { // port port = uri.getPort(); - if(port <= 0){ + if (port <= 0) { port = 19530; } diff --git a/sdk-core/src/main/java/io/milvus/exception/IllegalResponseException.java b/sdk-core/src/main/java/io/milvus/exception/IllegalResponseException.java index d5ac6abbf..dd7740311 100644 --- a/sdk-core/src/main/java/io/milvus/exception/IllegalResponseException.java +++ b/sdk-core/src/main/java/io/milvus/exception/IllegalResponseException.java @@ -23,7 +23,7 @@ import io.milvus.param.R; /** - * Interfaces including search/search/loadCollection might + * Interfaces including search/search/loadCollection might * throw this exception when server return illegal response. It may indicate a bug in server. */ public class IllegalResponseException extends MilvusException { diff --git a/sdk-core/src/main/java/io/milvus/exception/ServerException.java b/sdk-core/src/main/java/io/milvus/exception/ServerException.java index 15e303e2c..b30513d72 100644 --- a/sdk-core/src/main/java/io/milvus/exception/ServerException.java +++ b/sdk-core/src/main/java/io/milvus/exception/ServerException.java @@ -20,13 +20,13 @@ package io.milvus.exception; import io.milvus.grpc.ErrorCode; -import io.milvus.param.R; /** * Exception for error response from server side. */ public class ServerException extends MilvusException { protected ErrorCode compatibleCode; + public ServerException(String msg, Integer code, ErrorCode compatibleCode) { super(msg, code); this.compatibleCode = compatibleCode; diff --git a/sdk-core/src/main/java/io/milvus/orm/iterator/IteratorAdapterV2.java b/sdk-core/src/main/java/io/milvus/orm/iterator/IteratorAdapterV2.java index 479d9316a..952e334a6 100644 --- a/sdk-core/src/main/java/io/milvus/orm/iterator/IteratorAdapterV2.java +++ b/sdk-core/src/main/java/io/milvus/orm/iterator/IteratorAdapterV2.java @@ -25,8 +25,8 @@ import io.milvus.grpc.PlaceholderType; import io.milvus.param.MetricType; import io.milvus.param.collection.FieldType; -import io.milvus.param.dml.SearchIteratorParam; import io.milvus.param.dml.QueryIteratorParam; +import io.milvus.param.dml.SearchIteratorParam; import io.milvus.v2.common.IndexParam; import io.milvus.v2.service.collection.request.CreateCollectionReq; import io.milvus.v2.service.vector.request.QueryIteratorReq; @@ -58,6 +58,7 @@ public static QueryIteratorParam convertV2Req(QueryIteratorReq queryIteratorReq) return builder.build(); } + public static SearchIteratorParam convertV2Req(SearchIteratorReq searchIteratorReq) { MetricType metricType = MetricType.None; if (searchIteratorReq.getMetricType() != IndexParam.MetricType.INVALID) { @@ -94,31 +95,31 @@ public static SearchIteratorParam convertV2Req(SearchIteratorReq searchIteratorR switch (plType) { case FloatVector: { List> data = new ArrayList<>(); - vectors.forEach(vector->data.add((List)vector.getData())); + vectors.forEach(vector -> data.add((List) vector.getData())); builder.withFloatVectors(data); break; } case BinaryVector: { List data = new ArrayList<>(); - vectors.forEach(vector->data.add((ByteBuffer)vector.getData())); + vectors.forEach(vector -> data.add((ByteBuffer) vector.getData())); builder.withBinaryVectors(data); break; } case Float16Vector: { List data = new ArrayList<>(); - vectors.forEach(vector -> data.add((ByteBuffer)vector.getData())); + vectors.forEach(vector -> data.add((ByteBuffer) vector.getData())); builder.withFloat16Vectors(data); break; } case BFloat16Vector: { List data = new ArrayList<>(); - vectors.forEach(vector -> data.add((ByteBuffer)vector.getData())); + vectors.forEach(vector -> data.add((ByteBuffer) vector.getData())); builder.withBFloat16Vectors(data); break; } case SparseFloatVector: { List> data = new ArrayList<>(); - vectors.forEach(vector -> data.add((SortedMap)vector.getData())); + vectors.forEach(vector -> data.add((SortedMap) vector.getData())); builder.withSparseFloatVectors(data); break; } diff --git a/sdk-core/src/main/java/io/milvus/orm/iterator/QueryIterator.java b/sdk-core/src/main/java/io/milvus/orm/iterator/QueryIterator.java index 3d0c0c69d..a62fe7259 100644 --- a/sdk-core/src/main/java/io/milvus/orm/iterator/QueryIterator.java +++ b/sdk-core/src/main/java/io/milvus/orm/iterator/QueryIterator.java @@ -36,9 +36,7 @@ import java.util.ArrayList; import java.util.List; -import static io.milvus.param.Constant.NO_CACHE_ID; -import static io.milvus.param.Constant.MAX_BATCH_SIZE; -import static io.milvus.param.Constant.UNLIMITED; +import static io.milvus.param.Constant.*; public class QueryIterator { protected static final Logger logger = LoggerFactory.getLogger(RpcUtils.class); @@ -200,7 +198,7 @@ private String setupNextExpr() { if (StringUtils.isEmpty(currentExpr)) { return filteredPKStr; } - return " ( "+currentExpr+" ) " + " and " + filteredPKStr; + return " ( " + currentExpr + " ) " + " and " + filteredPKStr; } private boolean isResSufficient(List ret) { @@ -247,7 +245,7 @@ private QueryResults executeQuery(String expr, long offset, long limit, long ts, // set default consistency level builder.setUseDefaultConsistency(true); - QueryResults response = rpcUtils.retry(()->blockingStub.query(builder.build())); + QueryResults response = rpcUtils.retry(() -> blockingStub.query(builder.build())); String title = String.format("QueryRequest collectionName:%s", queryIteratorParam.getCollectionName()); rpcUtils.handleResponse(title, response.getStatus()); return response; diff --git a/sdk-core/src/main/java/io/milvus/orm/iterator/SearchIterator.java b/sdk-core/src/main/java/io/milvus/orm/iterator/SearchIterator.java index 829b51a03..84c04c0d9 100644 --- a/sdk-core/src/main/java/io/milvus/orm/iterator/SearchIterator.java +++ b/sdk-core/src/main/java/io/milvus/orm/iterator/SearchIterator.java @@ -44,17 +44,12 @@ import java.nio.ByteBuffer; import java.text.DecimalFormat; -import java.util.*; - -import static io.milvus.param.Constant.DEFAULT_SEARCH_EXTENSION_RATE; -import static io.milvus.param.Constant.EF; -import static io.milvus.param.Constant.MAX_BATCH_SIZE; -import static io.milvus.param.Constant.MAX_FILTERED_IDS_COUNT_ITERATION; -import static io.milvus.param.Constant.MAX_TRY_TIME; -import static io.milvus.param.Constant.NO_CACHE_ID; -import static io.milvus.param.Constant.RADIUS; -import static io.milvus.param.Constant.RANGE_FILTER; -import static io.milvus.param.Constant.UNLIMITED; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.SortedMap; + +import static io.milvus.param.Constant.*; public class SearchIterator { private static final Logger logger = LoggerFactory.getLogger(SearchIterator.class); @@ -168,7 +163,8 @@ private void initParams() { if (null != searchIteratorParam.getParams() && !searchIteratorParam.getParams().isEmpty()) { params = new HashMap<>(); } - params = JsonUtils.fromJson(searchIteratorParam.getParams(), new TypeToken>() {}.getType()); + params = JsonUtils.fromJson(searchIteratorParam.getParams(), new TypeToken>() { + }.getType()); } private void checkForSpecialIndexParam() { @@ -300,7 +296,7 @@ private SearchResults executeSearch(Map params, String nextExpr, // set default consistency level builder.setUseDefaultConsistency(true); - SearchResults response = rpcUtils.retry(()->blockingStub.search(builder.build())); + SearchResults response = rpcUtils.retry(() -> blockingStub.search(builder.build())); String title = String.format("SearchRequest collectionName:%s", searchIteratorParam.getCollectionName()); rpcUtils.handleResponse(title, response.getStatus()); return response; @@ -399,8 +395,8 @@ private List extractPageFromCache(long count) { throw new ParamException(msg); } - List retPageRes = cachedPage.subList(0, (int)count); - List leftCachePage = cachedPage.subList((int)count, cachedPage.size()); + List retPageRes = cachedPage.subList(0, (int) count); + List leftCachePage = cachedPage.subList((int) count, cachedPage.size()); iteratorCache.cache(cacheId, leftCachePage); return retPageRes; @@ -448,7 +444,8 @@ private Map nextParams(int coefficient) { // here we make a new object nextParams, to ensure is it a deep copy, we convert it to JSON string and // convert back to a Map. Map nextParams = JsonUtils.fromJson(JsonUtils.toJson(params), - new TypeToken>() {}.getType()); + new TypeToken>() { + }.getType()); if (metricsPositiveRelated(metricType)) { float nextRadius = tailBand + width * coefficient; diff --git a/sdk-core/src/main/java/io/milvus/orm/iterator/SearchIteratorV2.java b/sdk-core/src/main/java/io/milvus/orm/iterator/SearchIteratorV2.java index 65b5d8937..7add8a429 100644 --- a/sdk-core/src/main/java/io/milvus/orm/iterator/SearchIteratorV2.java +++ b/sdk-core/src/main/java/io/milvus/orm/iterator/SearchIteratorV2.java @@ -33,7 +33,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import java.util.function.Function; import static io.milvus.param.Constant.MAX_BATCH_SIZE; @@ -77,7 +79,7 @@ private void checkParams() { } searchParams = searchIteratorReq.getSearchParams(); - if (searchParams.containsKey(Constant.OFFSET) && (int)searchParams.get(Constant.OFFSET) > 0) { + if (searchParams.containsKey(Constant.OFFSET) && (int) searchParams.get(Constant.OFFSET) > 0) { ExceptionUtils.throwUnExpectedException("Offset is not supported for SearchIterator"); } @@ -99,7 +101,7 @@ private void setupCollectionID() { if (StringUtils.isNotEmpty(searchIteratorReq.getDatabaseName())) { builder.setDbName(searchIteratorReq.getDatabaseName()); } - DescribeCollectionResponse response = rpcUtils.retry(()->this.blockingStub.describeCollection(builder.build())); + DescribeCollectionResponse response = rpcUtils.retry(() -> this.blockingStub.describeCollection(builder.build())); String title = String.format("DescribeCollectionRequest collectionName:%s", searchIteratorReq.getCollectionName()); rpcUtils.handleResponse(title, response.getStatus()); @@ -126,7 +128,7 @@ private SearchResults executeSearch(int limit) { .groupByFieldName(searchIteratorReq.getGroupByFieldName()) .build(); SearchRequest searchRequest = new VectorUtils().ConvertToGrpcSearchRequest(request); - SearchResults response = rpcUtils.retry(()->this.blockingStub.search(searchRequest)); + SearchResults response = rpcUtils.retry(() -> this.blockingStub.search(searchRequest)); String title = String.format("SearchRequest collectionName:%s", searchIteratorReq.getCollectionName()); rpcUtils.handleResponse(title, response.getStatus()); @@ -200,7 +202,7 @@ private List _next() { searchParams.put("search_iter_id", iterInfo.getToken()); } - long ts = (long)searchParams.get("guarantee_timestamp"); + long ts = (long) searchParams.get("guarantee_timestamp"); if (ts <= 0) { if (response.getSessionTs() > 0) { searchParams.put("guarantee_timestamp", response.getSessionTs()); diff --git a/sdk-core/src/main/java/io/milvus/param/ConnectParam.java b/sdk-core/src/main/java/io/milvus/param/ConnectParam.java index 0d3520431..fc252ab06 100644 --- a/sdk-core/src/main/java/io/milvus/param/ConnectParam.java +++ b/sdk-core/src/main/java/io/milvus/param/ConnectParam.java @@ -231,7 +231,7 @@ public static class Builder { //used to set client_request_id in the grpc header uniquely for every request private ThreadLocal clientRequestId; - + private String proxyAddress; protected Builder() { @@ -341,7 +341,7 @@ public Builder withHost(String host) { * @param port port value * @return Builder */ - public Builder withPort(int port) { + public Builder withPort(int port) { this.port = port; return this; } @@ -383,7 +383,7 @@ public Builder withToken(String token) { * Sets the connection timeout value of client channel. The timeout value must be greater than zero. * * @param connectTimeout timeout value - * @param timeUnit timeout unit + * @param timeUnit timeout unit * @return Builder */ public Builder withConnectTimeout(long connectTimeout, TimeUnit timeUnit) { @@ -399,7 +399,7 @@ public Builder withConnectTimeout(long connectTimeout, TimeUnit timeUnit) { * Default is 55000 ms. * * @param keepAliveTime keep-alive value - * @param timeUnit keep-alive unit + * @param timeUnit keep-alive unit * @return Builder */ public Builder withKeepAliveTime(long keepAliveTime, TimeUnit timeUnit) { @@ -415,7 +415,7 @@ public Builder withKeepAliveTime(long keepAliveTime, TimeUnit timeUnit) { * Default value is 20000 ms * * @param keepAliveTimeout timeout value - * @param timeUnit timeout unit + * @param timeUnit timeout unit * @return Builder */ public Builder withKeepAliveTimeout(long keepAliveTimeout, TimeUnit timeUnit) { @@ -439,7 +439,7 @@ public Builder keepAliveWithoutCalls(boolean enable) { /** * Enables the secure for client channel. - * + *

* Deprecated from v2.3.6, this flag is auto-detected, no need to specify * * @param enable true keep-alive @@ -455,7 +455,7 @@ public Builder secure(boolean enable) { * Sets the idle timeout value of client channel. The timeout value must be larger than zero. * * @param idleTimeout timeout value - * @param timeUnit timeout unit + * @param timeUnit timeout unit * @return Builder */ public Builder withIdleTimeout(long idleTimeout, TimeUnit timeUnit) { @@ -485,6 +485,7 @@ public Builder withRpcDeadline(long deadline, TimeUnit timeUnit) { /** * Sets the username and password for this connection + * * @param username current user * @param password password * @return Builder @@ -497,7 +498,7 @@ public Builder withAuthorization(String username, String password) { /** * Sets secure the authorization for this connection, set to True to enable TLS - * + *

* Deprecated from v2.3.6, this flag is auto-detected, no need to specify * * @param secure boolean @@ -511,6 +512,7 @@ public Builder withSecure(boolean secure) { /** * Sets the authorization for this connection + * * @param authorization the encoded authorization info that has included the encoded username and password info * @return Builder */ @@ -524,6 +526,7 @@ public Builder withAuthorization(String authorization) { /** * Set the client.key path for tls two-way authentication, only takes effect when "secure" is True. + * * @param clientKeyPath path of client.key * @return Builder */ @@ -537,6 +540,7 @@ public Builder withClientKeyPath(String clientKeyPath) { /** * Set the client.pem path for tls two-way authentication, only takes effect when "secure" is True. + * * @param clientPemPath path of client.pem * @return Builder */ @@ -550,6 +554,7 @@ public Builder withClientPemPath(String clientPemPath) { /** * Set the ca.pem path for tls two-way authentication, only takes effect when "secure" is True. + * * @param caPemPath path of ca.pem * @return Builder */ @@ -563,6 +568,7 @@ public Builder withCaPemPath(String caPemPath) { /** * Set the server.pem path for tls one-way authentication, only takes effect when "secure" is True. + * * @param serverPemPath path of server.pem * @return Builder */ @@ -577,6 +583,7 @@ public Builder withServerPemPath(String serverPemPath) { /** * Set target name override for SSL host name checking, only takes effect when "secure" is True. * Note: this value is passed to grpc.ssl_target_name_override + * * @param serverName override name for SSL host * @return Builder */ @@ -595,10 +602,10 @@ public Builder withClientRequestId(ThreadLocal clientRequestId) { this.clientRequestId = clientRequestId; return this; } - + /** * Sets the proxy address for connections through a proxy server. - * + * * @param proxyAddress proxy server address in format "host:port" * @return Builder */ @@ -631,7 +638,7 @@ protected void verify() throws ParamException { } } - if(host.startsWith(HOST_HTTPS_PREFIX)){ + if (host.startsWith(HOST_HTTPS_PREFIX)) { this.secure = true; } diff --git a/sdk-core/src/main/java/io/milvus/param/Constant.java b/sdk-core/src/main/java/io/milvus/param/Constant.java index 1987e9974..d9a74c9b1 100644 --- a/sdk-core/src/main/java/io/milvus/param/Constant.java +++ b/sdk-core/src/main/java/io/milvus/param/Constant.java @@ -87,9 +87,9 @@ public class Constant { public static final Long GUARANTEE_STRONG_TS = 0L; // high level api - public static final String VECTOR_FIELD_NAME_DEFAULT = "vector"; + public static final String VECTOR_FIELD_NAME_DEFAULT = "vector"; public static final String PRIMARY_FIELD_NAME_DEFAULT = "id"; - public static final String VECTOR_INDEX_NAME_DEFAULT = "vector_idx"; + public static final String VECTOR_INDEX_NAME_DEFAULT = "vector_idx"; public static final Long LIMIT_DEFAULT = 100L; public static final Long OFFSET_DEFAULT = 0L; public static final String ALL_OUTPUT_FIELDS = "*"; diff --git a/sdk-core/src/main/java/io/milvus/param/IndexType.java b/sdk-core/src/main/java/io/milvus/param/IndexType.java index 083d8d78a..11d513dc3 100644 --- a/sdk-core/src/main/java/io/milvus/param/IndexType.java +++ b/sdk-core/src/main/java/io/milvus/param/IndexType.java @@ -57,23 +57,22 @@ public enum IndexType { // Only for sparse vectors SPARSE_INVERTED_INDEX(300), - SPARSE_WAND(301) - ; + SPARSE_WAND(301); private final String name; private final int code; - IndexType(){ + IndexType() { this.name = this.name(); this.code = this.ordinal(); } - IndexType(int code){ + IndexType(int code) { this.name = this.name(); this.code = code; } - IndexType(String name, int code){ + IndexType(String name, int code) { this.name = name; this.code = code; } diff --git a/sdk-core/src/main/java/io/milvus/param/MultiConnectParam.java b/sdk-core/src/main/java/io/milvus/param/MultiConnectParam.java index 18cb5334e..d333941e7 100644 --- a/sdk-core/src/main/java/io/milvus/param/MultiConnectParam.java +++ b/sdk-core/src/main/java/io/milvus/param/MultiConnectParam.java @@ -124,7 +124,7 @@ public Builder withHost(String host) { * @param port port value * @return Builder */ - public Builder withPort(int port) { + public Builder withPort(int port) { super.withPort(port); return this; } @@ -166,7 +166,7 @@ public Builder withToken(String token) { * Sets the connection timeout value of client channel. The timeout value must be greater than zero. * * @param connectTimeout timeout value - * @param timeUnit timeout unit + * @param timeUnit timeout unit * @return Builder */ public Builder withConnectTimeout(long connectTimeout, TimeUnit timeUnit) { @@ -181,7 +181,7 @@ public Builder withConnectTimeout(long connectTimeout, TimeUnit timeUnit) { * Sets the keep-alive time value of client channel. The keep-alive value must be greater than zero. * * @param keepAliveTime keep-alive value - * @param timeUnit keep-alive unit + * @param timeUnit keep-alive unit * @return Builder */ public Builder withKeepAliveTime(long keepAliveTime, TimeUnit timeUnit) { @@ -196,7 +196,7 @@ public Builder withKeepAliveTime(long keepAliveTime, TimeUnit timeUnit) { * Sets the keep-alive timeout value of client channel. The timeout value must be greater than zero. * * @param keepAliveTimeout timeout value - * @param timeUnit timeout unit + * @param timeUnit timeout unit * @return Builder */ public Builder withKeepAliveTimeout(long keepAliveTimeout, TimeUnit timeUnit) { @@ -222,7 +222,7 @@ public Builder keepAliveWithoutCalls(boolean enable) { * Sets the idle timeout value of client channel. The timeout value must be larger than zero. * * @param idleTimeout timeout value - * @param timeUnit timeout unit + * @param timeUnit timeout unit * @return Builder */ public Builder withIdleTimeout(long idleTimeout, TimeUnit timeUnit) { @@ -252,6 +252,7 @@ public Builder withRpcDeadline(long deadline, TimeUnit timeUnit) { /** * Sets the username and password for this connection + * * @param username current user * @param password password * @return Builder @@ -263,6 +264,7 @@ public Builder withAuthorization(String username, String password) { /** * Sets secure the authorization for this connection, set to True to enable TLS + * * @param secure boolean * @return Builder */ @@ -273,6 +275,7 @@ public Builder withSecure(boolean secure) { /** * Sets the secure for this connection + * * @param authorization the authorization info that has included the encoded username and password info * @return Builder */ @@ -286,6 +289,7 @@ public Builder withAuthorization(String authorization) { /** * Set the client.key path for tls two-way authentication, only takes effect when "secure" is True. + * * @param clientKeyPath path of client.key * @return Builder */ @@ -299,6 +303,7 @@ public Builder withClientKeyPath(String clientKeyPath) { /** * Set the client.pem path for tls two-way authentication, only takes effect when "secure" is True. + * * @param clientPemPath path of client.pem * @return Builder */ @@ -312,6 +317,7 @@ public Builder withClientPemPath(String clientPemPath) { /** * Set the ca.pem path for tls two-way authentication, only takes effect when "secure" is True. + * * @param caPemPath path of ca.pem * @return Builder */ @@ -325,6 +331,7 @@ public Builder withCaPemPath(String caPemPath) { /** * Set the server.pem path for tls two-way authentication, only takes effect when "secure" is True. + * * @param serverPemPath path of server.pem * @return Builder */ @@ -339,6 +346,7 @@ public Builder withServerPemPath(String serverPemPath) { /** * Set target name override for SSL host name checking, only takes effect when "secure" is True. * Note: this value is passed to grpc.ssl_target_name_override + * * @param serverName path of server.pem * @return Builder */ @@ -366,10 +374,10 @@ public MultiConnectParam build() throws ParamException { for (ServerAddress serverAddress : hosts) { String host = serverAddress.getHost(); ParamUtils.CheckNullEmptyString(host, "Host name"); - if(host.startsWith(HOST_HTTPS_PREFIX)){ + if (host.startsWith(HOST_HTTPS_PREFIX)) { host = host.replace(HOST_HTTPS_PREFIX, ""); this.secure = true; - }else if(host.startsWith(HOST_HTTP_PREFIX)){ + } else if (host.startsWith(HOST_HTTP_PREFIX)) { host = host.replace(HOST_HTTP_PREFIX, ""); } hostAddress.add(ServerAddress.newBuilder() diff --git a/sdk-core/src/main/java/io/milvus/param/ParamUtils.java b/sdk-core/src/main/java/io/milvus/param/ParamUtils.java index 540423720..0bdba579c 100644 --- a/sdk-core/src/main/java/io/milvus/param/ParamUtils.java +++ b/sdk-core/src/main/java/io/milvus/param/ParamUtils.java @@ -98,15 +98,15 @@ public static void checkFieldData(FieldType fieldSchema, InsertParam.Field field public static int calculateBinVectorDim(DataType dataType, int byteCount) { if (dataType == DataType.BinaryVector) { - return byteCount*8; // for BinaryVector, each byte is 8 dimensions + return byteCount * 8; // for BinaryVector, each byte is 8 dimensions } else if (dataType == DataType.Int8Vector) { return byteCount; // for Int8Vector, each byte is one dimension } else { - if (byteCount%2 != 0) { + if (byteCount % 2 != 0) { String msg = "Incorrect byte count for %s type field, byte count is %d, cannot be evenly divided by 2"; throw new ParamException(String.format(msg, dataType.name(), byteCount)); } - return byteCount/2; // for float16/bfloat16, each dimension is 2 bytes + return byteCount / 2; // for float16/bfloat16, each dimension is 2 bytes } } @@ -155,12 +155,12 @@ public static void checkFieldData(FieldType fieldSchema, List values, boolean int dim = fieldSchema.getDimension(); for (int i = 0; i < values.size(); ++i) { // is List<> ? - Object value = values.get(i); + Object value = values.get(i); if (!(value instanceof List)) { throw new ParamException(String.format(errMsgs.get(dataType), fieldSchema.getName())); } // is List ? - List temp = (List)value; + List temp = (List) value; for (Object v : temp) { if (!(v instanceof Float)) { throw new ParamException(String.format(errMsgs.get(dataType), fieldSchema.getName())); @@ -180,14 +180,14 @@ public static void checkFieldData(FieldType fieldSchema, List values, boolean case BFloat16Vector: { int dim = fieldSchema.getDimension(); for (int i = 0; i < values.size(); ++i) { - Object value = values.get(i); + Object value = values.get(i); // is ByteBuffer? if (!(value instanceof ByteBuffer)) { throw new ParamException(String.format(errMsgs.get(dataType), fieldSchema.getName())); } // check dimension - ByteBuffer v = (ByteBuffer)value; + ByteBuffer v = (ByteBuffer) value; int real_dim = calculateBinVectorDim(dataType, v.limit()); if (real_dim != dim) { String msg = "Incorrect dimension for field '%s': the no.%d vector's dimension: %d is not equal to field's dimension: %d"; @@ -203,7 +203,7 @@ public static void checkFieldData(FieldType fieldSchema, List values, boolean } // is SortedMap ? - SortedMap m = (SortedMap)value; + SortedMap m = (SortedMap) value; if (m.isEmpty()) { // not allow empty value for sparse vector String msg = "Not allow empty SortedMap for sparse vector field '%s'"; throw new ParamException(String.format(msg, fieldSchema.getName())); @@ -300,7 +300,7 @@ public static void checkFieldData(FieldType fieldSchema, List values, boolean throw new ParamException(String.format(errMsgs.get(dataType), fieldSchema.getName())); } - List array = (List)value; + List array = (List) value; if (array.size() > fieldSchema.getMaxCapacity()) { throw new ParamException(String.format(errMsgs.get(dataType), fieldSchema.getName())); } @@ -346,7 +346,8 @@ public static Object checkFieldValue(String fieldName, DataType dataType, DataTy throw new ParamException(String.format(errMsgs.get(dataType), fieldName)); } try { - List vector = JsonUtils.fromJson(value, new TypeToken>() {}.getType()); + List vector = JsonUtils.fromJson(value, new TypeToken>() { + }.getType()); if (vector.size() != dim) { String msg = "Incorrect dimension for field '%s': dimension: %d is not equal to field's dimension: %d"; throw new ParamException(String.format(msg, fieldName, vector.size(), dim)); @@ -365,7 +366,8 @@ public static Object checkFieldValue(String fieldName, DataType dataType, DataTy throw new ParamException(String.format(errMsgs.get(dataType), fieldName)); } try { - byte[] v = JsonUtils.fromJson(value, new TypeToken() {}.getType()); + byte[] v = JsonUtils.fromJson(value, new TypeToken() { + }.getType()); int real_dim = calculateBinVectorDim(dataType, v.length); if (real_dim != dim) { String msg = "Incorrect dimension for field '%s': dimension: %d is not equal to field's dimension: %d"; @@ -383,7 +385,8 @@ public static Object checkFieldValue(String fieldName, DataType dataType, DataTy } try { // return SortedMap for genFieldData() - return JsonUtils.fromJson(value, new TypeToken>() {}.getType()); + return JsonUtils.fromJson(value, new TypeToken>() { + }.getType()); } catch (JsonSyntaxException e) { throw new ParamException(String.format("Unable to convert JsonObject to SortedMap for field '%s'. Reason: %s", fieldName, e.getCause().getMessage())); @@ -453,19 +456,25 @@ public static List convertJsonArray(JsonArray jsonArray, DataType elemen try { switch (elementType) { case Int64: - return JsonUtils.fromJson(jsonArray, new TypeToken>() {}.getType()); + return JsonUtils.fromJson(jsonArray, new TypeToken>() { + }.getType()); case Int32: case Int16: case Int8: - return JsonUtils.fromJson(jsonArray, new TypeToken>() {}.getType()); + return JsonUtils.fromJson(jsonArray, new TypeToken>() { + }.getType()); case Bool: - return JsonUtils.fromJson(jsonArray, new TypeToken>() {}.getType()); + return JsonUtils.fromJson(jsonArray, new TypeToken>() { + }.getType()); case Float: - return JsonUtils.fromJson(jsonArray, new TypeToken>() {}.getType()); + return JsonUtils.fromJson(jsonArray, new TypeToken>() { + }.getType()); case Double: - return JsonUtils.fromJson(jsonArray, new TypeToken>() {}.getType()); + return JsonUtils.fromJson(jsonArray, new TypeToken>() { + }.getType()); case VarChar: - return JsonUtils.fromJson(jsonArray, new TypeToken>() {}.getType()); + return JsonUtils.fromJson(jsonArray, new TypeToken>() { + }.getType()); default: throw new ParamException(String.format("Unsupported element type of Array field '%s'", fieldName)); } @@ -480,7 +489,7 @@ public static List convertJsonArray(JsonArray jsonArray, DataType elemen * Throws {@link ParamException} if the string is empty of null. * * @param target target string - * @param name a name to describe this string + * @param name a name to describe this string */ public static void CheckNullEmptyString(String target, String name) throws ParamException { if (target == null || StringUtils.isBlank(target)) { @@ -493,7 +502,7 @@ public static void CheckNullEmptyString(String target, String name) throws Param * Throws {@link ParamException} if the string is null. * * @param target target string - * @param name a name to describe this string + * @param name a name to describe this string */ public static void CheckNullString(String target, String name) throws ParamException { if (target == null) { @@ -640,11 +649,11 @@ private void checkAndSetRowData(DescCollResponseWrapper wrapper, List nameInsertInfo = new HashMap<>(); InsertDataInfo insertDynamicDataInfo = InsertDataInfo.builder().fieldType( - FieldType.newBuilder() - .withName(Constant.DYNAMIC_FIELD_NAME) - .withDataType(DataType.JSON) - .withIsDynamic(true) - .build()) + FieldType.newBuilder() + .withName(Constant.DYNAMIC_FIELD_NAME) + .withDataType(DataType.JSON) + .withIsDynamic(true) + .build()) .data(new LinkedList<>()).build(); for (JsonObject row : rows) { for (FieldType fieldType : fieldTypes) { @@ -876,7 +885,8 @@ public static SearchRequest convertSearchParam(SearchParam requestParam) throws if (null != requestParam.getParams() && !requestParam.getParams().isEmpty()) { try { Map paramMap = JsonUtils.fromJson(requestParam.getParams(), - new TypeToken>() {}.getType()); + new TypeToken>() { + }.getType()); compatibleSearchParams(paramMap, builder); String offset = paramMap.getOrDefault(Constant.OFFSET, 0).toString(); @@ -893,10 +903,10 @@ public static SearchRequest convertSearchParam(SearchParam requestParam) throws // the following parameters are not changed // just note: if the searchParams already contains the same key, the following parameters will overwrite it builder.addSearchParams( - KeyValuePair.newBuilder() - .setKey(Constant.VECTOR_FIELD) - .setValue(requestParam.getVectorFieldName()) - .build()) + KeyValuePair.newBuilder() + .setKey(Constant.VECTOR_FIELD) + .setValue(requestParam.getVectorFieldName()) + .build()) .addSearchParams( KeyValuePair.newBuilder() .setKey(Constant.TOP_K) @@ -981,7 +991,8 @@ public static SearchRequest convertAnnSearchParam(AnnSearchParam annSearchParam, // tries to fit the compatibility between v2.5.1 and older versions Map paramMap = new HashMap<>(); if (null != annSearchParam.getParams() && !annSearchParam.getParams().isEmpty()) { - paramMap = JsonUtils.fromJson(annSearchParam.getParams(), new TypeToken>() {}.getType()); + paramMap = JsonUtils.fromJson(annSearchParam.getParams(), new TypeToken>() { + }.getType()); } ParamUtils.compatibleSearchParams(paramMap, builder); @@ -1144,13 +1155,13 @@ public static QueryRequest convertQueryParam(QueryParam requestParam) { return builder.build(); } - private static long getGuaranteeTimestamp(ConsistencyLevelEnum consistencyLevel, String dbName, String collectionName){ - if(consistencyLevel == null){ + private static long getGuaranteeTimestamp(ConsistencyLevelEnum consistencyLevel, String dbName, String collectionName) { + if (consistencyLevel == null) { String key = GTsDict.CombineCollectionName(dbName, collectionName); Long ts = GTsDict.getInstance().getCollectionTs(key); - return (ts == null) ? 1L : ts; + return (ts == null) ? 1L : ts; } - switch (consistencyLevel){ + switch (consistencyLevel) { case STRONG: return 0L; case SESSION: { @@ -1263,7 +1274,7 @@ public static VectorField genVectorField(DataType dataType, List objects) { } else { return VectorField.newBuilder().setDim(dim).setInt8Vector(byteString).build(); } - } else if (dataType == DataType.SparseFloatVector) { + } else if (dataType == DataType.SparseFloatVector) { SparseFloatArray sparseArray = genSparseFloatArray(objects); return VectorField.newBuilder().setDim(sparseArray.getDim()).setSparseFloatVector(sparseArray).build(); } @@ -1277,7 +1288,7 @@ public static ByteBuffer encodeSparseFloatVector(SortedMap sparse) buf.order(ByteOrder.LITTLE_ENDIAN); for (Map.Entry entry : sparse.entrySet()) { long k = entry.getKey(); - if (k < 0 || k >= (long)Math.pow(2.0, 32.0)-1) { + if (k < 0 || k >= (long) Math.pow(2.0, 32.0) - 1) { throw new ParamException("Sparse vector index must be positive and less than 2^32-1"); } // here we construct a binary from the long key @@ -1301,13 +1312,13 @@ public static ByteBuffer encodeSparseFloatVector(SortedMap sparse) public static SortedMap decodeSparseFloatVector(ByteBuffer buf) { buf.order(ByteOrder.LITTLE_ENDIAN); SortedMap sparse = new TreeMap<>(); - long num = buf.limit()/8; // each uint+float pair is 8 bytes + long num = buf.limit() / 8; // each uint+float pair is 8 bytes for (long j = 0; j < num; j++) { // here we convert an uint 4-bytes to a long value // milvus server requires sparse vector to be transfered in little endian ByteBuffer pBuf = ByteBuffer.allocate(Long.BYTES); pBuf.order(ByteOrder.LITTLE_ENDIAN); - int offset = 8*(int)j; + int offset = 8 * (int) j; byte[] aa = buf.array(); for (int k = offset; k < offset + 4; k++) { pBuf.put(aa[k]); // fill the first 4 bytes with the unit bytes @@ -1317,7 +1328,7 @@ public static SortedMap decodeSparseFloatVector(ByteBuffer buf) { long k = pBuf.getLong(); // this is the long value converted from the uint // here we get the float value as normal - buf.position(offset+4); // position offsets 4 bytes since they were converted to long + buf.position(offset + 4); // position offsets 4 bytes since they were converted to long float v = buf.getFloat(); // this is the float value sparse.put(k, v); } @@ -1346,7 +1357,7 @@ public static ScalarField genScalarField(DataType dataType, DataType elementType if (dataType == DataType.Array) { ArrayArray.Builder builder = ArrayArray.newBuilder(); for (Object object : objects) { - List temp = (List)object; + List temp = (List) object; ScalarField arrayField = genScalarField(elementType, DataType.None, temp); builder.addData(arrayField); } @@ -1498,21 +1509,21 @@ public static ValueField objectToValueField(Object obj, DataType dataType) { case Int8: case Int16: if (obj instanceof Short) { - return builder.setIntData(((Short)obj).intValue()).build(); + return builder.setIntData(((Short) obj).intValue()).build(); } break; case Int32: if (obj instanceof Short) { - return builder.setIntData(((Short)obj).intValue()).build(); + return builder.setIntData(((Short) obj).intValue()).build(); } else if (obj instanceof Integer) { return builder.setIntData((Integer) obj).build(); } break; case Int64: if (obj instanceof Short) { - return builder.setLongData(((Short)obj).longValue()).build(); + return builder.setLongData(((Short) obj).longValue()).build(); } else if (obj instanceof Integer) { - return builder.setLongData(((Integer)obj).longValue()).build(); + return builder.setLongData(((Integer) obj).longValue()).build(); } else if (obj instanceof Long) { return builder.setLongData((Long) obj).build(); } @@ -1524,7 +1535,7 @@ public static ValueField objectToValueField(Object obj, DataType dataType) { break; case Double: if (obj instanceof Float) { - return builder.setDoubleData(((Float)obj).doubleValue()).build(); + return builder.setDoubleData(((Float) obj).doubleValue()).build(); } else if (obj instanceof Double) { return builder.setDoubleData((Double) obj).build(); } diff --git a/sdk-core/src/main/java/io/milvus/param/QueryNodeSingleSearch.java b/sdk-core/src/main/java/io/milvus/param/QueryNodeSingleSearch.java index 0bc192d46..da6997b06 100644 --- a/sdk-core/src/main/java/io/milvus/param/QueryNodeSingleSearch.java +++ b/sdk-core/src/main/java/io/milvus/param/QueryNodeSingleSearch.java @@ -144,7 +144,7 @@ public Builder withVectors(List vectors) { /** * Sets the search parameters specific to the index type. - * + *

* For example: IVF index, the search parameters can be "{\"nprobe\":10}" * For more information: @see Index Selection * diff --git a/sdk-core/src/main/java/io/milvus/param/R.java b/sdk-core/src/main/java/io/milvus/param/R.java index 78f3f2fe7..332b81927 100644 --- a/sdk-core/src/main/java/io/milvus/param/R.java +++ b/sdk-core/src/main/java/io/milvus/param/R.java @@ -42,7 +42,9 @@ public void setException(Exception exception) { this.exception = exception; } - public String getMessage() { return exception.getMessage(); } + public String getMessage() { + return exception.getMessage(); + } public Integer getStatus() { return status; @@ -82,7 +84,7 @@ public static R failed(Exception exception) { * Wraps an error code and error message for failure. * * @param errorCode rpc error code - * @param msg error message + * @param msg error message * @return R */ public static R failed(ErrorCode errorCode, String msg) { @@ -96,7 +98,7 @@ public static R failed(ErrorCode errorCode, String msg) { * Wraps a status code and error message for failure. * * @param statusCode status code - * @param msg error message + * @param msg error message * @return R */ public static R failed(Status statusCode, String msg) { diff --git a/sdk-core/src/main/java/io/milvus/param/RpcStatus.java b/sdk-core/src/main/java/io/milvus/param/RpcStatus.java index b4bc7f6a0..b06b892fe 100644 --- a/sdk-core/src/main/java/io/milvus/param/RpcStatus.java +++ b/sdk-core/src/main/java/io/milvus/param/RpcStatus.java @@ -34,7 +34,7 @@ public String getMsg() { public RpcStatus(String msg) { this.msg = msg; } - + @Override public String toString() { return "RpcStatus(msg=" + msg + ")"; diff --git a/sdk-core/src/main/java/io/milvus/param/ServerAddress.java b/sdk-core/src/main/java/io/milvus/param/ServerAddress.java index b93b94c4c..b21ba0e95 100644 --- a/sdk-core/src/main/java/io/milvus/param/ServerAddress.java +++ b/sdk-core/src/main/java/io/milvus/param/ServerAddress.java @@ -84,7 +84,7 @@ public Builder withHost(String host) { * @param port port value * @return Builder */ - public Builder withPort(int port) { + public Builder withPort(int port) { this.port = port; return this; } @@ -95,7 +95,7 @@ public Builder withPort(int port) { * @param port port value * @return Builder */ - public Builder withHealthPort(int port) { + public Builder withHealthPort(int port) { this.healthPort = port; return this; } diff --git a/sdk-core/src/main/java/io/milvus/param/bulkinsert/BulkInsertParam.java b/sdk-core/src/main/java/io/milvus/param/bulkinsert/BulkInsertParam.java index d5c768c07..07054a3f6 100644 --- a/sdk-core/src/main/java/io/milvus/param/bulkinsert/BulkInsertParam.java +++ b/sdk-core/src/main/java/io/milvus/param/bulkinsert/BulkInsertParam.java @@ -95,6 +95,7 @@ public static final class Builder { private String partitionName; private final List files = new ArrayList<>(); private final Map options = new HashMap<>(); + private Builder() { } @@ -167,7 +168,7 @@ public Builder addFile(String file) { /** * Sets the options of the request * - * @param key a List of {@link String} + * @param key a List of {@link String} * @param value a List of {@link String} * @return Builder */ diff --git a/sdk-core/src/main/java/io/milvus/param/collection/AlterCollectionParam.java b/sdk-core/src/main/java/io/milvus/param/collection/AlterCollectionParam.java index 604303621..7989f91fe 100644 --- a/sdk-core/src/main/java/io/milvus/param/collection/AlterCollectionParam.java +++ b/sdk-core/src/main/java/io/milvus/param/collection/AlterCollectionParam.java @@ -138,7 +138,7 @@ public Builder withMMapEnabled(boolean enabledMMap) { /** * Basic method to set a key-value property. * - * @param key the key + * @param key the key * @param value the value * @return Builder */ diff --git a/sdk-core/src/main/java/io/milvus/param/collection/AlterDatabaseParam.java b/sdk-core/src/main/java/io/milvus/param/collection/AlterDatabaseParam.java index 43a7a8997..d848943f7 100644 --- a/sdk-core/src/main/java/io/milvus/param/collection/AlterDatabaseParam.java +++ b/sdk-core/src/main/java/io/milvus/param/collection/AlterDatabaseParam.java @@ -89,6 +89,7 @@ public Builder withDatabaseName(String databaseName) { /** * Set the replica number in database level, then if load collection doesn't have replica number, it will use this replica number. + * * @param replicaNumber replica number * @return Builder */ @@ -98,6 +99,7 @@ public Builder withReplicaNumber(int replicaNumber) { /** * Set the resource groups in database level, then if load collection doesn't have resource groups, it will use this resource groups. + * * @param resourceGroups resource group names * @return Builder */ @@ -111,7 +113,7 @@ public Builder withResourceGroups(List resourceGroups) { /** * Basic method to set a key-value property. * - * @param key the key + * @param key the key * @param value the value * @return Builder */ diff --git a/sdk-core/src/main/java/io/milvus/param/collection/CollectionSchemaParam.java b/sdk-core/src/main/java/io/milvus/param/collection/CollectionSchemaParam.java index e870315e5..afcc82040 100644 --- a/sdk-core/src/main/java/io/milvus/param/collection/CollectionSchemaParam.java +++ b/sdk-core/src/main/java/io/milvus/param/collection/CollectionSchemaParam.java @@ -82,10 +82,10 @@ public Builder withEnableDynamicField(boolean enableDynamicField) { /** * Sets the fieldTypes of the schema. The fieldTypes cannot be empty or null. - * @see FieldType * * @param fieldTypes a List of {@link FieldType} * @return Builder + * @see FieldType */ public Builder withFieldTypes(List fieldTypes) { if (fieldTypes == null) { @@ -97,10 +97,10 @@ public Builder withFieldTypes(List fieldTypes) { /** * Adds a field. - * @see FieldType * * @param fieldType a {@link FieldType} object * @return Builder + * @see FieldType */ public Builder addFieldType(FieldType fieldType) { if (fieldType == null) { diff --git a/sdk-core/src/main/java/io/milvus/param/collection/CreateCollectionParam.java b/sdk-core/src/main/java/io/milvus/param/collection/CreateCollectionParam.java index 179b5cc47..d337c819f 100644 --- a/sdk-core/src/main/java/io/milvus/param/collection/CreateCollectionParam.java +++ b/sdk-core/src/main/java/io/milvus/param/collection/CreateCollectionParam.java @@ -176,10 +176,10 @@ public Builder withShardsNum(int shardsNum) { /** * Sets the collection if enableDynamicField. - * @deprecated Use {@link #withSchema(CollectionSchemaParam)} repace * * @param enableDynamicField enableDynamicField of the collection * @return Builder + * @deprecated Use {@link #withSchema(CollectionSchemaParam)} repace */ @Deprecated public Builder withEnableDynamicField(boolean enableDynamicField) { @@ -203,11 +203,11 @@ public Builder withDescription(String description) { /** * Sets the schema of the collection. The schema cannot be empty or null. - * @see FieldType - * @deprecated Use {@link #withSchema(CollectionSchemaParam)} repace * * @param fieldTypes a List of {@link FieldType} * @return Builder + * @see FieldType + * @deprecated Use {@link #withSchema(CollectionSchemaParam)} repace */ @Deprecated public Builder withFieldTypes(List fieldTypes) { @@ -220,11 +220,11 @@ public Builder withFieldTypes(List fieldTypes) { /** * Adds a field schema. - * @see FieldType - * @deprecated Use {@link #withSchema(CollectionSchemaParam)} repace * * @param fieldType a {@link FieldType} object * @return Builder + * @see FieldType + * @deprecated Use {@link #withSchema(CollectionSchemaParam)} repace */ @Deprecated public Builder addFieldType(FieldType fieldType) { @@ -237,10 +237,10 @@ public Builder addFieldType(FieldType fieldType) { /** * Sets the consistency level. The default value is {@link ConsistencyLevelEnum#BOUNDED}. - * @see ConsistencyLevelEnum * * @param consistencyLevel consistency level * @return Builder + * @see ConsistencyLevelEnum */ public Builder withConsistencyLevel(ConsistencyLevelEnum consistencyLevel) { if (consistencyLevel == null) { @@ -267,7 +267,6 @@ public Builder withPartitionsNum(int partitionsNum) { /** * Sets the schema of collection. * - * * @param schema the schema of collection * @return Builder */ @@ -281,6 +280,7 @@ public Builder withSchema(CollectionSchemaParam schema) { /** * Sets the replica number in collection level, then if load collection doesn't have replica number, it will use this replica number. + * * @param replicaNumber replica number * @return Builder */ @@ -290,6 +290,7 @@ public Builder withReplicaNumber(int replicaNumber) { /** * Sets the resource groups in collection level, then if load collection doesn't have resource groups, it will use this resource groups. + * * @param resourceGroups resource group names * @return Builder */ @@ -304,7 +305,7 @@ public Builder withResourceGroups(List resourceGroups) { /** * Basic method to set a key-value property. * - * @param key the key + * @param key the key * @param value the value * @return Builder */ diff --git a/sdk-core/src/main/java/io/milvus/param/collection/CreateDatabaseParam.java b/sdk-core/src/main/java/io/milvus/param/collection/CreateDatabaseParam.java index 28bdb3f76..b9d058e10 100644 --- a/sdk-core/src/main/java/io/milvus/param/collection/CreateDatabaseParam.java +++ b/sdk-core/src/main/java/io/milvus/param/collection/CreateDatabaseParam.java @@ -89,6 +89,7 @@ public Builder withDatabaseName(String databaseName) { /** * Sets the replica number in database level, then if load collection doesn't have replica number, it will use this replica number. + * * @param replicaNumber replica number * @return Builder */ @@ -98,6 +99,7 @@ public Builder withReplicaNumber(int replicaNumber) { /** * Sets the resource groups in database level, then if load collection doesn't have resource groups, it will use this resource groups. + * * @param resourceGroups resource group names * @return Builder */ @@ -111,7 +113,7 @@ public Builder withResourceGroups(List resourceGroups) { /** * Basic method to set a key-value property. * - * @param key the key + * @param key the key * @param value the value * @return Builder */ diff --git a/sdk-core/src/main/java/io/milvus/param/collection/FieldType.java b/sdk-core/src/main/java/io/milvus/param/collection/FieldType.java index 1c26e7d08..2ccc4b7af 100644 --- a/sdk-core/src/main/java/io/milvus/param/collection/FieldType.java +++ b/sdk-core/src/main/java/io/milvus/param/collection/FieldType.java @@ -29,6 +29,7 @@ /** * Parameters for a collection field. + * * @see CreateCollectionParam */ public class FieldType { @@ -36,7 +37,7 @@ public class FieldType { private final boolean primaryKey; private final String description; private final DataType dataType; - private final Map typeParams; + private final Map typeParams; private final boolean autoID; private final boolean partitionKey; private final boolean clusteringKey; @@ -45,7 +46,7 @@ public class FieldType { private final boolean nullable; private final Object defaultValue; - private FieldType(Builder builder){ + private FieldType(Builder builder) { if (builder == null) { throw new IllegalArgumentException("builder cannot be null"); } @@ -167,7 +168,7 @@ public static final class Builder { private boolean primaryKey = false; private String description = ""; private DataType dataType; - private final Map typeParams = new HashMap<>(); + private final Map typeParams = new HashMap<>(); private boolean autoID = false; private boolean partitionKey = false; private boolean clusteringKey = false; @@ -256,7 +257,7 @@ public Builder withElementType(DataType elementType) { /** * Adds a parameter pair for the field. * - * @param key parameter key + * @param key parameter key * @param value parameter value * @return Builder */ @@ -335,7 +336,7 @@ public Builder withMaxCapacity(Integer maxCapacity) { * Enables auto-id function for the field. Note that the auto-id function can only be enabled on primary key field. * If auto-id function is enabled, Milvus will automatically generate unique ID for each entity, * thus you do not need to provide values for the primary key field when inserting. - * + *

* If auto-id is disabled, you need to provide values for the primary key field when inserting. * * @param autoID true enable auto-id, false disable auto-id @@ -363,14 +364,14 @@ public Builder withPartitionKey(boolean partitionKey) { /** * Sets this field is nullable or not. * Primary key field, vector fields, Array fields cannot be nullable. - * - * 1. if the field is nullable, user can input JsonNull/JsonObject(for row-based insert), or input null/object(for column-based insert) - * 1) if user input JsonNull, this value is replaced by default value - * 2) if user input JsonObject, infer this value by type - * 2. if the field is not nullable, user can input JsonNull/JsonObject(for row-based insert), or input null/object(for column-based insert) - * 1) if user input JsonNull, and default value is null, throw error - * 2) if user input JsonNull, and default value is not null, this value is replaced by default value - * 3) if user input JsonObject, infer this value by type + *

+ * 1. if the field is nullable, user can input JsonNull/JsonObject(for row-based insert), or input null/object(for column-based insert) + * 1) if user input JsonNull, this value is replaced by default value + * 2) if user input JsonObject, infer this value by type + * 2. if the field is not nullable, user can input JsonNull/JsonObject(for row-based insert), or input null/object(for column-based insert) + * 1) if user input JsonNull, and default value is null, throw error + * 2) if user input JsonNull, and default value is not null, this value is replaced by default value + * 3) if user input JsonObject, infer this value by type * * @param nullable true is nullable, false is not * @return Builder @@ -393,7 +394,7 @@ public Builder withNullable(boolean nullable) { * - Double for Double fields * - String for Varchar fields * - JsonObject for JSON fields - * + *

* For JSON field, you can use JsonNull.INSTANCE as default value. For other scalar fields, you can use null as default value. * * @param obj the default value diff --git a/sdk-core/src/main/java/io/milvus/param/collection/FlushParam.java b/sdk-core/src/main/java/io/milvus/param/collection/FlushParam.java index d86968605..e92bd930c 100644 --- a/sdk-core/src/main/java/io/milvus/param/collection/FlushParam.java +++ b/sdk-core/src/main/java/io/milvus/param/collection/FlushParam.java @@ -150,7 +150,7 @@ public Builder addCollectionName(String collectionName) { /** * Sets the flush function to sync mode. * With sync mode enabled, the client keeps waiting until all segments of the collection successfully flushed. - * + *

* If sync mode disabled, client returns at once after the flush() is called. * * @param syncFlush Boolean.TRUE is sync mode, Boolean.FALSE is not @@ -167,10 +167,10 @@ public Builder withSyncFlush(Boolean syncFlush) { /** * Sets waiting interval in sync mode. With sync mode enabled, the client will constantly check segments state by interval. * Interval must be greater than zero, and cannot be greater than Constant.MAX_WAITING_FLUSHING_INTERVAL. - * @see Constant * * @param milliseconds interval * @return Builder + * @see Constant */ public Builder withSyncFlushWaitingInterval(Long milliseconds) { if (milliseconds == null) { @@ -183,10 +183,10 @@ public Builder withSyncFlushWaitingInterval(Long milliseconds) { /** * Sets timeout value for sync mode. * Timeout value must be greater than zero, and cannot be greater than Constant.MAX_WAITING_FLUSHING_TIMEOUT. - * @see Constant * * @param seconds time out value for sync mode * @return Builder + * @see Constant */ public Builder withSyncFlushWaitingTimeout(Long seconds) { if (seconds == null) { diff --git a/sdk-core/src/main/java/io/milvus/param/collection/LoadCollectionParam.java b/sdk-core/src/main/java/io/milvus/param/collection/LoadCollectionParam.java index 23bc6aba0..d92345625 100644 --- a/sdk-core/src/main/java/io/milvus/param/collection/LoadCollectionParam.java +++ b/sdk-core/src/main/java/io/milvus/param/collection/LoadCollectionParam.java @@ -298,7 +298,7 @@ public Builder withLoadFields(List loadFields) { if (loadFields == null) { throw new IllegalArgumentException("loadFields cannot be null"); } - loadFields.forEach((field)->{ + loadFields.forEach((field) -> { if (!this.loadFields.contains(field)) { this.loadFields.add(field); } diff --git a/sdk-core/src/main/java/io/milvus/param/control/GetCompactionPlansParam.java b/sdk-core/src/main/java/io/milvus/param/control/GetCompactionPlansParam.java index 07c37ea8d..f4350af00 100644 --- a/sdk-core/src/main/java/io/milvus/param/control/GetCompactionPlansParam.java +++ b/sdk-core/src/main/java/io/milvus/param/control/GetCompactionPlansParam.java @@ -20,8 +20,6 @@ package io.milvus.param.control; import io.milvus.exception.ParamException; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; /** * Parameters for getCompactionStateWithPlans interface. @@ -43,23 +41,6 @@ public Long getCompactionID() { return compactionID; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GetCompactionPlansParam that = (GetCompactionPlansParam) obj; - return new EqualsBuilder() - .append(compactionID, that.compactionID) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(compactionID) - .toHashCode(); - } - @Override public String toString() { return "GetCompactionPlansParam{" + diff --git a/sdk-core/src/main/java/io/milvus/param/control/GetMetricsParam.java b/sdk-core/src/main/java/io/milvus/param/control/GetMetricsParam.java index 2665f98a3..6ad4baed3 100644 --- a/sdk-core/src/main/java/io/milvus/param/control/GetMetricsParam.java +++ b/sdk-core/src/main/java/io/milvus/param/control/GetMetricsParam.java @@ -21,8 +21,6 @@ import io.milvus.exception.ParamException; import io.milvus.param.ParamUtils; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; /** * Parameters for getMetric interface. @@ -42,23 +40,6 @@ public String getRequest() { return request; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GetMetricsParam that = (GetMetricsParam) obj; - return new EqualsBuilder() - .append(request, that.request) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(request) - .toHashCode(); - } - @Override public String toString() { return "GetMetricsParam{" + @@ -77,10 +58,10 @@ private Builder() { /** * Sets request in .json format to retrieve metric information from server. - * @see Metric function design * * @param request request string in json format * @return Builder + * @see Metric function design */ public Builder withRequest(String request) { if (request == null) { diff --git a/sdk-core/src/main/java/io/milvus/param/control/GetReplicasParam.java b/sdk-core/src/main/java/io/milvus/param/control/GetReplicasParam.java index ecd7bccd6..c6b080e98 100644 --- a/sdk-core/src/main/java/io/milvus/param/control/GetReplicasParam.java +++ b/sdk-core/src/main/java/io/milvus/param/control/GetReplicasParam.java @@ -78,7 +78,7 @@ private Builder() { /** * Sets the database name. Database name cannot be empty or null. - * + * * @param databaseName database name * @return Builder */ diff --git a/sdk-core/src/main/java/io/milvus/param/control/ManualCompactParam.java b/sdk-core/src/main/java/io/milvus/param/control/ManualCompactParam.java index 605829aa8..cccd250af 100644 --- a/sdk-core/src/main/java/io/milvus/param/control/ManualCompactParam.java +++ b/sdk-core/src/main/java/io/milvus/param/control/ManualCompactParam.java @@ -21,8 +21,6 @@ import io.milvus.exception.ParamException; import io.milvus.param.ParamUtils; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; /** * Parameters for manualCompact interface. @@ -44,23 +42,6 @@ public String getCollectionName() { return collectionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ManualCompactParam that = (ManualCompactParam) obj; - return new EqualsBuilder() - .append(collectionName, that.collectionName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(collectionName) - .toHashCode(); - } - @Override public String toString() { return "ManualCompactParam{" + diff --git a/sdk-core/src/main/java/io/milvus/param/dml/AnnSearchParam.java b/sdk-core/src/main/java/io/milvus/param/dml/AnnSearchParam.java index 3b9a576a5..9614f8889 100644 --- a/sdk-core/src/main/java/io/milvus/param/dml/AnnSearchParam.java +++ b/sdk-core/src/main/java/io/milvus/param/dml/AnnSearchParam.java @@ -171,10 +171,10 @@ public Builder withLimit(Long limit) { /** * Sets expression to filter out entities before searching (Optional). - * @see Boolean Expression Rules * * @param expr filtering expression * @return Builder + * @see Boolean Expression Rules */ public Builder withExpr(String expr) { // Replace @NonNull logic with explicit null check @@ -273,7 +273,7 @@ public Builder withSparseFloatVectors(List> vectors) { /** * Sets the search parameters specific to the index type. - * + *

* For example: IVF index, the search parameters can be "{\"nprobe\":10}" * For more information: @see Index Selection * @@ -314,7 +314,6 @@ public AnnSearchParam build() throws ParamException { /** * - * Warning: don't use lombok@ToString to annotate this class * because large number of vectors will waste time in toString() method. * */ diff --git a/sdk-core/src/main/java/io/milvus/param/dml/DeleteParam.java b/sdk-core/src/main/java/io/milvus/param/dml/DeleteParam.java index c8f0759c6..25088be61 100644 --- a/sdk-core/src/main/java/io/milvus/param/dml/DeleteParam.java +++ b/sdk-core/src/main/java/io/milvus/param/dml/DeleteParam.java @@ -129,10 +129,10 @@ public Builder withPartitionName(String partitionName) { /** * Sets the expression to filter out entities to be deleted. - * @see Boolean Expression Rules * * @param expr filtering expression * @return Builder + * @see Boolean Expression Rules */ public Builder withExpr(String expr) { // Replace @NonNull logic with explicit null check diff --git a/sdk-core/src/main/java/io/milvus/param/dml/HybridSearchParam.java b/sdk-core/src/main/java/io/milvus/param/dml/HybridSearchParam.java index ab9800843..67eb500f6 100644 --- a/sdk-core/src/main/java/io/milvus/param/dml/HybridSearchParam.java +++ b/sdk-core/src/main/java/io/milvus/param/dml/HybridSearchParam.java @@ -23,7 +23,6 @@ import io.milvus.common.clientenum.ConsistencyLevelEnum; import io.milvus.exception.ParamException; import io.milvus.param.ParamUtils; - import io.milvus.param.dml.ranker.BaseRanker; import java.util.List; diff --git a/sdk-core/src/main/java/io/milvus/param/dml/InsertParam.java b/sdk-core/src/main/java/io/milvus/param/dml/InsertParam.java index e34975bf1..50c515a2e 100644 --- a/sdk-core/src/main/java/io/milvus/param/dml/InsertParam.java +++ b/sdk-core/src/main/java/io/milvus/param/dml/InsertParam.java @@ -22,7 +22,6 @@ import com.google.gson.JsonObject; import io.milvus.exception.ParamException; import io.milvus.param.ParamUtils; - import org.apache.commons.collections4.CollectionUtils; import java.util.List; @@ -151,7 +150,7 @@ public Builder withFields(List fields) { /** * Sets the row data to insert. The rows list cannot be empty. - * + *

* Internal class for insert data. * If dataType is Bool/Int8/Int16/Int32/Int64/Float/Double/Varchar, use JsonObject.addProperty(key, value) to input; * If dataType is FloatVector, use JsonObject.add(key, gson.toJsonTree(List[Float]) to input; @@ -159,18 +158,17 @@ public Builder withFields(List fields) { * If dataType is SparseFloatVector, use JsonObject.add(key, gson.toJsonTree(SortedMap[Long, Float])) to input; * If dataType is Array, use JsonObject.add(key, gson.toJsonTree(List of Boolean/Integer/Short/Long/Float/Double/String)) to input; * If dataType is JSON, use JsonObject.add(key, JsonElement) to input; - * + *

* Note: * 1. For scalar numeric values, value will be cut according to the type of the field. * For example: - * An Int8 field named "XX", you set the value to be 128 by JsonObject.add("XX", 128), the value 128 is cut to -128. - * An Int64 field named "XX", you set the value to be 3.9 by JsonObject.add("XX", 3.9), the value 3.9 is cut to 3. - * + * An Int8 field named "XX", you set the value to be 128 by JsonObject.add("XX", 128), the value 128 is cut to -128. + * An Int64 field named "XX", you set the value to be 3.9 by JsonObject.add("XX", 3.9), the value 3.9 is cut to 3. + *

* 2. String value can be parsed to numeric/boolean type if the value is valid. * For example: - * A Bool field named "XX", you set the value to be "TRUE" by JsonObject.add("XX", "TRUE"), the string "TRUE" is parsed as true. - * A Float field named "XX", you set the value to be "3.5" by JsonObject.add("XX", "3.5", the string "3.5" is parsed as 3.5. - * + * A Bool field named "XX", you set the value to be "TRUE" by JsonObject.add("XX", "TRUE"), the string "TRUE" is parsed as true. + * A Float field named "XX", you set the value to be "3.5" by JsonObject.add("XX", "3.5", the string "3.5" is parsed as 3.5. * * @param rows insert row data * @return Builder @@ -276,7 +274,7 @@ protected void checkRows() { * If dataType is SparseFloatVector, values is List of SortedMap[Long, Float]; * If dataType is Array, values can be List of List Boolean/Integer/Short/Long/Float/Double/String; * If dataType is JSON, values is List of gson.JsonObject; - * + *

* Note: * If dataType is Int8/Int16/Int32, values is List of Integer or Short * (why? because the rpc proto only support int32/int64 type, actually Int8/Int16/Int32 use int32 type to encode/decode) @@ -347,7 +345,6 @@ public Field build() { /** * - * Warning: don't use lombok@ToString to annotate this class * because large number of vectors will waste time in toString() method. * */ diff --git a/sdk-core/src/main/java/io/milvus/param/dml/QueryIteratorParam.java b/sdk-core/src/main/java/io/milvus/param/dml/QueryIteratorParam.java index 3c3cc18b3..c93b4ce0c 100644 --- a/sdk-core/src/main/java/io/milvus/param/dml/QueryIteratorParam.java +++ b/sdk-core/src/main/java/io/milvus/param/dml/QueryIteratorParam.java @@ -281,10 +281,10 @@ public Builder addOutField(String fieldName) { /** * Sets the expression to query entities. - * @see Boolean Expression Rules * * @param expr filtering expression * @return Builder + * @see Boolean Expression Rules */ public Builder withExpr(String expr) { // Replace @NonNull logic with explicit null check diff --git a/sdk-core/src/main/java/io/milvus/param/dml/QueryParam.java b/sdk-core/src/main/java/io/milvus/param/dml/QueryParam.java index 073fc31b9..9d220cbe8 100644 --- a/sdk-core/src/main/java/io/milvus/param/dml/QueryParam.java +++ b/sdk-core/src/main/java/io/milvus/param/dml/QueryParam.java @@ -264,10 +264,10 @@ public Builder addOutField(String fieldName) { /** * Sets the expression to query entities. - * @see Boolean Expression Rules * * @param expr filtering expression * @return Builder + * @see Boolean Expression Rules */ public Builder withExpr(String expr) { // Replace @NonNull logic with explicit null check diff --git a/sdk-core/src/main/java/io/milvus/param/dml/SearchIteratorParam.java b/sdk-core/src/main/java/io/milvus/param/dml/SearchIteratorParam.java index 9820d56d5..ad491d033 100644 --- a/sdk-core/src/main/java/io/milvus/param/dml/SearchIteratorParam.java +++ b/sdk-core/src/main/java/io/milvus/param/dml/SearchIteratorParam.java @@ -82,7 +82,7 @@ private SearchIteratorParam(Builder builder) { this.ignoreGrowing = builder.ignoreGrowing; this.groupByFieldName = builder.groupByFieldName; this.plType = builder.plType; - + this.batchSize = builder.batchSize; } @@ -357,10 +357,10 @@ public Builder withLimit(Long limit) { /** * Sets expression to filter out entities before searching (Optional). - * @see Boolean Expression Rules * * @param expr filtering expression * @return Builder + * @see Boolean Expression Rules */ public Builder withExpr(String expr) { // Replace @NonNull logic with explicit null check @@ -406,9 +406,9 @@ public Builder addOutField(String fieldName) { /** * Sets the target vectors. * Note: Deprecated in v2.4.0, for the reason that the sdk cannot know a ByteBuffer - * is a BinarVector or Float16Vector/BFloat16Vector. - * Replaced by withFloatVectors/withBinaryVectors/withFloat16Vectors/withBFloat16Vectors/withSparseFloatVectors. - * It still works for FloatVector/BinarVector/SparseVector, don't use it for Float16Vector/BFloat16Vector. + * is a BinarVector or Float16Vector/BFloat16Vector. + * Replaced by withFloatVectors/withBinaryVectors/withFloat16Vectors/withBFloat16Vectors/withSparseFloatVectors. + * It still works for FloatVector/BinarVector/SparseVector, don't use it for Float16Vector/BFloat16Vector. * * @param vectors list of target vectors: * if vector type is FloatVector, vectors is List of List Float; @@ -529,7 +529,7 @@ public Builder withRoundDecimal(Integer decimal) { /** * Sets the search parameters specific to the index type. - * + *

* For example: IVF index, the search parameters can be "{\"nprobe\":10}" * For more information: @see Index Selection * diff --git a/sdk-core/src/main/java/io/milvus/param/dml/SearchParam.java b/sdk-core/src/main/java/io/milvus/param/dml/SearchParam.java index 76ff1944b..f91160759 100644 --- a/sdk-core/src/main/java/io/milvus/param/dml/SearchParam.java +++ b/sdk-core/src/main/java/io/milvus/param/dml/SearchParam.java @@ -320,6 +320,7 @@ public Builder withTopK(Integer topK) { this.topK = topK.longValue(); return this; } + public Builder withLimit(Long limit) { if (limit == null) { throw new IllegalArgumentException("limit cannot be null"); @@ -330,10 +331,10 @@ public Builder withLimit(Long limit) { /** * Sets expression to filter out entities before searching (Optional). - * @see Boolean Expression Rules * * @param expr filtering expression * @return Builder + * @see Boolean Expression Rules */ public Builder withExpr(String expr) { if (expr == null) { @@ -376,9 +377,9 @@ public Builder addOutField(String fieldName) { /** * Sets the target vectors. * Note: Deprecated in v2.4.0, for the reason that the sdk cannot know a ByteBuffer - * is a BinarVector or Float16Vector/BFloat16Vector. - * Replaced by withFloatVectors/withBinaryVectors/withFloat16Vectors/withBFloat16Vectors/withSparseFloatVectors. - * It still works for FloatVector/BinarVector/SparseVector, don't use it for Float16Vector/BFloat16Vector. + * is a BinarVector or Float16Vector/BFloat16Vector. + * Replaced by withFloatVectors/withBinaryVectors/withFloat16Vectors/withBFloat16Vectors/withSparseFloatVectors. + * It still works for FloatVector/BinarVector/SparseVector, don't use it for Float16Vector/BFloat16Vector. * * @param vectors list of target vectors: * if vector type is FloatVector, vectors is List of List Float; @@ -492,7 +493,7 @@ public Builder withRoundDecimal(Integer decimal) { /** * Sets the search parameters specific to the index type. - * + *

* For example: IVF index, the search parameters can be "{\"nprobe\":10}" * For more information: @see Index Selection * @@ -648,7 +649,6 @@ public static void verifyVectors(List vectors) { /** * - * Warning: don't use lombok@ToString to annotate this class * because large number of vectors will waste time in toString() method. * */ diff --git a/sdk-core/src/main/java/io/milvus/param/dml/UpsertParam.java b/sdk-core/src/main/java/io/milvus/param/dml/UpsertParam.java index 3c3160034..b2b0d1cae 100644 --- a/sdk-core/src/main/java/io/milvus/param/dml/UpsertParam.java +++ b/sdk-core/src/main/java/io/milvus/param/dml/UpsertParam.java @@ -104,7 +104,7 @@ public Builder withFields(List fields) { /** * Sets the row data to insert. The rows list cannot be empty. - * + *

* Internal class for insert data. * If dataType is Bool/Int8/Int16/Int32/Int64/Float/Double/Varchar, use JsonObject.addProperty(key, value) to input; * If dataType is FloatVector, use JsonObject.add(key, gson.toJsonTree(List[Float]) to input; @@ -112,18 +112,17 @@ public Builder withFields(List fields) { * If dataType is SparseFloatVector, use JsonObject.add(key, gson.toJsonTree(SortedMap[Long, Float])) to input; * If dataType is Array, use JsonObject.add(key, gson.toJsonTree(List of Boolean/Integer/Short/Long/Float/Double/String)) to input; * If dataType is JSON, use JsonObject.add(key, JsonElement) to input; - * + *

* Note: * 1. For scalar numeric values, value will be cut according to the type of the field. * For example: - * An Int8 field named "XX", you set the value to be 128 by JsonObject.add("XX", 128), the value 128 is cut to -128. - * An Int64 field named "XX", you set the value to be 3.9 by JsonObject.add("XX", 3.9), the value 3.9 is cut to 3. - * + * An Int8 field named "XX", you set the value to be 128 by JsonObject.add("XX", 128), the value 128 is cut to -128. + * An Int64 field named "XX", you set the value to be 3.9 by JsonObject.add("XX", 3.9), the value 3.9 is cut to 3. + *

* 2. String value can be parsed to numeric/boolean type if the value is valid. * For example: - * A Bool field named "XX", you set the value to be "TRUE" by JsonObject.add("XX", "TRUE"), the string "TRUE" is parsed as true. - * A Float field named "XX", you set the value to be "3.5" by JsonObject.add("XX", "3.5", the string "3.5" is parsed as 3.5. - * + * A Bool field named "XX", you set the value to be "TRUE" by JsonObject.add("XX", "TRUE"), the string "TRUE" is parsed as true. + * A Float field named "XX", you set the value to be "3.5" by JsonObject.add("XX", "3.5", the string "3.5" is parsed as 3.5. * * @param rows insert row data * @return Builder @@ -151,7 +150,6 @@ public UpsertParam build() throws ParamException { /** * - * Warning: don't use lombok@ToString to annotate this class * because large number of vectors will waste time in toString() method. * */ diff --git a/sdk-core/src/main/java/io/milvus/param/dml/ranker/BaseRanker.java b/sdk-core/src/main/java/io/milvus/param/dml/ranker/BaseRanker.java index 18db69189..c1ce3fb0c 100644 --- a/sdk-core/src/main/java/io/milvus/param/dml/ranker/BaseRanker.java +++ b/sdk-core/src/main/java/io/milvus/param/dml/ranker/BaseRanker.java @@ -19,7 +19,6 @@ package io.milvus.param.dml.ranker; -import java.util.HashMap; import java.util.Map; public abstract class BaseRanker { diff --git a/sdk-core/src/main/java/io/milvus/param/dml/ranker/RRFRanker.java b/sdk-core/src/main/java/io/milvus/param/dml/ranker/RRFRanker.java index 4134a6766..4cd2cb2b9 100644 --- a/sdk-core/src/main/java/io/milvus/param/dml/ranker/RRFRanker.java +++ b/sdk-core/src/main/java/io/milvus/param/dml/ranker/RRFRanker.java @@ -20,11 +20,11 @@ package io.milvus.param.dml.ranker; import com.google.gson.JsonObject; +import io.milvus.exception.ParamException; + import java.util.HashMap; import java.util.Map; -import io.milvus.exception.ParamException; - /** * The RRF reranking strategy, which merges results from multiple searches, favoring items that consistently appear. */ diff --git a/sdk-core/src/main/java/io/milvus/param/dml/ranker/WeightedRanker.java b/sdk-core/src/main/java/io/milvus/param/dml/ranker/WeightedRanker.java index f764813fc..f1af31401 100644 --- a/sdk-core/src/main/java/io/milvus/param/dml/ranker/WeightedRanker.java +++ b/sdk-core/src/main/java/io/milvus/param/dml/ranker/WeightedRanker.java @@ -23,7 +23,10 @@ import io.milvus.common.utils.JsonUtils; import io.milvus.exception.ParamException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * The Average Weighted Scoring reranking strategy, which prioritizes vectors based on relevance, diff --git a/sdk-core/src/main/java/io/milvus/param/highlevel/collection/CreateSimpleCollectionParam.java b/sdk-core/src/main/java/io/milvus/param/highlevel/collection/CreateSimpleCollectionParam.java index 7ba6bb886..91af19b43 100644 --- a/sdk-core/src/main/java/io/milvus/param/highlevel/collection/CreateSimpleCollectionParam.java +++ b/sdk-core/src/main/java/io/milvus/param/highlevel/collection/CreateSimpleCollectionParam.java @@ -206,10 +206,10 @@ public Builder withSyncLoad(boolean syncLoad) { /** * Sets the consistency level. The default value is {@link ConsistencyLevelEnum#BOUNDED}. - * @see ConsistencyLevelEnum * * @param consistencyLevel consistency level * @return Builder + * @see ConsistencyLevelEnum */ public Builder withConsistencyLevel(ConsistencyLevelEnum consistencyLevel) { if (consistencyLevel == null) { @@ -244,7 +244,7 @@ public Builder withMaxLength(Integer maxLength) { if (maxLength == null) { throw new IllegalArgumentException("maxLength cannot be null"); } - this.maxLength = maxLength; + this.maxLength = maxLength; return this; } diff --git a/sdk-core/src/main/java/io/milvus/param/highlevel/dml/InsertRowsParam.java b/sdk-core/src/main/java/io/milvus/param/highlevel/dml/InsertRowsParam.java index 8abb94f66..b1d483a12 100644 --- a/sdk-core/src/main/java/io/milvus/param/highlevel/dml/InsertRowsParam.java +++ b/sdk-core/src/main/java/io/milvus/param/highlevel/dml/InsertRowsParam.java @@ -33,7 +33,7 @@ public class InsertRowsParam { private final InsertParam insertParam; - + private InsertRowsParam(InsertParam insertParam) { this.insertParam = insertParam; } @@ -75,7 +75,7 @@ public Builder withCollectionName(String collectionName) { /** * Sets the row data to insert. The rows list cannot be empty. - * + *

* Internal class for insert data. * If dataType is Bool/Int8/Int16/Int32/Int64/Float/Double/Varchar, use JsonObject.addProperty(key, value) to input; * If dataType is FloatVector, use JsonObject.add(key, gson.toJsonTree(List[Float])) to input; @@ -83,18 +83,17 @@ public Builder withCollectionName(String collectionName) { * If dataType is SparseFloatVector, use JsonObject.add(key, gson.toJsonTree(SortedMap[Long, Float])) to input; * If dataType is Array, use JsonObject.add(key, gson.toJsonTree(List of Boolean/Integer/Short/Long/Float/Double/String)) to input; * If dataType is JSON, use JsonObject.add(key, JsonElement) to input; - * + *

* Note: * 1. For scalar numeric values, value will be cut according to the type of the field. * For example: - * An Int8 field named "XX", you set the value to be 128 by JsonObject.add("XX", 128), the value 128 is cut to -128. - * An Int64 field named "XX", you set the value to be 3.9 by JsonObject.add("XX", 3.9), the value 3.9 is cut to 3. - * + * An Int8 field named "XX", you set the value to be 128 by JsonObject.add("XX", 128), the value 128 is cut to -128. + * An Int64 field named "XX", you set the value to be 3.9 by JsonObject.add("XX", 3.9), the value 3.9 is cut to 3. + *

* 2. String value can be parsed to numeric/boolean type if the value is valid. * For example: - * A Bool field named "XX", you set the value to be "TRUE" by JsonObject.add("XX", "TRUE"), the string "TRUE" is parsed as true. - * A Float field named "XX", you set the value to be "3.5" by JsonObject.add("XX", "3.5", the string "3.5" is parsed as 3.5. - * + * A Bool field named "XX", you set the value to be "TRUE" by JsonObject.add("XX", "TRUE"), the string "TRUE" is parsed as true. + * A Float field named "XX", you set the value to be "3.5" by JsonObject.add("XX", "3.5", the string "3.5" is parsed as 3.5. * * @param rows insert row data * @return Builder @@ -132,7 +131,6 @@ public InsertRowsParam build() throws ParamException { /** * - * Warning: don't use lombok@ToString to annotate this class * because large number of vectors will waste time in toString() method. * */ diff --git a/sdk-core/src/main/java/io/milvus/param/highlevel/dml/QuerySimpleParam.java b/sdk-core/src/main/java/io/milvus/param/highlevel/dml/QuerySimpleParam.java index 31d92fa88..b98e51f6d 100644 --- a/sdk-core/src/main/java/io/milvus/param/highlevel/dml/QuerySimpleParam.java +++ b/sdk-core/src/main/java/io/milvus/param/highlevel/dml/QuerySimpleParam.java @@ -22,7 +22,6 @@ import io.milvus.common.clientenum.ConsistencyLevelEnum; import io.milvus.exception.ParamException; import io.milvus.param.ParamUtils; -import io.milvus.param.dml.QueryParam; import java.util.ArrayList; import java.util.List; @@ -139,10 +138,10 @@ public Builder withOutputFields(List outputFields) { /** * Sets the expression to query entities. - * @see Boolean Expression Rules * * @param filter filtering expression * @return Builder + * @see Boolean Expression Rules */ public Builder withFilter(String filter) { // Replace @NonNull logic with explicit null check diff --git a/sdk-core/src/main/java/io/milvus/param/highlevel/dml/SearchSimpleParam.java b/sdk-core/src/main/java/io/milvus/param/highlevel/dml/SearchSimpleParam.java index e131b301f..68f27c07e 100644 --- a/sdk-core/src/main/java/io/milvus/param/highlevel/dml/SearchSimpleParam.java +++ b/sdk-core/src/main/java/io/milvus/param/highlevel/dml/SearchSimpleParam.java @@ -24,7 +24,6 @@ import io.milvus.exception.ParamException; import io.milvus.param.Constant; import io.milvus.param.ParamUtils; -import io.milvus.param.dml.SearchParam; import org.apache.commons.collections4.CollectionUtils; import org.jetbrains.annotations.NotNull; @@ -246,7 +245,6 @@ public SearchSimpleParam build() throws ParamException { /** * - * Warning: don't use lombok@ToString to annotate this class * because large number of vectors will waste time in toString() method. * */ diff --git a/sdk-core/src/main/java/io/milvus/param/highlevel/dml/response/DeleteResponse.java b/sdk-core/src/main/java/io/milvus/param/highlevel/dml/response/DeleteResponse.java index e907a2965..dd6690219 100644 --- a/sdk-core/src/main/java/io/milvus/param/highlevel/dml/response/DeleteResponse.java +++ b/sdk-core/src/main/java/io/milvus/param/highlevel/dml/response/DeleteResponse.java @@ -19,9 +19,6 @@ package io.milvus.param.highlevel.dml.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.List; /** @@ -51,23 +48,6 @@ public List getDeleteIds() { return deleteIds; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DeleteResponse that = (DeleteResponse) obj; - return new EqualsBuilder() - .append(deleteIds, that.deleteIds) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(deleteIds) - .toHashCode(); - } - @Override public String toString() { return "DeleteResponse{" + diff --git a/sdk-core/src/main/java/io/milvus/param/highlevel/dml/response/SearchResponse.java b/sdk-core/src/main/java/io/milvus/param/highlevel/dml/response/SearchResponse.java index 655116927..c1762994d 100644 --- a/sdk-core/src/main/java/io/milvus/param/highlevel/dml/response/SearchResponse.java +++ b/sdk-core/src/main/java/io/milvus/param/highlevel/dml/response/SearchResponse.java @@ -21,8 +21,6 @@ import io.milvus.exception.ParamException; import io.milvus.response.QueryResultsWrapper; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.List; @@ -68,23 +66,6 @@ public List getRowRecords(int indexOfTarget) { return rowRecords.get(indexOfTarget); } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - SearchResponse that = (SearchResponse) obj; - return new EqualsBuilder() - .append(rowRecords, that.rowRecords) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(rowRecords) - .toHashCode(); - } - @Override public String toString() { return "SearchResponse{" + diff --git a/sdk-core/src/main/java/io/milvus/param/index/AlterIndexParam.java b/sdk-core/src/main/java/io/milvus/param/index/AlterIndexParam.java index 8a526606d..8abfeb6a2 100644 --- a/sdk-core/src/main/java/io/milvus/param/index/AlterIndexParam.java +++ b/sdk-core/src/main/java/io/milvus/param/index/AlterIndexParam.java @@ -145,7 +145,7 @@ public Builder withMMapEnabled(boolean enabledMMap) { /** * Basic method to set a key-value property. * - * @param key the key + * @param key the key * @param value the value * @return Builder */ diff --git a/sdk-core/src/main/java/io/milvus/param/index/CreateIndexParam.java b/sdk-core/src/main/java/io/milvus/param/index/CreateIndexParam.java index 8ae1dc103..d7595d574 100644 --- a/sdk-core/src/main/java/io/milvus/param/index/CreateIndexParam.java +++ b/sdk-core/src/main/java/io/milvus/param/index/CreateIndexParam.java @@ -243,7 +243,7 @@ public Builder withMetricType(MetricType metricType) { /** * Sets the specific index parameters according to index type. - * + *

* For example: IVF index, the extra parameters can be "{\"nlist\":1024}". * For more information: @see Index Selection * @@ -262,7 +262,7 @@ public Builder withExtraParam(String extraParam) { /** * Enables to sync mode. * With sync mode enabled, the client keeps waiting until all segments of the collection are successfully indexed. - * + *

* With sync mode disabled, client returns at once after the createIndex() is called. * * @param syncMode Boolean.TRUE is sync mode, Boolean.FALSE is not @@ -281,10 +281,10 @@ public Builder withSyncMode(Boolean syncMode) { * Sets the waiting interval in sync mode. With sync mode enabled, the client constantly checks index state by interval. * Interval must be greater than zero, and cannot be greater than Constant.MAX_WAITING_INDEX_INTERVAL. * Default value is 500 milliseconds. - * @see Constant * * @param milliseconds interval * @return Builder + * @see Constant */ public Builder withSyncWaitingInterval(Long milliseconds) { // Replace @NonNull logic with explicit null check @@ -296,12 +296,12 @@ public Builder withSyncWaitingInterval(Long milliseconds) { } /** - * Sets the timeout value for sync mode. + * Sets the timeout value for sync mode. * Timeout value must be greater than zero and with No upper limit. Default value is 600 seconds. - * @see Constant * * @param seconds time out value for sync mode * @return Builder + * @see Constant */ public Builder withSyncWaitingTimeout(Long seconds) { // Replace @NonNull logic with explicit null check diff --git a/sdk-core/src/main/java/io/milvus/param/index/DescribeIndexParam.java b/sdk-core/src/main/java/io/milvus/param/index/DescribeIndexParam.java index 5c4a936c9..46fd37c76 100644 --- a/sdk-core/src/main/java/io/milvus/param/index/DescribeIndexParam.java +++ b/sdk-core/src/main/java/io/milvus/param/index/DescribeIndexParam.java @@ -20,11 +20,8 @@ package io.milvus.param.index; import io.milvus.exception.ParamException; -import io.milvus.param.Constant; import io.milvus.param.ParamUtils; -import org.apache.commons.lang3.StringUtils; - /** * Parameters for describeIndex interface. */ @@ -118,6 +115,7 @@ public Builder withCollectionName(String collectionName) { /** * Sets the target index name. Index name can be empty or null. * If no index name is specified, then return all this collection indexes. + * * @param indexName field name * @return Builder */ @@ -130,6 +128,7 @@ public Builder withIndexName(String indexName) { /** * Sets the target field name. Field name can be empty or null. * If no field name is specified, then return all this collection indexes. + * * @param fieldName field name * @return Builder */ diff --git a/sdk-core/src/main/java/io/milvus/param/index/DropIndexParam.java b/sdk-core/src/main/java/io/milvus/param/index/DropIndexParam.java index 0735b4f4c..5bf93a259 100644 --- a/sdk-core/src/main/java/io/milvus/param/index/DropIndexParam.java +++ b/sdk-core/src/main/java/io/milvus/param/index/DropIndexParam.java @@ -22,9 +22,7 @@ import io.milvus.exception.ParamException; import io.milvus.param.Constant; import io.milvus.param.ParamUtils; - import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.builder.EqualsBuilder; /** * Parameters for dropIndex interface. @@ -41,7 +39,7 @@ private DropIndexParam(Builder builder) { if (builder.indexName == null) { throw new IllegalArgumentException("Index name cannot be null"); } - + this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.indexName = builder.indexName; @@ -72,30 +70,6 @@ public String toString() { '}'; } - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - DropIndexParam that = (DropIndexParam) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(indexName, that.indexName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0); - result = 31 * result + (indexName != null ? indexName.hashCode() : 0); - return result; - } - /** * Builder for {@link DropIndexParam} class. */ diff --git a/sdk-core/src/main/java/io/milvus/param/index/GetIndexBuildProgressParam.java b/sdk-core/src/main/java/io/milvus/param/index/GetIndexBuildProgressParam.java index bf0e9d701..129b19ad7 100644 --- a/sdk-core/src/main/java/io/milvus/param/index/GetIndexBuildProgressParam.java +++ b/sdk-core/src/main/java/io/milvus/param/index/GetIndexBuildProgressParam.java @@ -22,7 +22,6 @@ import io.milvus.exception.ParamException; import io.milvus.param.Constant; import io.milvus.param.ParamUtils; - import org.apache.commons.lang3.StringUtils; /** diff --git a/sdk-core/src/main/java/io/milvus/param/index/GetIndexStateParam.java b/sdk-core/src/main/java/io/milvus/param/index/GetIndexStateParam.java index 8013b77a6..d1bc2f28b 100644 --- a/sdk-core/src/main/java/io/milvus/param/index/GetIndexStateParam.java +++ b/sdk-core/src/main/java/io/milvus/param/index/GetIndexStateParam.java @@ -22,7 +22,6 @@ import io.milvus.exception.ParamException; import io.milvus.param.Constant; import io.milvus.param.ParamUtils; - import org.apache.commons.lang3.StringUtils; /** diff --git a/sdk-core/src/main/java/io/milvus/param/partition/LoadPartitionsParam.java b/sdk-core/src/main/java/io/milvus/param/partition/LoadPartitionsParam.java index b6c42a723..ba82aa302 100644 --- a/sdk-core/src/main/java/io/milvus/param/partition/LoadPartitionsParam.java +++ b/sdk-core/src/main/java/io/milvus/param/partition/LoadPartitionsParam.java @@ -338,7 +338,7 @@ public Builder withLoadFields(List loadFields) { if (loadFields == null) { throw new IllegalArgumentException("Load fields cannot be null"); } - loadFields.forEach((field)->{ + loadFields.forEach((field) -> { if (!this.loadFields.contains(field)) { this.loadFields.add(field); } diff --git a/sdk-core/src/main/java/io/milvus/param/resourcegroup/CreateResourceGroupParam.java b/sdk-core/src/main/java/io/milvus/param/resourcegroup/CreateResourceGroupParam.java index 991088329..85661ead5 100644 --- a/sdk-core/src/main/java/io/milvus/param/resourcegroup/CreateResourceGroupParam.java +++ b/sdk-core/src/main/java/io/milvus/param/resourcegroup/CreateResourceGroupParam.java @@ -82,7 +82,7 @@ public Builder withGroupName(String groupName) { /** * Sets the resource group config. - * + * * @param config configuration of resource group * @return Builder */ diff --git a/sdk-core/src/main/java/io/milvus/param/resourcegroup/UpdateResourceGroupsParam.java b/sdk-core/src/main/java/io/milvus/param/resourcegroup/UpdateResourceGroupsParam.java index 1a077f49e..0b732f0bb 100644 --- a/sdk-core/src/main/java/io/milvus/param/resourcegroup/UpdateResourceGroupsParam.java +++ b/sdk-core/src/main/java/io/milvus/param/resourcegroup/UpdateResourceGroupsParam.java @@ -45,7 +45,7 @@ public Map getResourceGroups() { /** * Builder for {@link UpdateResourceGroupsParam} class. - * + * */ public static final class Builder { private Map resourceGroups; @@ -69,7 +69,7 @@ public Builder putResourceGroup(String resourceGroupName, ResourceGroupConfig re /** * Builds the UpdateResourceGroupsParam object. - * + * * @return {@link UpdateResourceGroupsParam} */ public UpdateResourceGroupsParam build() { @@ -79,7 +79,7 @@ public UpdateResourceGroupsParam build() { /** * Converts to grpc request. - * + * * @return io.milvus.grpc.UpdateResourceGroupsRequest */ public io.milvus.grpc.UpdateResourceGroupsRequest toGRPC() { diff --git a/sdk-core/src/main/java/io/milvus/pool/ClientPool.java b/sdk-core/src/main/java/io/milvus/pool/ClientPool.java index 358b5237e..5a6f6debe 100644 --- a/sdk-core/src/main/java/io/milvus/pool/ClientPool.java +++ b/sdk-core/src/main/java/io/milvus/pool/ClientPool.java @@ -80,7 +80,7 @@ public T getClient(String key) { * The caller should ensure the client is returned. Otherwise, the client will keep in active state and cannot be used by the next caller. * Throw exceptions if the key doesn't exist or the client is not belong to this key group. * - * @param key the key of a group where the client belong + * @param key the key of a group where the client belong * @param grpcClient the client object to return */ public void returnClient(String key, T grpcClient) { diff --git a/sdk-core/src/main/java/io/milvus/pool/PoolConfig.java b/sdk-core/src/main/java/io/milvus/pool/PoolConfig.java index 2efb1eb01..77d08f6c6 100644 --- a/sdk-core/src/main/java/io/milvus/pool/PoolConfig.java +++ b/sdk-core/src/main/java/io/milvus/pool/PoolConfig.java @@ -1,7 +1,5 @@ package io.milvus.pool; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.time.Duration; public class PoolConfig { @@ -115,44 +113,6 @@ public void setTestOnReturn(boolean testOnReturn) { this.testOnReturn = testOnReturn; } - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - PoolConfig that = (PoolConfig) obj; - return new EqualsBuilder() - .append(maxIdlePerKey, that.maxIdlePerKey) - .append(minIdlePerKey, that.minIdlePerKey) - .append(maxTotalPerKey, that.maxTotalPerKey) - .append(maxTotal, that.maxTotal) - .append(blockWhenExhausted, that.blockWhenExhausted) - .append(maxBlockWaitDuration, that.maxBlockWaitDuration) - .append(evictionPollingInterval, that.evictionPollingInterval) - .append(minEvictableIdleDuration, that.minEvictableIdleDuration) - .append(testOnBorrow, that.testOnBorrow) - .append(testOnReturn, that.testOnReturn) - .isEquals(); - } - - @Override - public int hashCode() { - int result = maxIdlePerKey; - result = 31 * result + minIdlePerKey; - result = 31 * result + maxTotalPerKey; - result = 31 * result + maxTotal; - result = 31 * result + (blockWhenExhausted ? 1 : 0); - result = 31 * result + (maxBlockWaitDuration != null ? maxBlockWaitDuration.hashCode() : 0); - result = 31 * result + (evictionPollingInterval != null ? evictionPollingInterval.hashCode() : 0); - result = 31 * result + (minEvictableIdleDuration != null ? minEvictableIdleDuration.hashCode() : 0); - result = 31 * result + (testOnBorrow ? 1 : 0); - result = 31 * result + (testOnReturn ? 1 : 0); - return result; - } - @Override public String toString() { return "PoolConfig{" + diff --git a/sdk-core/src/main/java/io/milvus/response/DescCollResponseWrapper.java b/sdk-core/src/main/java/io/milvus/response/DescCollResponseWrapper.java index 7f0d86590..ccd943684 100644 --- a/sdk-core/src/main/java/io/milvus/response/DescCollResponseWrapper.java +++ b/sdk-core/src/main/java/io/milvus/response/DescCollResponseWrapper.java @@ -21,7 +21,9 @@ import io.milvus.common.clientenum.ConsistencyLevelEnum; import io.milvus.exception.ParamException; -import io.milvus.grpc.*; +import io.milvus.grpc.CollectionSchema; +import io.milvus.grpc.DescribeCollectionResponse; +import io.milvus.grpc.FieldSchema; import io.milvus.param.Constant; import io.milvus.param.ParamUtils; import io.milvus.param.collection.CollectionSchemaParam; @@ -274,7 +276,6 @@ public CollectionSchemaParam getSchema() { } - /** * return collection resource groups * diff --git a/sdk-core/src/main/java/io/milvus/response/DescDBResponseWrapper.java b/sdk-core/src/main/java/io/milvus/response/DescDBResponseWrapper.java index 24c43ed96..3c3ea35c8 100644 --- a/sdk-core/src/main/java/io/milvus/response/DescDBResponseWrapper.java +++ b/sdk-core/src/main/java/io/milvus/response/DescDBResponseWrapper.java @@ -19,14 +19,10 @@ package io.milvus.response; -import io.milvus.grpc.*; +import io.milvus.grpc.DescribeDatabaseResponse; import io.milvus.param.Constant; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** @@ -97,8 +93,8 @@ public int getReplicaNumber() { @Override public String toString() { return "Database Description{" + - "name:'" + getDatabaseName() + '\'' + - ", properties:" + getProperties() + - '}'; + "name:'" + getDatabaseName() + '\'' + + ", properties:" + getProperties() + + '}'; } } diff --git a/sdk-core/src/main/java/io/milvus/response/DescIndexResponseWrapper.java b/sdk-core/src/main/java/io/milvus/response/DescIndexResponseWrapper.java index 94948ff32..2b515f32d 100644 --- a/sdk-core/src/main/java/io/milvus/response/DescIndexResponseWrapper.java +++ b/sdk-core/src/main/java/io/milvus/response/DescIndexResponseWrapper.java @@ -21,15 +21,17 @@ import com.google.gson.reflect.TypeToken; import io.milvus.common.utils.JsonUtils; -import io.milvus.grpc.IndexDescription; import io.milvus.grpc.DescribeIndexResponse; - +import io.milvus.grpc.IndexDescription; import io.milvus.param.Constant; -import io.milvus.param.IndexType; import io.milvus.param.IndexBuildState; +import io.milvus.param.IndexType; import io.milvus.param.MetricType; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * Util class to wrap response of describeIndex interface. @@ -52,7 +54,7 @@ public DescIndexResponseWrapper(DescribeIndexResponse response) { public List getIndexDescriptions() { List results = new ArrayList<>(); List descriptions = response.getIndexDescriptionsList(); - descriptions.forEach((desc)->{ + descriptions.forEach((desc) -> { IndexDesc res = convertIndexDescInternal(desc); results.add(res); }); @@ -107,7 +109,7 @@ private IndexDesc convertIndexDescInternal(IndexDescription desc) { res.pendingIndexRows = desc.getPendingIndexRows(); res.indexState = IndexBuildState.valueOf(desc.getState().name()); res.indexFailedReason = desc.getIndexStateFailReason(); - desc.getParamsList().forEach((kv)-> res.addParam(kv.getKey(), kv.getValue())); + desc.getParamsList().forEach((kv) -> res.addParam(kv.getKey(), kv.getValue())); return res; } @@ -208,7 +210,8 @@ public String getExtraParam() { for (Map.Entry entry : this.params.entrySet()) { if (entry.getKey().equals(Constant.INDEX_TYPE) || entry.getKey().equals(Constant.METRIC_TYPE)) { } else if (entry.getKey().equals(Constant.PARAMS)) { - Map tempParams = JsonUtils.fromJson(entry.getValue(), new TypeToken>() {}.getType()); + Map tempParams = JsonUtils.fromJson(entry.getValue(), new TypeToken>() { + }.getType()); extraParams.putAll(tempParams); } else { extraParams.put(entry.getKey(), entry.getValue()); diff --git a/sdk-core/src/main/java/io/milvus/response/FieldDataWrapper.java b/sdk-core/src/main/java/io/milvus/response/FieldDataWrapper.java index c0efca6b2..91a6de91d 100644 --- a/sdk-core/src/main/java/io/milvus/response/FieldDataWrapper.java +++ b/sdk-core/src/main/java/io/milvus/response/FieldDataWrapper.java @@ -19,12 +19,15 @@ package io.milvus.response; -import com.google.gson.*; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonPrimitive; +import com.google.protobuf.ByteString; import com.google.protobuf.ProtocolStringList; +import io.milvus.exception.IllegalResponseException; import io.milvus.exception.ParamException; import io.milvus.grpc.*; -import io.milvus.exception.IllegalResponseException; - import io.milvus.param.ParamUtils; import java.nio.ByteBuffer; @@ -32,8 +35,6 @@ import java.util.*; import java.util.stream.Collectors; -import com.google.protobuf.ByteString; - import static io.milvus.grpc.DataType.JSON; /** @@ -85,19 +86,19 @@ private int getDimInternal(VectorField vector) { // for float16 vector, each dimension 2 bytes private int checkDim(DataType dt, ByteString data, int dim) { if (dt == DataType.BinaryVector) { - if ((data.size()*8) % dim != 0) { + if ((data.size() * 8) % dim != 0) { String msg = String.format("Returned binary vector data array size %d doesn't match dimension %d", data.size(), dim); throw new IllegalResponseException(msg); } - return dim/8; + return dim / 8; } else if (dt == DataType.Float16Vector || dt == DataType.BFloat16Vector) { - if (data.size() % (dim*2) != 0) { + if (data.size() % (dim * 2) != 0) { String msg = String.format("Returned float16 vector data array size %d doesn't match dimension %d", data.size(), dim); throw new IllegalResponseException(msg); } - return dim*2; + return dim * 2; } else if (dt == DataType.Int8Vector) { if (data.size() % dim != 0) { String msg = String.format("Returned int8 vector data array size %d doesn't match dimension %d", @@ -145,7 +146,7 @@ public long getRowCount() throws IllegalResponseException { throw new IllegalResponseException(msg); } - return data.size()/dim; + return data.size() / dim; } case BinaryVector: case Float16Vector: @@ -155,7 +156,7 @@ public long getRowCount() throws IllegalResponseException { ByteString data = getVectorBytes(fieldData.getVectors(), dt); int bytePerVec = checkDim(dt, data, dim); - return data.size()/bytePerVec; + return data.size() / bytePerVec; } case SparseFloatVector: { // for sparse vector, each content is a vector @@ -204,20 +205,20 @@ public long getRowCount() throws IllegalResponseException { /** * Returns the field data according to its type: - * FloatVector field returns List of List Float, - * BinaryVector/Float16Vector/BFloat16Vector fields return List of ByteBuffer - * SparseFloatVector field returns List of SortedMap[Long, Float] - * Int64 field returns List of Long - * Int32/Int16/Int8 fields return List of Integer - * Bool field returns List of Boolean - * Float field returns List of Float - * Double field returns List of Double - * Varchar field returns List of String - * Array field returns List of List - * JSON field returns List of String; - * Struct field returns List of List> - * etc. - * + * FloatVector field returns List of List Float, + * BinaryVector/Float16Vector/BFloat16Vector fields return List of ByteBuffer + * SparseFloatVector field returns List of SortedMap[Long, Float] + * Int64 field returns List of Long + * Int32/Int16/Int8 fields return List of Integer + * Bool field returns List of Boolean + * Float field returns List of Float + * Double field returns List of Double + * Varchar field returns List of String + * Array field returns List of List + * JSON field returns List of String; + * Struct field returns List of List> + * etc. + *

* Throws {@link IllegalResponseException} if the field type is illegal. * * @return List @@ -435,7 +436,7 @@ private List getStructData(StructArrayField field, String fieldName) { for (int k = 0; k < elementCount; k++) { Map struct = new HashMap<>(); int finalK = k; - rowColumn.forEach((key, val)->struct.put(key, val.get(finalK))); + rowColumn.forEach((key, val) -> struct.put(key, val.get(finalK))); structs.add(struct); } packData.add(structs); @@ -455,7 +456,7 @@ public String getAsString(int index, String paramName) throws IllegalResponseExc if (isJsonField()) { JsonElement jsonElement = parseObjectData(index); if (jsonElement instanceof JsonObject) { - return ((JsonObject)jsonElement).get(paramName).getAsString(); + return ((JsonObject) jsonElement).get(paramName).getAsString(); } else { throw new IllegalResponseException("The JSON element is not a dict"); } @@ -482,10 +483,10 @@ public Double getAsDouble(int index, String paramName) throws IllegalResponseExc /** * Gets a field's value by field name. * - * @param index which row + * @param index which row * @param paramName which field * @return returns Long for integer value, returns Double for decimal value, - * returns String for string value, returns JsonElement for JSON object and Array. + * returns String for string value, returns JsonElement for JSON object and Array. */ public Object get(int index, String paramName) throws IllegalResponseException { if (!isJsonField()) { @@ -497,7 +498,7 @@ public Object get(int index, String paramName) throws IllegalResponseException { throw new IllegalResponseException("The JSON element is not a dict"); } - JsonElement element = ((JsonObject)jsonElement).get(paramName); + JsonElement element = ((JsonObject) jsonElement).get(paramName); return ValueOfJSONElement(element); } @@ -519,7 +520,7 @@ public static JsonElement ParseJSONObject(Object object) { throw new IllegalResponseException("Object cannot be null"); } if (object instanceof String) { - return JsonParser.parseString((String)object); + return JsonParser.parseString((String) object); } else if (object instanceof byte[]) { return JsonParser.parseString(new String((byte[]) object)); } else { diff --git a/sdk-core/src/main/java/io/milvus/response/GetBulkInsertStateWrapper.java b/sdk-core/src/main/java/io/milvus/response/GetBulkInsertStateWrapper.java index 5ec8b9468..22fba6c03 100644 --- a/sdk-core/src/main/java/io/milvus/response/GetBulkInsertStateWrapper.java +++ b/sdk-core/src/main/java/io/milvus/response/GetBulkInsertStateWrapper.java @@ -61,13 +61,13 @@ public List getAutoGeneratedIDs() { // for example, if the response return [1, 100, 200, 250], the id ranges are [1, 100), [200, 250) // the full id list should be [1, 2, 3 ... , 99, 200, 201, 202 ... , 249] List ranges = response.getIdListList(); - if (ranges.size()%2 != 0) { + if (ranges.size() % 2 != 0) { throw new IllegalResponseException("The bulk insert state response id range list is illegal"); } List ids = new ArrayList<>(); - for (int i = 0; i < ranges.size()/2; i++) { - Long begin = ranges.get(i*2); - Long end = ranges.get(i*2+1); + for (int i = 0; i < ranges.size() / 2; i++) { + Long begin = ranges.get(i * 2); + Long end = ranges.get(i * 2 + 1); for (long j = begin; j <= end; j++) { ids.add(j); } diff --git a/sdk-core/src/main/java/io/milvus/response/MutationResultWrapper.java b/sdk-core/src/main/java/io/milvus/response/MutationResultWrapper.java index 5db7f4b53..5a9392eb7 100644 --- a/sdk-core/src/main/java/io/milvus/response/MutationResultWrapper.java +++ b/sdk-core/src/main/java/io/milvus/response/MutationResultWrapper.java @@ -117,9 +117,9 @@ public long getDeleteCount() { /** * Get timestamp of the operation marked by server. You can use this timestamp as for guarantee timestamp of query/search api. - * + *

* Note: the timestamp is not an absolute timestamp, it is a hybrid value combined by UTC time and internal flags. - * We call it TSO, for more information: @see Hybrid Timestamp in Milvus + * We call it TSO, for more information: @see Hybrid Timestamp in Milvus * * @return int row count of the deleted entities */ diff --git a/sdk-core/src/main/java/io/milvus/response/QueryResultsWrapper.java b/sdk-core/src/main/java/io/milvus/response/QueryResultsWrapper.java index 833ce41b3..eddec3168 100644 --- a/sdk-core/src/main/java/io/milvus/response/QueryResultsWrapper.java +++ b/sdk-core/src/main/java/io/milvus/response/QueryResultsWrapper.java @@ -19,14 +19,17 @@ package io.milvus.response; -import com.google.gson.*; +import com.google.gson.JsonObject; import io.milvus.exception.ParamException; -import io.milvus.grpc.*; +import io.milvus.grpc.FieldData; +import io.milvus.grpc.QueryResults; import io.milvus.param.Constant; - import io.milvus.response.basic.RowRecordWrapper; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * Utility class to wrap response of query interface. @@ -81,7 +84,7 @@ public List getRowRecords() { /** * Gets a row record from result. - * Throws {@link ParamException} if the index is illegal. + * Throws {@link ParamException} if the index is illegal. * * @param index index of a row * @return RowRecord a row record of the result @@ -156,7 +159,7 @@ public Object get(String keyName) throws ParamException { // find the value from dynamic field Object meta = fieldValues.get(Constant.DYNAMIC_FIELD_NAME); if (meta != null) { - JsonObject jsonMata = (JsonObject)meta; + JsonObject jsonMata = (JsonObject) meta; Object innerObj = jsonMata.get(keyName); if (innerObj != null) { return innerObj; diff --git a/sdk-core/src/main/java/io/milvus/response/SearchResultsWrapper.java b/sdk-core/src/main/java/io/milvus/response/SearchResultsWrapper.java index fad08cb32..399d52087 100644 --- a/sdk-core/src/main/java/io/milvus/response/SearchResultsWrapper.java +++ b/sdk-core/src/main/java/io/milvus/response/SearchResultsWrapper.java @@ -19,7 +19,7 @@ package io.milvus.response; -import com.google.gson.*; +import com.google.gson.JsonObject; import io.milvus.exception.IllegalResponseException; import io.milvus.exception.ParamException; import io.milvus.grpc.*; @@ -71,7 +71,7 @@ public FieldDataWrapper getFieldWrapper(String fieldName) throws ParamException /** * Note: this method only can return the first target vector's topk result - * and its function is duplicated with getIDScore(), so we mark it as deprecated. + * and its function is duplicated with getIDScore(), so we mark it as deprecated. */ @Deprecated @Override @@ -99,7 +99,7 @@ public List getRowRecords(int indexOfTarget) { } record.put("score", score.getScore()); // use score instead - buildRowRecord(record, indexOfTarget*topK + (long)i); + buildRowRecord(record, indexOfTarget * topK + (long) i); records.add(record); } return records; @@ -119,7 +119,7 @@ protected List getOutputFields() { * Throws {@link ParamException} if the field doesn't exist. * Throws {@link ParamException} if the indexOfTarget is illegal. * - * @param fieldName field name to get output data + * @param fieldName field name to get output data * @param indexOfTarget which target vector the field data belongs to * @return {@link FieldDataWrapper} */ @@ -148,7 +148,7 @@ public List getFieldData(String fieldName, int indexOfTarget) { throw new IllegalResponseException("Field data row count is wrong"); } - return allData.subList((int)offset, (int)offset + (int)k); + return allData.subList((int) offset, (int) offset + (int) k); } /** @@ -179,7 +179,7 @@ public List getIDScore(int indexOfTarget) throws ParamException, Illega } for (int n = 0; n < k; ++n) { - idScores.add(new IDScore(primaryKey, "", longIDs.getData((int)offset + n), results.getScores((int)offset + n))); + idScores.add(new IDScore(primaryKey, "", longIDs.getData((int) offset + n), results.getScores((int) offset + n))); } } else if (ids.hasStrId()) { StringArray strIDs = ids.getStrId(); @@ -188,7 +188,7 @@ public List getIDScore(int indexOfTarget) throws ParamException, Illega } for (int n = 0; n < k; ++n) { - idScores.add(new IDScore(primaryKey, strIDs.getData((int)offset + n), 0, results.getScores((int)offset + n))); + idScores.add(new IDScore(primaryKey, strIDs.getData((int) offset + n), 0, results.getScores((int) offset + n))); } } else { // in v2.3.3, return an empty list instead of throwing exception @@ -218,7 +218,7 @@ public List getIDScore(int indexOfTarget) throws ParamException, Illega throw new ParamException("Illegal values length of output fields"); } - Object value = wrapper.valueByIdx((int)offset + n); + Object value = wrapper.valueByIdx((int) offset + n); if (wrapper.isJsonField()) { idScores.get(n).put(field.getFieldName(), FieldDataWrapper.ParseJSONObject(value)); } else { @@ -234,7 +234,7 @@ public List getIDScore(int indexOfTarget) throws ParamException, Illega // if the output field is not a field name, fetch it from dynamic field if (!isField && dynamicField != null) { for (int n = 0; n < k; ++n) { - Object obj = dynamicField.get((int)offset + n, outputKey); + Object obj = dynamicField.get((int) offset + n, outputKey); if (obj != null) { idScores.get(n).put(outputKey, obj); } @@ -246,6 +246,7 @@ public List getIDScore(int indexOfTarget) throws ParamException, Illega /** * Gets how many nq are searched. + * * @return how many nq are searched */ public long getNumQueries() { @@ -269,6 +270,7 @@ public long getK() { return k; } } + private Position getOffsetByIndex(int indexOfTarget) { List kList = results.getTopksList(); @@ -329,6 +331,7 @@ public float getScore() { /** * Get all field values as a map + * * @return Map containing all field values */ public Map getFieldValues() { @@ -337,8 +340,9 @@ public Map getFieldValues() { /** * Add a field value to the existing values + * * @param keyName field name - * @param obj field value + * @param obj field value * @return true if the value was added, false if the key already exists */ public boolean put(String keyName, Object obj) { @@ -368,7 +372,7 @@ public Object get(String keyName) throws ParamException { // find the value from dynamic field Object meta = fieldValues.get(Constant.DYNAMIC_FIELD_NAME); if (meta != null) { - JsonObject jsonMeta = (JsonObject)meta; + JsonObject jsonMeta = (JsonObject) meta; Object innerObj = jsonMeta.get(keyName); if (innerObj != null) { return innerObj; diff --git a/sdk-core/src/main/java/io/milvus/response/ShowCollResponseWrapper.java b/sdk-core/src/main/java/io/milvus/response/ShowCollResponseWrapper.java index c254854b4..d3b870e8f 100644 --- a/sdk-core/src/main/java/io/milvus/response/ShowCollResponseWrapper.java +++ b/sdk-core/src/main/java/io/milvus/response/ShowCollResponseWrapper.java @@ -49,7 +49,7 @@ public List getCollectionNames() { */ public List getCollectionsInfo() throws IllegalResponseException { if (response.getCollectionNamesCount() != response.getCollectionIdsCount() - || response.getCollectionNamesCount() != response.getCreatedUtcTimestampsCount()) { + || response.getCollectionNamesCount() != response.getCreatedUtcTimestampsCount()) { throw new IllegalResponseException("Collection information count doesn't match"); } diff --git a/sdk-core/src/main/java/io/milvus/response/basic/RowRecordWrapper.java b/sdk-core/src/main/java/io/milvus/response/basic/RowRecordWrapper.java index c0feb1447..b481f4428 100644 --- a/sdk-core/src/main/java/io/milvus/response/basic/RowRecordWrapper.java +++ b/sdk-core/src/main/java/io/milvus/response/basic/RowRecordWrapper.java @@ -19,7 +19,8 @@ package io.milvus.response.basic; -import com.google.gson.*; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import io.milvus.exception.ParamException; import io.milvus.grpc.FieldData; import io.milvus.response.FieldDataWrapper; @@ -66,7 +67,7 @@ public FieldDataWrapper getDynamicWrapper() throws ParamException { /** * Gets a row record from result. - * Throws {@link ParamException} if the index is illegal. + * Throws {@link ParamException} if the index is illegal. * * @return RowRecord a row record of the result */ @@ -78,7 +79,7 @@ protected QueryResultsWrapper.RowRecord buildRowRecord(QueryResultsWrapper.RowRe if (index < 0 || index >= wrapper.getRowCount()) { throw new ParamException("Index out of range"); } - Object value = wrapper.valueByIdx((int)index); + Object value = wrapper.valueByIdx((int) index); if (wrapper.isJsonField()) { JsonElement jsonValue = FieldDataWrapper.ParseJSONObject(value); if (!field.getIsDynamic()) { @@ -91,11 +92,11 @@ protected QueryResultsWrapper.RowRecord buildRowRecord(QueryResultsWrapper.RowRe throw new ParamException("The content of dynamic field is not a JSON dict"); } - JsonObject jsonDict = (JsonObject)jsonValue; + JsonObject jsonDict = (JsonObject) jsonValue; // the outputFields of QueryRequest/SearchRequest contains a "$meta" // put all key/value pairs of "$meta" into record // else pick some key/value pairs according to the dynamicFields - for (String key: jsonDict.keySet()) { + for (String key : jsonDict.keySet()) { if (dynamicFields.isEmpty() || dynamicFields.contains(key)) { record.put(key, FieldDataWrapper.ValueOfJSONElement(jsonDict.get(key))); } @@ -141,5 +142,6 @@ private List getDynamicFieldNames() { } protected abstract List getFieldDataList(); + protected abstract List getOutputFields(); } diff --git a/sdk-core/src/main/java/io/milvus/v2/client/ConnectConfig.java b/sdk-core/src/main/java/io/milvus/v2/client/ConnectConfig.java index df851ae41..9216061b0 100644 --- a/sdk-core/src/main/java/io/milvus/v2/client/ConnectConfig.java +++ b/sdk-core/src/main/java/io/milvus/v2/client/ConnectConfig.java @@ -19,16 +19,14 @@ package io.milvus.v2.client; -import static io.milvus.common.constant.MilvusClientConstant.MilvusConsts.CLOUD_SERVERLESS_URI_REGEX; +import io.milvus.common.utils.URLParser; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import javax.net.ssl.SSLContext; import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; -import io.milvus.common.utils.URLParser; +import static io.milvus.common.constant.MilvusClientConstant.MilvusConsts.CLOUD_SERVERLESS_URI_REGEX; public class ConnectConfig { private String uri; @@ -57,7 +55,7 @@ public class ConnectConfig { private ThreadLocal clientRequestId; // Constructor for builder - private ConnectConfig(Builder builder) { + private ConnectConfig(ConnectConfigBuilder builder) { if (builder.uri == null) { throw new NullPointerException("uri is marked non-null but is null"); } @@ -83,8 +81,8 @@ private ConnectConfig(Builder builder) { this.clientRequestId = builder.clientRequestId; } - public static Builder builder() { - return new Builder(); + public static ConnectConfigBuilder builder() { + return new ConnectConfigBuilder(); } // Getters @@ -283,63 +281,6 @@ public Boolean isSecure() { return secure; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ConnectConfig that = (ConnectConfig) o; - - return new EqualsBuilder() - .append(connectTimeoutMs, that.connectTimeoutMs) - .append(keepAliveTimeMs, that.keepAliveTimeMs) - .append(keepAliveTimeoutMs, that.keepAliveTimeoutMs) - .append(keepAliveWithoutCalls, that.keepAliveWithoutCalls) - .append(rpcDeadlineMs, that.rpcDeadlineMs) - .append(idleTimeoutMs, that.idleTimeoutMs) - .append(uri, that.uri) - .append(token, that.token) - .append(username, that.username) - .append(password, that.password) - .append(dbName, that.dbName) - .append(clientKeyPath, that.clientKeyPath) - .append(clientPemPath, that.clientPemPath) - .append(caPemPath, that.caPemPath) - .append(serverPemPath, that.serverPemPath) - .append(serverName, that.serverName) - .append(proxyAddress, that.proxyAddress) - .append(secure, that.secure) - .append(sslContext, that.sslContext) - .append(clientRequestId, that.clientRequestId) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(uri) - .append(token) - .append(username) - .append(password) - .append(dbName) - .append(connectTimeoutMs) - .append(keepAliveTimeMs) - .append(keepAliveTimeoutMs) - .append(keepAliveWithoutCalls) - .append(rpcDeadlineMs) - .append(clientKeyPath) - .append(clientPemPath) - .append(caPemPath) - .append(serverPemPath) - .append(serverName) - .append(proxyAddress) - .append(secure) - .append(idleTimeoutMs) - .append(sslContext) - .append(clientRequestId) - .toHashCode(); - } - @Override public String toString() { return "ConnectConfig{" + @@ -366,7 +307,7 @@ public String toString() { '}'; } - public static class Builder { + public static class ConnectConfigBuilder { private String uri; private String token; private String username; @@ -388,7 +329,7 @@ public static class Builder { private SSLContext sslContext; private ThreadLocal clientRequestId; - public Builder uri(String uri) { + public ConnectConfigBuilder uri(String uri) { if (uri == null) { throw new NullPointerException("uri is marked non-null but is null"); } @@ -396,97 +337,97 @@ public Builder uri(String uri) { return this; } - public Builder token(String token) { + public ConnectConfigBuilder token(String token) { this.token = token; return this; } - public Builder username(String username) { + public ConnectConfigBuilder username(String username) { this.username = username; return this; } - public Builder password(String password) { + public ConnectConfigBuilder password(String password) { this.password = password; return this; } - public Builder dbName(String dbName) { + public ConnectConfigBuilder dbName(String dbName) { this.dbName = dbName; return this; } - public Builder connectTimeoutMs(long connectTimeoutMs) { + public ConnectConfigBuilder connectTimeoutMs(long connectTimeoutMs) { this.connectTimeoutMs = connectTimeoutMs; return this; } - public Builder keepAliveTimeMs(long keepAliveTimeMs) { + public ConnectConfigBuilder keepAliveTimeMs(long keepAliveTimeMs) { this.keepAliveTimeMs = keepAliveTimeMs; return this; } - public Builder keepAliveTimeoutMs(long keepAliveTimeoutMs) { + public ConnectConfigBuilder keepAliveTimeoutMs(long keepAliveTimeoutMs) { this.keepAliveTimeoutMs = keepAliveTimeoutMs; return this; } - public Builder keepAliveWithoutCalls(boolean keepAliveWithoutCalls) { + public ConnectConfigBuilder keepAliveWithoutCalls(boolean keepAliveWithoutCalls) { this.keepAliveWithoutCalls = keepAliveWithoutCalls; return this; } - public Builder rpcDeadlineMs(long rpcDeadlineMs) { + public ConnectConfigBuilder rpcDeadlineMs(long rpcDeadlineMs) { this.rpcDeadlineMs = rpcDeadlineMs; return this; } - public Builder clientKeyPath(String clientKeyPath) { + public ConnectConfigBuilder clientKeyPath(String clientKeyPath) { this.clientKeyPath = clientKeyPath; return this; } - public Builder clientPemPath(String clientPemPath) { + public ConnectConfigBuilder clientPemPath(String clientPemPath) { this.clientPemPath = clientPemPath; return this; } - public Builder caPemPath(String caPemPath) { + public ConnectConfigBuilder caPemPath(String caPemPath) { this.caPemPath = caPemPath; return this; } - public Builder serverPemPath(String serverPemPath) { + public ConnectConfigBuilder serverPemPath(String serverPemPath) { this.serverPemPath = serverPemPath; return this; } - public Builder serverName(String serverName) { + public ConnectConfigBuilder serverName(String serverName) { this.serverName = serverName; return this; } - public Builder proxyAddress(String proxyAddress) { + public ConnectConfigBuilder proxyAddress(String proxyAddress) { this.proxyAddress = proxyAddress; return this; } - public Builder secure(Boolean secure) { + public ConnectConfigBuilder secure(Boolean secure) { this.secure = secure; return this; } - public Builder idleTimeoutMs(long idleTimeoutMs) { + public ConnectConfigBuilder idleTimeoutMs(long idleTimeoutMs) { this.idleTimeoutMs = idleTimeoutMs; return this; } - public Builder sslContext(SSLContext sslContext) { + public ConnectConfigBuilder sslContext(SSLContext sslContext) { this.sslContext = sslContext; return this; } - public Builder clientRequestId(ThreadLocal clientRequestId) { + public ConnectConfigBuilder clientRequestId(ThreadLocal clientRequestId) { this.clientRequestId = clientRequestId; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java b/sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java index 4f66618ca..9051c23ef 100644 --- a/sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java +++ b/sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java @@ -20,32 +20,41 @@ package io.milvus.v2.client; import io.grpc.ManagedChannel; -import io.milvus.grpc.*; +import io.milvus.grpc.ClientInfo; +import io.milvus.grpc.ConnectRequest; +import io.milvus.grpc.ConnectResponse; +import io.milvus.grpc.MilvusServiceGrpc; import io.milvus.orm.iterator.QueryIterator; import io.milvus.orm.iterator.SearchIterator; import io.milvus.orm.iterator.SearchIteratorV2; - import io.milvus.v2.service.cdc.CDCService; -import io.milvus.v2.service.cdc.request.*; -import io.milvus.v2.service.cdc.response.*; -import io.milvus.v2.service.database.DatabaseService; -import io.milvus.v2.service.database.request.*; -import io.milvus.v2.service.database.response.*; +import io.milvus.v2.service.cdc.request.UpdateReplicateConfigurationReq; +import io.milvus.v2.service.cdc.response.UpdateReplicateConfigurationResp; import io.milvus.v2.service.collection.CollectionService; import io.milvus.v2.service.collection.request.*; -import io.milvus.v2.service.collection.response.*; +import io.milvus.v2.service.collection.response.DescribeCollectionResp; +import io.milvus.v2.service.collection.response.DescribeReplicasResp; +import io.milvus.v2.service.collection.response.GetCollectionStatsResp; +import io.milvus.v2.service.collection.response.ListCollectionsResp; +import io.milvus.v2.service.database.DatabaseService; +import io.milvus.v2.service.database.request.*; +import io.milvus.v2.service.database.response.DescribeDatabaseResp; +import io.milvus.v2.service.database.response.ListDatabasesResp; import io.milvus.v2.service.index.IndexService; import io.milvus.v2.service.index.request.*; -import io.milvus.v2.service.index.response.*; +import io.milvus.v2.service.index.response.DescribeIndexResp; import io.milvus.v2.service.partition.PartitionService; import io.milvus.v2.service.partition.request.*; -import io.milvus.v2.service.partition.response.*; +import io.milvus.v2.service.partition.response.GetPartitionStatsResp; import io.milvus.v2.service.rbac.RBACService; import io.milvus.v2.service.rbac.request.*; -import io.milvus.v2.service.rbac.response.*; +import io.milvus.v2.service.rbac.response.DescribeRoleResp; +import io.milvus.v2.service.rbac.response.DescribeUserResp; +import io.milvus.v2.service.rbac.response.ListPrivilegeGroupsResp; import io.milvus.v2.service.resourcegroup.ResourceGroupService; import io.milvus.v2.service.resourcegroup.request.*; -import io.milvus.v2.service.resourcegroup.response.*; +import io.milvus.v2.service.resourcegroup.response.DescribeResourceGroupResp; +import io.milvus.v2.service.resourcegroup.response.ListResourceGroupsResp; import io.milvus.v2.service.utility.UtilityService; import io.milvus.v2.service.utility.request.*; import io.milvus.v2.service.utility.response.*; @@ -80,6 +89,7 @@ public class MilvusClientV2 { /** * Creates a Milvus client instance. + * * @param connectConfig Milvus server connection configuration */ public MilvusClientV2(ConnectConfig connectConfig) { @@ -112,10 +122,10 @@ private void initServices(String dbName) { * * @param connectConfig Milvus server connection configuration */ - private void connect(ConnectConfig connectConfig){ + private void connect(ConnectConfig connectConfig) { this.connectConfig = connectConfig; try { - if(this.channel != null) { + if (this.channel != null) { // close channel first close(3); } @@ -149,7 +159,7 @@ private MilvusServiceGrpc.MilvusServiceBlockingStub getRpcStub() { * This method is internal used, it calls a RPC Connect() to the remote server, * and sends the client info to the server so that the server knows which client is interacting, * especially for accesses log. - * + *

* The info includes: * 1. username(if Authentication is enabled) * 2. the client computer's name @@ -192,7 +202,7 @@ public MilvusClientV2 withTimeout(long timeout, TimeUnit timeoutUnit) { // if the input timeout value is not zero and less than 1ms, it will be treated as 1ms // if the input timeout value is larger than 1ms, it will be converted to an integer ms value long nn = timeoutUnit.toNanos(timeout); - long ms = (nn == 0) ? 0 : (nn < 1000000 ? 1 : nn/1000000); + long ms = (nn == 0) ? 0 : (nn < 1000000 ? 1 : nn / 1000000); connectConfig.setRpcDeadlineMs(ms); return this; } @@ -210,6 +220,7 @@ public String currentUsedDatabase() { ///////////////////////////////////////////////////////////////////////////////////////////// /** * use Database + * * @param dbName databaseName */ public void useDatabase(String dbName) throws InterruptedException { @@ -223,7 +234,7 @@ public void useDatabase(String dbName) throws InterruptedException { this.close(3); this.connect(this.connectConfig); this.initServices(dbName); - } catch (InterruptedException e){ + } catch (InterruptedException e) { logger.error("close connect error"); throw new RuntimeException(e); } @@ -231,28 +242,35 @@ public void useDatabase(String dbName) throws InterruptedException { /** * Creates a database in Milvus. + * * @param request create database request */ public void createDatabase(CreateDatabaseReq request) { - rpcUtils.retry(()-> databaseService.createDatabase(this.getRpcStub(), request)); + rpcUtils.retry(() -> databaseService.createDatabase(this.getRpcStub(), request)); } + /** * Drops a database. Note that this method drops all data in the database. + * * @param request drop database request */ public void dropDatabase(DropDatabaseReq request) { - rpcUtils.retry(()-> databaseService.dropDatabase(this.getRpcStub(), request)); + rpcUtils.retry(() -> databaseService.dropDatabase(this.getRpcStub(), request)); } + /** * List all databases. + * * @return List of String database names */ public ListDatabasesResp listDatabases() { - return rpcUtils.retry(()-> databaseService.listDatabases(this.getRpcStub())); + return rpcUtils.retry(() -> databaseService.listDatabases(this.getRpcStub())); } + /** * Alter database with key value pair. (Available from Milvus v2.4.4) * Deprecated, replaced by alterDatabaseProperties from SDK v2.5.3, to keep consistence with other SDKs + * * @param request alter database request */ @Deprecated @@ -262,28 +280,33 @@ public void alterDatabase(AlterDatabaseReq request) { .properties(request.getProperties()) .build()); } + /** * Alter a database's properties. + * * @param request alter database properties request */ public void alterDatabaseProperties(AlterDatabasePropertiesReq request) { - rpcUtils.retry(()-> databaseService.alterDatabaseProperties(this.getRpcStub(), request)); + rpcUtils.retry(() -> databaseService.alterDatabaseProperties(this.getRpcStub(), request)); } + /** * drop a database's properties. + * * @param request alter database properties request */ public void dropDatabaseProperties(DropDatabasePropertiesReq request) { - rpcUtils.retry(()-> databaseService.dropDatabaseProperties(this.getRpcStub(), request)); + rpcUtils.retry(() -> databaseService.dropDatabaseProperties(this.getRpcStub(), request)); } + /** * Show detail of database base, such as replica number and resource groups. (Available from Milvus v2.4.4) - * @param request describe database request * + * @param request describe database request * @return DescribeDatabaseResp */ public DescribeDatabaseResp describeDatabase(DescribeDatabaseReq request) { - return rpcUtils.retry(()-> databaseService.describeDatabase(this.getRpcStub(), request)); + return rpcUtils.retry(() -> databaseService.describeDatabase(this.getRpcStub(), request)); } ///////////////////////////////////////////////////////////////////////////////////////////// @@ -291,14 +314,16 @@ public DescribeDatabaseResp describeDatabase(DescribeDatabaseReq request) { ///////////////////////////////////////////////////////////////////////////////////////////// /** * Creates a collection in Milvus. + * * @param request create collection request */ public void createCollection(CreateCollectionReq request) { - rpcUtils.retry(()-> collectionService.createCollection(this.getRpcStub(), request)); + rpcUtils.retry(() -> collectionService.createCollection(this.getRpcStub(), request)); } /** * Creates a collection schema. This method is deprecated from v2.5.9, replaced by CreateSchema() + * * @return CreateCollectionReq.CollectionSchema */ @Deprecated @@ -308,6 +333,7 @@ public CreateCollectionReq.CollectionSchema createSchema() { /** * Creates a collection schema. + * * @return CreateCollectionReq.CollectionSchema */ public static CreateCollectionReq.CollectionSchema CreateSchema() { @@ -320,8 +346,9 @@ public static CreateCollectionReq.CollectionSchema CreateSchema() { * @return List of String collection names */ public ListCollectionsResp listCollections() { - return rpcUtils.retry(()-> collectionService.listCollections(this.getRpcStub(), "")); + return rpcUtils.retry(() -> collectionService.listCollections(this.getRpcStub(), "")); } + /** * List milvus collections, can specify the target database * Note: the old API listCollections() doesn't have a ListCollectionsReq argument, we have to create @@ -330,17 +357,19 @@ public ListCollectionsResp listCollections() { * @return List of String collection names */ public ListCollectionsResp listCollectionsV2(ListCollectionsReq request) { - return rpcUtils.retry(()-> collectionService.listCollections(this.getRpcStub(), request.getDatabaseName())); + return rpcUtils.retry(() -> collectionService.listCollections(this.getRpcStub(), request.getDatabaseName())); } + /** * Drops a collection in Milvus. * * @param request drop collection request */ public void dropCollection(DropCollectionReq request) { - rpcUtils.retry(()-> collectionService.dropCollection(this.getRpcStub(), request)); + rpcUtils.retry(() -> collectionService.dropCollection(this.getRpcStub(), request)); vectorService.removeCollectionCache(request.getDatabaseName(), request.getCollectionName()); } + /** * Alter a collection in Milvus. * Deprecated, replaced by alterCollectionProperties from SDK v2.5.3, to keep consistence with other SDKs @@ -355,44 +384,52 @@ public void alterCollection(AlterCollectionReq request) { .properties(request.getProperties()) .build()); } + /** * Alter a collection's properties. * * @param request alter collection properties request */ public void alterCollectionProperties(AlterCollectionPropertiesReq request) { - rpcUtils.retry(()-> collectionService.alterCollectionProperties(this.getRpcStub(), request)); + rpcUtils.retry(() -> collectionService.alterCollectionProperties(this.getRpcStub(), request)); } + /** * Add a new field to collection. * * @param request add new field request */ public void addCollectionField(AddCollectionFieldReq request) { - rpcUtils.retry(()-> collectionService.addCollectionField(this.getRpcStub(), request)); + rpcUtils.retry(() -> collectionService.addCollectionField(this.getRpcStub(), request)); } + /** * Alter a field's properties. * * @param request alter field properties request */ public void alterCollectionField(AlterCollectionFieldReq request) { - rpcUtils.retry(()-> collectionService.alterCollectionField(this.getRpcStub(), request)); + rpcUtils.retry(() -> collectionService.alterCollectionField(this.getRpcStub(), request)); } + /** * drop a collection's properties. + * * @param request drop collection properties request */ public void dropCollectionProperties(DropCollectionPropertiesReq request) { - rpcUtils.retry(()-> collectionService.dropCollectionProperties(this.getRpcStub(), request)); + rpcUtils.retry(() -> collectionService.dropCollectionProperties(this.getRpcStub(), request)); } + /** * drop a field's properties. + * * @param request drop field properties request */ public void dropCollectionFieldProperties(DropCollectionFieldPropertiesReq request) { - rpcUtils.retry(()-> collectionService.dropCollectionFieldProperties(this.getRpcStub(), request)); + rpcUtils.retry(() -> collectionService.dropCollectionFieldProperties(this.getRpcStub(), request)); } + /** * Checks whether a collection exists in Milvus. * @@ -400,8 +437,9 @@ public void dropCollectionFieldProperties(DropCollectionFieldPropertiesReq reque * @return Boolean */ public Boolean hasCollection(HasCollectionReq request) { - return rpcUtils.retry(()-> collectionService.hasCollection(this.getRpcStub(), request)); + return rpcUtils.retry(() -> collectionService.hasCollection(this.getRpcStub(), request)); } + /** * Gets the collection info in Milvus. * @@ -409,7 +447,7 @@ public Boolean hasCollection(HasCollectionReq request) { * @return DescribeCollectionResp */ public DescribeCollectionResp describeCollection(DescribeCollectionReq request) { - return rpcUtils.retry(()-> collectionService.describeCollection(this.getRpcStub(), request)); + return rpcUtils.retry(() -> collectionService.describeCollection(this.getRpcStub(), request)); } /** @@ -419,7 +457,7 @@ public DescribeCollectionResp describeCollection(DescribeCollectionReq request) * @return List */ public List batchDescribeCollection(BatchDescribeCollectionReq request) { - return rpcUtils.retry(()-> collectionService.batchDescribeCollections(this.getRpcStub(), request)); + return rpcUtils.retry(() -> collectionService.batchDescribeCollections(this.getRpcStub(), request)); } /** @@ -429,24 +467,27 @@ public List batchDescribeCollection(BatchDescribeCollect * @return GetCollectionStatsResp */ public GetCollectionStatsResp getCollectionStats(GetCollectionStatsReq request) { - return rpcUtils.retry(()-> collectionService.getCollectionStats(this.getRpcStub(), request)); + return rpcUtils.retry(() -> collectionService.getCollectionStats(this.getRpcStub(), request)); } + /** * rename collection in a collection in Milvus. * * @param request rename collection request */ public void renameCollection(RenameCollectionReq request) { - rpcUtils.retry(()-> collectionService.renameCollection(this.getRpcStub(), request)); + rpcUtils.retry(() -> collectionService.renameCollection(this.getRpcStub(), request)); } + /** * Loads a collection into memory in Milvus. * * @param request load collection request */ public void loadCollection(LoadCollectionReq request) { - rpcUtils.retry(()-> collectionService.loadCollection(this.getRpcStub(), request)); + rpcUtils.retry(() -> collectionService.loadCollection(this.getRpcStub(), request)); } + /** * Refresh loads a collection. Mainly used when there are new segments generated by bulkinsert request. * Force the new segments to be loaded into memory. @@ -455,16 +496,18 @@ public void loadCollection(LoadCollectionReq request) { * @param request refresh load collection request */ public void refreshLoad(RefreshLoadReq request) { - rpcUtils.retry(()-> collectionService.refreshLoad(this.getRpcStub(), request)); + rpcUtils.retry(() -> collectionService.refreshLoad(this.getRpcStub(), request)); } + /** * Releases a collection from memory in Milvus. * * @param request release collection request */ public void releaseCollection(ReleaseCollectionReq request) { - rpcUtils.retry(()-> collectionService.releaseCollection(this.getRpcStub(), request)); + rpcUtils.retry(() -> collectionService.releaseCollection(this.getRpcStub(), request)); } + /** * Checks whether a collection is loaded in Milvus. * @@ -472,7 +515,7 @@ public void releaseCollection(ReleaseCollectionReq request) { * @return Boolean */ public Boolean getLoadState(GetLoadStateReq request) { - return rpcUtils.retry(()->collectionService.getLoadState(this.getRpcStub(), request)); + return rpcUtils.retry(() -> collectionService.getLoadState(this.getRpcStub(), request)); } /** @@ -481,7 +524,7 @@ public Boolean getLoadState(GetLoadStateReq request) { * @param request describe replicas request */ public DescribeReplicasResp describeReplicas(DescribeReplicasReq request) { - return rpcUtils.retry(()->collectionService.describeReplicas(this.getRpcStub(), request)); + return rpcUtils.retry(() -> collectionService.describeReplicas(this.getRpcStub(), request)); } ///////////////////////////////////////////////////////////////////////////////////////////// @@ -493,16 +536,18 @@ public DescribeReplicasResp describeReplicas(DescribeReplicasReq request) { * @param request create index request */ public void createIndex(CreateIndexReq request) { - rpcUtils.retry(()->indexService.createIndex(this.getRpcStub(), request)); + rpcUtils.retry(() -> indexService.createIndex(this.getRpcStub(), request)); } + /** * Drops an index for a specified field in a collection in Milvus. * * @param request drop index request */ public void dropIndex(DropIndexReq request) { - rpcUtils.retry(()->indexService.dropIndex(this.getRpcStub(), request)); + rpcUtils.retry(() -> indexService.dropIndex(this.getRpcStub(), request)); } + /** * Alter an index in Milvus. * Deprecated, replaced by alterIndexProperties from SDK v2.5.3, to keep consistence with other SDKs @@ -518,21 +563,25 @@ public void alterIndex(AlterIndexReq request) { .properties(request.getProperties()) .build()); } + /** * Alter an index's properties. * * @param request alter index request */ public void alterIndexProperties(AlterIndexPropertiesReq request) { - rpcUtils.retry(()->indexService.alterIndexProperties(this.getRpcStub(), request)); + rpcUtils.retry(() -> indexService.alterIndexProperties(this.getRpcStub(), request)); } + /** * drop an index's properties. + * * @param request drop index properties request */ public void dropIndexProperties(DropIndexPropertiesReq request) { - rpcUtils.retry(()-> indexService.dropIndexProperties(this.getRpcStub(), request)); + rpcUtils.retry(() -> indexService.dropIndexProperties(this.getRpcStub(), request)); } + /** * Checks whether an index exists for a specified field in a collection in Milvus. * @@ -540,8 +589,9 @@ public void dropIndexProperties(DropIndexPropertiesReq request) { * @return DescribeIndexResp */ public DescribeIndexResp describeIndex(DescribeIndexReq request) { - return rpcUtils.retry(()->indexService.describeIndex(this.getRpcStub(), request)); + return rpcUtils.retry(() -> indexService.describeIndex(this.getRpcStub(), request)); } + /** * Lists all indexes in a collection in Milvus. * @@ -549,7 +599,7 @@ public DescribeIndexResp describeIndex(DescribeIndexReq request) { * @return List of String names of the indexes */ public List listIndexes(ListIndexesReq request) { - return rpcUtils.retry(()->indexService.listIndexes(this.getRpcStub(), request)); + return rpcUtils.retry(() -> indexService.listIndexes(this.getRpcStub(), request)); } ///////////////////////////////////////////////////////////////////////////////////////////// @@ -562,8 +612,9 @@ public List listIndexes(ListIndexesReq request) { * @return InsertResp */ public InsertResp insert(InsertReq request) { - return rpcUtils.retry(()->vectorService.insert(this.getRpcStub(), request)); + return rpcUtils.retry(() -> vectorService.insert(this.getRpcStub(), request)); } + /** * Upsert vectors into a collection in Milvus. * @@ -571,8 +622,9 @@ public InsertResp insert(InsertReq request) { * @return UpsertResp */ public UpsertResp upsert(UpsertReq request) { - return rpcUtils.retry(()->vectorService.upsert(this.getRpcStub(), request)); + return rpcUtils.retry(() -> vectorService.upsert(this.getRpcStub(), request)); } + /** * Deletes vectors in a collection in Milvus. * @@ -580,8 +632,9 @@ public UpsertResp upsert(UpsertReq request) { * @return DeleteResp */ public DeleteResp delete(DeleteReq request) { - return rpcUtils.retry(()->vectorService.delete(this.getRpcStub(), request)); + return rpcUtils.retry(() -> vectorService.delete(this.getRpcStub(), request)); } + /** * Gets vectors in a collection in Milvus. * @@ -589,7 +642,7 @@ public DeleteResp delete(DeleteReq request) { * @return GetResp */ public GetResp get(GetReq request) { - return rpcUtils.retry(()->vectorService.get(this.getRpcStub(), request)); + return rpcUtils.retry(() -> vectorService.get(this.getRpcStub(), request)); } /** @@ -599,8 +652,9 @@ public GetResp get(GetReq request) { * @return QueryResp */ public QueryResp query(QueryReq request) { - return rpcUtils.retry(()->vectorService.query(this.getRpcStub(), request)); + return rpcUtils.retry(() -> vectorService.query(this.getRpcStub(), request)); } + /** * Searches vectors in a collection in Milvus. * @@ -608,8 +662,9 @@ public QueryResp query(QueryReq request) { * @return SearchResp */ public SearchResp search(SearchReq request) { - return rpcUtils.retry(()->vectorService.search(this.getRpcStub(), request)); + return rpcUtils.retry(() -> vectorService.search(this.getRpcStub(), request)); } + /** * Conducts multi vector similarity search with a ranker for rearrangement. * @@ -617,7 +672,7 @@ public SearchResp search(SearchReq request) { * @return SearchResp */ public SearchResp hybridSearch(HybridSearchReq request) { - return rpcUtils.retry(()->vectorService.hybridSearch(this.getRpcStub(), request)); + return rpcUtils.retry(() -> vectorService.hybridSearch(this.getRpcStub(), request)); } /** @@ -628,7 +683,7 @@ public SearchResp hybridSearch(HybridSearchReq request) { * @return QueryIterator */ public QueryIterator queryIterator(QueryIteratorReq request) { - return rpcUtils.retry(()->vectorService.queryIterator(this.getRpcStub(), request)); + return rpcUtils.retry(() -> vectorService.queryIterator(this.getRpcStub(), request)); } /** @@ -638,7 +693,7 @@ public QueryIterator queryIterator(QueryIteratorReq request) { * @return SearchIterator */ public SearchIterator searchIterator(SearchIteratorReq request) { - return rpcUtils.retry(()->vectorService.searchIterator(this.getRpcStub(), request)); + return rpcUtils.retry(() -> vectorService.searchIterator(this.getRpcStub(), request)); } /** @@ -648,7 +703,7 @@ public SearchIterator searchIterator(SearchIteratorReq request) { * @return SearchIteratorV2 */ public SearchIteratorV2 searchIteratorV2(SearchIteratorReqV2 request) { - return rpcUtils.retry(()->vectorService.searchIteratorV2(this.getRpcStub(), request)); + return rpcUtils.retry(() -> vectorService.searchIteratorV2(this.getRpcStub(), request)); } /** @@ -659,7 +714,7 @@ public SearchIteratorV2 searchIteratorV2(SearchIteratorReqV2 request) { * @return RunAnalyzerResp */ public RunAnalyzerResp runAnalyzer(RunAnalyzerReq request) { - return rpcUtils.retry(()->vectorService.runAnalyzer(this.getRpcStub(), request)); + return rpcUtils.retry(() -> vectorService.runAnalyzer(this.getRpcStub(), request)); } ///////////////////////////////////////////////////////////////////////////////////////////// @@ -671,7 +726,7 @@ public RunAnalyzerResp runAnalyzer(RunAnalyzerReq request) { * @param request create partition request */ public void createPartition(CreatePartitionReq request) { - rpcUtils.retry(()->partitionService.createPartition(this.getRpcStub(), request)); + rpcUtils.retry(() -> partitionService.createPartition(this.getRpcStub(), request)); } /** @@ -680,7 +735,7 @@ public void createPartition(CreatePartitionReq request) { * @param request drop partition request */ public void dropPartition(DropPartitionReq request) { - rpcUtils.retry(()->partitionService.dropPartition(this.getRpcStub(), request)); + rpcUtils.retry(() -> partitionService.dropPartition(this.getRpcStub(), request)); } /** @@ -690,7 +745,7 @@ public void dropPartition(DropPartitionReq request) { * @return Boolean */ public Boolean hasPartition(HasPartitionReq request) { - return rpcUtils.retry(()->partitionService.hasPartition(this.getRpcStub(), request)); + return rpcUtils.retry(() -> partitionService.hasPartition(this.getRpcStub(), request)); } /** @@ -700,7 +755,7 @@ public Boolean hasPartition(HasPartitionReq request) { * @return List of String partition names */ public List listPartitions(ListPartitionsReq request) { - return rpcUtils.retry(()->partitionService.listPartitions(this.getRpcStub(), request)); + return rpcUtils.retry(() -> partitionService.listPartitions(this.getRpcStub(), request)); } /** @@ -710,7 +765,7 @@ public List listPartitions(ListPartitionsReq request) { * @return GetPartitionStatsResp */ public GetPartitionStatsResp getPartitionStats(GetPartitionStatsReq request) { - return rpcUtils.retry(()-> partitionService.getPartitionStats(this.getRpcStub(), request)); + return rpcUtils.retry(() -> partitionService.getPartitionStats(this.getRpcStub(), request)); } /** @@ -719,15 +774,16 @@ public GetPartitionStatsResp getPartitionStats(GetPartitionStatsReq request) { * @param request load partitions request */ public void loadPartitions(LoadPartitionsReq request) { - rpcUtils.retry(()->partitionService.loadPartitions(this.getRpcStub(), request)); + rpcUtils.retry(() -> partitionService.loadPartitions(this.getRpcStub(), request)); } + /** * Releases partitions in a collection in Milvus. * * @param request release partitions request */ public void releasePartitions(ReleasePartitionsReq request) { - rpcUtils.retry(()->partitionService.releasePartitions(this.getRpcStub(), request)); + rpcUtils.retry(() -> partitionService.releasePartitions(this.getRpcStub(), request)); } ///////////////////////////////////////////////////////////////////////////////////////////// @@ -739,8 +795,9 @@ public void releasePartitions(ReleasePartitionsReq request) { * @return List of String usernames */ public List listUsers() { - return rpcUtils.retry(()->rbacService.listUsers(this.getRpcStub())); + return rpcUtils.retry(() -> rbacService.listUsers(this.getRpcStub())); } + /** * describe user * @@ -748,41 +805,46 @@ public List listUsers() { * @return DescribeUserResp */ public DescribeUserResp describeUser(DescribeUserReq request) { - return rpcUtils.retry(()->rbacService.describeUser(this.getRpcStub(), request)); + return rpcUtils.retry(() -> rbacService.describeUser(this.getRpcStub(), request)); } + /** * create user * * @param request create user request */ public void createUser(CreateUserReq request) { - rpcUtils.retry(()->rbacService.createUser(this.getRpcStub(), request)); + rpcUtils.retry(() -> rbacService.createUser(this.getRpcStub(), request)); } + /** * change password * * @param request change password request */ public void updatePassword(UpdatePasswordReq request) { - rpcUtils.retry(()->rbacService.updatePassword(this.getRpcStub(), request)); + rpcUtils.retry(() -> rbacService.updatePassword(this.getRpcStub(), request)); } + /** * drop user * * @param request drop user request */ public void dropUser(DropUserReq request) { - rpcUtils.retry(()->rbacService.dropUser(this.getRpcStub(), request)); + rpcUtils.retry(() -> rbacService.dropUser(this.getRpcStub(), request)); } // role operations + /** * list roles * * @return List of String role names */ public List listRoles() { - return rpcUtils.retry(()->rbacService.listRoles(this.getRpcStub())); + return rpcUtils.retry(() -> rbacService.listRoles(this.getRpcStub())); } + /** * describe role * @@ -790,83 +852,89 @@ public List listRoles() { * @return DescribeRoleResp */ public DescribeRoleResp describeRole(DescribeRoleReq request) { - return rpcUtils.retry(()->rbacService.describeRole(this.getRpcStub(), request)); + return rpcUtils.retry(() -> rbacService.describeRole(this.getRpcStub(), request)); } + /** * create role * * @param request create role request */ public void createRole(CreateRoleReq request) { - rpcUtils.retry(()->rbacService.createRole(this.getRpcStub(), request)); + rpcUtils.retry(() -> rbacService.createRole(this.getRpcStub(), request)); } + /** * drop role * * @param request drop role request */ public void dropRole(DropRoleReq request) { - rpcUtils.retry(()->rbacService.dropRole(this.getRpcStub(), request)); + rpcUtils.retry(() -> rbacService.dropRole(this.getRpcStub(), request)); } + /** * grant privilege * * @param request grant privilege request */ public void grantPrivilege(GrantPrivilegeReq request) { - rpcUtils.retry(()->rbacService.grantPrivilege(this.getRpcStub(), request)); + rpcUtils.retry(() -> rbacService.grantPrivilege(this.getRpcStub(), request)); } + /** * revoke privilege * * @param request revoke privilege request */ public void revokePrivilege(RevokePrivilegeReq request) { - rpcUtils.retry(()->rbacService.revokePrivilege(this.getRpcStub(), request)); + rpcUtils.retry(() -> rbacService.revokePrivilege(this.getRpcStub(), request)); } + /** * grant role * * @param request grant role request */ public void grantRole(GrantRoleReq request) { - rpcUtils.retry(()->rbacService.grantRole(this.getRpcStub(), request)); + rpcUtils.retry(() -> rbacService.grantRole(this.getRpcStub(), request)); } + /** * revoke role * * @param request revoke role request */ public void revokeRole(RevokeRoleReq request) { - rpcUtils.retry(()->rbacService.revokeRole(this.getRpcStub(), request)); + rpcUtils.retry(() -> rbacService.revokeRole(this.getRpcStub(), request)); } public void createPrivilegeGroup(CreatePrivilegeGroupReq request) { - rpcUtils.retry(()->rbacService.createPrivilegeGroup(this.getRpcStub(), request)); + rpcUtils.retry(() -> rbacService.createPrivilegeGroup(this.getRpcStub(), request)); } public void dropPrivilegeGroup(DropPrivilegeGroupReq request) { - rpcUtils.retry(()->rbacService.dropPrivilegeGroup(this.getRpcStub(), request)); + rpcUtils.retry(() -> rbacService.dropPrivilegeGroup(this.getRpcStub(), request)); } public ListPrivilegeGroupsResp listPrivilegeGroups(ListPrivilegeGroupsReq request) { - return rpcUtils.retry(()->rbacService.listPrivilegeGroups(this.getRpcStub(), request)); + return rpcUtils.retry(() -> rbacService.listPrivilegeGroups(this.getRpcStub(), request)); } public void addPrivilegesToGroup(AddPrivilegesToGroupReq request) { - rpcUtils.retry(()->rbacService.addPrivilegesToGroup(this.getRpcStub(), request)); + rpcUtils.retry(() -> rbacService.addPrivilegesToGroup(this.getRpcStub(), request)); } public void removePrivilegesFromGroup(RemovePrivilegesFromGroupReq request) { - rpcUtils.retry(()->rbacService.removePrivilegesFromGroup(this.getRpcStub(), request)); + rpcUtils.retry(() -> rbacService.removePrivilegesFromGroup(this.getRpcStub(), request)); } public void grantPrivilegeV2(GrantPrivilegeReqV2 request) { - rpcUtils.retry(()->rbacService.grantPrivilegeV2(this.getRpcStub(), request)); + rpcUtils.retry(() -> rbacService.grantPrivilegeV2(this.getRpcStub(), request)); } public void revokePrivilegeV2(RevokePrivilegeReqV2 request) { - rpcUtils.retry(()->rbacService.revokePrivilegeV2(this.getRpcStub(), request)); + rpcUtils.retry(() -> rbacService.revokePrivilegeV2(this.getRpcStub(), request)); } ///////////////////////////////////////////////////////////////////////////////////////////// @@ -877,8 +945,8 @@ public void revokePrivilegeV2(RevokePrivilegeReqV2 request) { * * @param request {@link CreateResourceGroupReq} */ - public void createResourceGroup(CreateResourceGroupReq request){ - rpcUtils.retry(()->rgroupService.createResourceGroup(this.getRpcStub(), request)); + public void createResourceGroup(CreateResourceGroupReq request) { + rpcUtils.retry(() -> rgroupService.createResourceGroup(this.getRpcStub(), request)); } /** @@ -887,7 +955,7 @@ public void createResourceGroup(CreateResourceGroupReq request){ * @param request {@link UpdateResourceGroupsReq} */ public void updateResourceGroups(UpdateResourceGroupsReq request) { - rpcUtils.retry(()->rgroupService.updateResourceGroups(this.getRpcStub(), request)); + rpcUtils.retry(() -> rgroupService.updateResourceGroups(this.getRpcStub(), request)); } /** @@ -896,7 +964,7 @@ public void updateResourceGroups(UpdateResourceGroupsReq request) { * @param request {@link DropResourceGroupReq} */ public void dropResourceGroup(DropResourceGroupReq request) { - rpcUtils.retry(()->rgroupService.dropResourceGroup(this.getRpcStub(), request)); + rpcUtils.retry(() -> rgroupService.dropResourceGroup(this.getRpcStub(), request)); } /** @@ -906,7 +974,7 @@ public void dropResourceGroup(DropResourceGroupReq request) { * @return ListResourceGroupsResp */ public ListResourceGroupsResp listResourceGroups(ListResourceGroupsReq request) { - return rpcUtils.retry(()->rgroupService.listResourceGroups(this.getRpcStub(), request)); + return rpcUtils.retry(() -> rgroupService.listResourceGroups(this.getRpcStub(), request)); } /** @@ -916,7 +984,7 @@ public ListResourceGroupsResp listResourceGroups(ListResourceGroupsReq request) * @return DescribeResourceGroupResp */ public DescribeResourceGroupResp describeResourceGroup(DescribeResourceGroupReq request) { - return rpcUtils.retry(()->rgroupService.describeResourceGroup(this.getRpcStub(), request)); + return rpcUtils.retry(() -> rgroupService.describeResourceGroup(this.getRpcStub(), request)); } /** @@ -925,7 +993,7 @@ public DescribeResourceGroupResp describeResourceGroup(DescribeResourceGroupReq * @param request {@link TransferNodeReq} */ public void transferNode(TransferNodeReq request) { - rpcUtils.retry(()->rgroupService.transferNode(this.getRpcStub(), request)); + rpcUtils.retry(() -> rgroupService.transferNode(this.getRpcStub(), request)); } /** @@ -934,7 +1002,7 @@ public void transferNode(TransferNodeReq request) { * @param request {@link TransferReplicaReq} */ public void transferReplica(TransferReplicaReq request) { - rpcUtils.retry(()->rgroupService.transferReplica(this.getRpcStub(), request)); + rpcUtils.retry(() -> rgroupService.transferReplica(this.getRpcStub(), request)); } ///////////////////////////////////////////////////////////////////////////////////////////// @@ -946,24 +1014,27 @@ public void transferReplica(TransferReplicaReq request) { * @param request create alias request */ public void createAlias(CreateAliasReq request) { - rpcUtils.retry(()->utilityService.createAlias(this.getRpcStub(), request)); + rpcUtils.retry(() -> utilityService.createAlias(this.getRpcStub(), request)); } + /** * drop aliases * * @param request drop alias request */ public void dropAlias(DropAliasReq request) { - rpcUtils.retry(()->utilityService.dropAlias(this.getRpcStub(), request)); + rpcUtils.retry(() -> utilityService.dropAlias(this.getRpcStub(), request)); } + /** * alter aliases * * @param request alter alias request */ public void alterAlias(AlterAliasReq request) { - rpcUtils.retry(()->utilityService.alterAlias(this.getRpcStub(), request)); + rpcUtils.retry(() -> utilityService.alterAlias(this.getRpcStub(), request)); } + /** * list aliases * @@ -971,8 +1042,9 @@ public void alterAlias(AlterAliasReq request) { * @return List of String alias names */ public ListAliasResp listAliases(ListAliasesReq request) { - return rpcUtils.retry(()->utilityService.listAliases(this.getRpcStub(), request)); + return rpcUtils.retry(() -> utilityService.listAliases(this.getRpcStub(), request)); } + /** * describe aliases * @@ -980,7 +1052,7 @@ public ListAliasResp listAliases(ListAliasesReq request) { * @return DescribeAliasResp */ public DescribeAliasResp describeAlias(DescribeAliasReq request) { - return rpcUtils.retry(()->utilityService.describeAlias(this.getRpcStub(), request)); + return rpcUtils.retry(() -> utilityService.describeAlias(this.getRpcStub(), request)); } /** @@ -989,7 +1061,7 @@ public DescribeAliasResp describeAlias(DescribeAliasReq request) { * @param request flush request */ public void flush(FlushReq request) { - FlushResp response = rpcUtils.retry(()->utilityService.flush(this.getRpcStub(), request)); + FlushResp response = rpcUtils.retry(() -> utilityService.flush(this.getRpcStub(), request)); // The BlockingStub.flush() api returns immediately after the datanode set all growing segments to be "sealed". // The flush state becomes "Completed" after the datanode uploading them to S3 asynchronously. @@ -1010,7 +1082,7 @@ public void flush(FlushReq request) { * @return GetPersistentSegmentInfoResp */ public GetPersistentSegmentInfoResp getPersistentSegmentInfo(GetPersistentSegmentInfoReq request) { - return rpcUtils.retry(()->utilityService.getPersistentSegmentInfo(this.getRpcStub(), request)); + return rpcUtils.retry(() -> utilityService.getPersistentSegmentInfo(this.getRpcStub(), request)); } /** @@ -1020,8 +1092,8 @@ public GetPersistentSegmentInfoResp getPersistentSegmentInfo(GetPersistentSegmen * @param request get request * @return GetQuerySegmentInfoResp */ - public GetQuerySegmentInfoResp getQuerySegmentInfo(GetQuerySegmentInfoReq request){ - return rpcUtils.retry(()->utilityService.getQuerySegmentInfo(this.getRpcStub(), request)); + public GetQuerySegmentInfoResp getQuerySegmentInfo(GetQuerySegmentInfoReq request) { + return rpcUtils.retry(() -> utilityService.getQuerySegmentInfo(this.getRpcStub(), request)); } /** @@ -1031,7 +1103,7 @@ public GetQuerySegmentInfoResp getQuerySegmentInfo(GetQuerySegmentInfoReq reques * @return CompactResp */ public CompactResp compact(CompactReq request) { - return rpcUtils.retry(()->utilityService.compact(this.getRpcStub(), request)); + return rpcUtils.retry(() -> utilityService.compact(this.getRpcStub(), request)); } /** @@ -1041,7 +1113,7 @@ public CompactResp compact(CompactReq request) { * @return GetCompactStateResp */ public GetCompactionStateResp getCompactionState(GetCompactionStateReq request) { - return rpcUtils.retry(()->utilityService.getCompactionState(this.getRpcStub(), request)); + return rpcUtils.retry(() -> utilityService.getCompactionState(this.getRpcStub(), request)); } /** @@ -1050,7 +1122,7 @@ public GetCompactionStateResp getCompactionState(GetCompactionStateReq request) * @return String */ public String getServerVersion() { - return rpcUtils.retry(()->clientUtils.getServerVersion(this.getRpcStub())); + return rpcUtils.retry(() -> clientUtils.getServerVersion(this.getRpcStub())); } /** @@ -1059,11 +1131,11 @@ public String getServerVersion() { * @return CheckHealthResp */ public CheckHealthResp checkHealth() { - return rpcUtils.retry(()->utilityService.checkHealth(this.getRpcStub())); + return rpcUtils.retry(() -> utilityService.checkHealth(this.getRpcStub())); } public UpdateReplicateConfigurationResp updateReplicateConfiguration(UpdateReplicateConfigurationReq request) { - return rpcUtils.retry(()->cdcService.updateReplicateConfiguration(this.getRpcStub(), request)); + return rpcUtils.retry(() -> cdcService.updateReplicateConfiguration(this.getRpcStub(), request)); } /** @@ -1073,7 +1145,7 @@ public UpdateReplicateConfigurationResp updateReplicateConfiguration(UpdateRepli * @throws InterruptedException throws InterruptedException if the client failed to close connection */ public void close(long maxWaitSeconds) throws InterruptedException { - if(channel!= null){ + if (channel != null) { channel.shutdownNow(); channel.awaitTermination(maxWaitSeconds, TimeUnit.SECONDS); } diff --git a/sdk-core/src/main/java/io/milvus/v2/client/RetryConfig.java b/sdk-core/src/main/java/io/milvus/v2/client/RetryConfig.java index 5e3b3f223..808f8a65c 100644 --- a/sdk-core/src/main/java/io/milvus/v2/client/RetryConfig.java +++ b/sdk-core/src/main/java/io/milvus/v2/client/RetryConfig.java @@ -19,9 +19,6 @@ package io.milvus.v2.client; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class RetryConfig { private int maxRetryTimes = 75; private long initialBackOffMs = 10; @@ -31,7 +28,7 @@ public class RetryConfig { private long maxRetryTimeoutMs = 0; // Constructor for builder pattern - private RetryConfig(Builder builder) { + private RetryConfig(RetryConfigBuilder builder) { this.maxRetryTimes = builder.maxRetryTimes; this.initialBackOffMs = builder.initialBackOffMs; this.maxBackOffMs = builder.maxBackOffMs; @@ -40,8 +37,8 @@ private RetryConfig(Builder builder) { this.maxRetryTimeoutMs = builder.maxRetryTimeoutMs; } - public static Builder builder() { - return new Builder(); + public static RetryConfigBuilder builder() { + return new RetryConfigBuilder(); } // Getters @@ -94,35 +91,6 @@ public void setMaxRetryTimeoutMs(long maxRetryTimeoutMs) { this.maxRetryTimeoutMs = maxRetryTimeoutMs; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - RetryConfig that = (RetryConfig) o; - - return new EqualsBuilder() - .append(maxRetryTimes, that.maxRetryTimes) - .append(initialBackOffMs, that.initialBackOffMs) - .append(maxBackOffMs, that.maxBackOffMs) - .append(backOffMultiplier, that.backOffMultiplier) - .append(retryOnRateLimit, that.retryOnRateLimit) - .append(maxRetryTimeoutMs, that.maxRetryTimeoutMs) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(maxRetryTimes) - .append(initialBackOffMs) - .append(maxBackOffMs) - .append(backOffMultiplier) - .append(retryOnRateLimit) - .append(maxRetryTimeoutMs) - .toHashCode(); - } - @Override public String toString() { return "RetryConfig{" + @@ -136,7 +104,7 @@ public String toString() { } // Builder class with public access modifier - public static class Builder { + public static class RetryConfigBuilder { private int maxRetryTimes = 75; private long initialBackOffMs = 10; private long maxBackOffMs = 3000; @@ -144,32 +112,32 @@ public static class Builder { private boolean retryOnRateLimit = true; private long maxRetryTimeoutMs = 0; - public Builder maxRetryTimes(int maxRetryTimes) { + public RetryConfigBuilder maxRetryTimes(int maxRetryTimes) { this.maxRetryTimes = maxRetryTimes; return this; } - public Builder initialBackOffMs(long initialBackOffMs) { + public RetryConfigBuilder initialBackOffMs(long initialBackOffMs) { this.initialBackOffMs = initialBackOffMs; return this; } - public Builder maxBackOffMs(long maxBackOffMs) { + public RetryConfigBuilder maxBackOffMs(long maxBackOffMs) { this.maxBackOffMs = maxBackOffMs; return this; } - public Builder backOffMultiplier(int backOffMultiplier) { + public RetryConfigBuilder backOffMultiplier(int backOffMultiplier) { this.backOffMultiplier = backOffMultiplier; return this; } - public Builder retryOnRateLimit(boolean retryOnRateLimit) { + public RetryConfigBuilder retryOnRateLimit(boolean retryOnRateLimit) { this.retryOnRateLimit = retryOnRateLimit; return this; } - public Builder maxRetryTimeoutMs(long maxRetryTimeoutMs) { + public RetryConfigBuilder maxRetryTimeoutMs(long maxRetryTimeoutMs) { this.maxRetryTimeoutMs = maxRetryTimeoutMs; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/common/CompactionState.java b/sdk-core/src/main/java/io/milvus/v2/common/CompactionState.java index 546859845..c4c261aca 100644 --- a/sdk-core/src/main/java/io/milvus/v2/common/CompactionState.java +++ b/sdk-core/src/main/java/io/milvus/v2/common/CompactionState.java @@ -25,7 +25,7 @@ public enum CompactionState { Completed(2); private final int code; - + CompactionState(int code) { this.code = code; } diff --git a/sdk-core/src/main/java/io/milvus/v2/common/ConsistencyLevel.java b/sdk-core/src/main/java/io/milvus/v2/common/ConsistencyLevel.java index ab128d939..fd7f1b463 100644 --- a/sdk-core/src/main/java/io/milvus/v2/common/ConsistencyLevel.java +++ b/sdk-core/src/main/java/io/milvus/v2/common/ConsistencyLevel.java @@ -19,15 +19,15 @@ package io.milvus.v2.common; -public enum ConsistencyLevel{ +public enum ConsistencyLevel { STRONG("Strong", 0), SESSION("Session", 1), BOUNDED("Bounded", 2), - EVENTUALLY("Eventually",3), + EVENTUALLY("Eventually", 3), ; private final String name; private final int code; - + ConsistencyLevel(String name, int code) { this.name = name; this.code = code; diff --git a/sdk-core/src/main/java/io/milvus/v2/common/DataType.java b/sdk-core/src/main/java/io/milvus/v2/common/DataType.java index 4cf2da611..7072b42a4 100644 --- a/sdk-core/src/main/java/io/milvus/v2/common/DataType.java +++ b/sdk-core/src/main/java/io/milvus/v2/common/DataType.java @@ -49,7 +49,7 @@ public enum DataType { Struct(201); private final int code; - + DataType(int code) { this.code = code; } diff --git a/sdk-core/src/main/java/io/milvus/v2/common/IndexParam.java b/sdk-core/src/main/java/io/milvus/v2/common/IndexParam.java index ec2eca984..219121b3a 100644 --- a/sdk-core/src/main/java/io/milvus/v2/common/IndexParam.java +++ b/sdk-core/src/main/java/io/milvus/v2/common/IndexParam.java @@ -19,9 +19,6 @@ package io.milvus.v2.common; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.Map; public class IndexParam { @@ -32,7 +29,7 @@ public class IndexParam { private Map extraParams; // Constructor for builder - private IndexParam(Builder builder) { + private IndexParam(IndexParamBuilder builder) { if (builder.fieldName == null) { throw new NullPointerException("fieldName cannot be null"); } @@ -43,8 +40,8 @@ private IndexParam(Builder builder) { this.extraParams = builder.extraParams; } - public static Builder builder() { - return new Builder(); + public static IndexParamBuilder builder() { + return new IndexParamBuilder(); } // Getters @@ -92,33 +89,6 @@ public void setExtraParams(Map extraParams) { this.extraParams = extraParams; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - IndexParam that = (IndexParam) o; - - return new EqualsBuilder() - .append(fieldName, that.fieldName) - .append(indexName, that.indexName) - .append(indexType, that.indexType) - .append(metricType, that.metricType) - .append(extraParams, that.extraParams) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(fieldName) - .append(indexName) - .append(indexType) - .append(metricType) - .append(extraParams) - .toHashCode(); - } - @Override public String toString() { return "IndexParam{" + @@ -131,14 +101,14 @@ public String toString() { } // Public Builder class - public static class Builder { + public static class IndexParamBuilder { private String fieldName; private String indexName; private IndexType indexType = IndexType.AUTOINDEX; private MetricType metricType; private Map extraParams; - public Builder fieldName(String fieldName) { + public IndexParamBuilder fieldName(String fieldName) { if (fieldName == null) { throw new NullPointerException("fieldName cannot be null"); } @@ -146,22 +116,22 @@ public Builder fieldName(String fieldName) { return this; } - public Builder indexName(String indexName) { + public IndexParamBuilder indexName(String indexName) { this.indexName = indexName; return this; } - public Builder indexType(IndexType indexType) { + public IndexParamBuilder indexType(IndexType indexType) { this.indexType = indexType; return this; } - public Builder metricType(MetricType metricType) { + public IndexParamBuilder metricType(MetricType metricType) { this.metricType = metricType; return this; } - public Builder extraParams(Map extraParams) { + public IndexParamBuilder extraParams(Map extraParams) { this.extraParams = extraParams; return this; } @@ -248,17 +218,17 @@ public enum IndexType { private final String name; private final int code; - IndexType(){ + IndexType() { this.name = this.toString(); this.code = this.ordinal(); } - IndexType(int code){ + IndexType(int code) { this.name = this.toString(); this.code = code; } - IndexType(String name, int code){ + IndexType(String name, int code) { this.name = name; this.code = code; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/CrossClusterTopology.java b/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/CrossClusterTopology.java index bfe721632..dbd791472 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/CrossClusterTopology.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/CrossClusterTopology.java @@ -20,9 +20,6 @@ package io.milvus.v2.service.cdc.request; -import java.util.Objects; - - public class CrossClusterTopology { private String sourceClusterId; private String targetClusterId; @@ -50,18 +47,6 @@ public void setTargetClusterId(String targetClusterId) { this.targetClusterId = targetClusterId; } - @Override - public boolean equals(Object o) { - if (o == null || getClass() != o.getClass()) return false; - CrossClusterTopology topology = (CrossClusterTopology) o; - return Objects.equals(sourceClusterId, topology.sourceClusterId) && Objects.equals(targetClusterId, topology.targetClusterId); - } - - @Override - public int hashCode() { - return Objects.hash(sourceClusterId, targetClusterId); - } - @Override public String toString() { return "CrossClusterTopology{" + @@ -70,21 +55,25 @@ public String toString() { '}'; } - private CrossClusterTopology(Builder builder) { + private CrossClusterTopology(CrossClusterTopologyBuilder builder) { this.sourceClusterId = builder.sourceClusterId; this.targetClusterId = builder.targetClusterId; } - public static class Builder { + public static CrossClusterTopologyBuilder builder() { + return new CrossClusterTopologyBuilder(); + } + + public static class CrossClusterTopologyBuilder { private String sourceClusterId; private String targetClusterId; - public Builder sourceClusterId(String sourceClusterId) { + public CrossClusterTopologyBuilder sourceClusterId(String sourceClusterId) { this.sourceClusterId = sourceClusterId; return this; } - public Builder targetClusterId(String targetClusterId) { + public CrossClusterTopologyBuilder targetClusterId(String targetClusterId) { this.targetClusterId = targetClusterId; return this; } @@ -93,8 +82,4 @@ public CrossClusterTopology build() { return new CrossClusterTopology(this); } } - - public static Builder builder() { - return new Builder(); - } } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/MilvusCluster.java b/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/MilvusCluster.java index 304751ece..a52356b6b 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/MilvusCluster.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/MilvusCluster.java @@ -20,7 +20,6 @@ package io.milvus.v2.service.cdc.request; import java.util.List; -import java.util.Objects; public class MilvusCluster { private String clusterId; @@ -44,7 +43,7 @@ public io.milvus.grpc.MilvusCluster toGRPC() { return builder.build(); } - private MilvusCluster(Builder builder) { + private MilvusCluster(MilvusClusterBuilder builder) { this.clusterId = builder.clusterId; this.uri = builder.uri; this.token = builder.token; @@ -83,18 +82,6 @@ public void setPchannels(List pchannels) { this.pchannels = pchannels; } - @Override - public boolean equals(Object o) { - if (o == null || getClass() != o.getClass()) return false; - MilvusCluster that = (MilvusCluster) o; - return Objects.equals(clusterId, that.clusterId) && Objects.equals(uri, that.uri) && Objects.equals(token, that.token) && Objects.equals(pchannels, that.pchannels); - } - - @Override - public int hashCode() { - return Objects.hash(clusterId, uri, token, pchannels); - } - @Override public String toString() { return "MilvusCluster{" + @@ -105,32 +92,32 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static MilvusClusterBuilder builder() { + return new MilvusClusterBuilder(); } - public static class Builder { + public static class MilvusClusterBuilder { private String clusterId; private String uri; private String token; private List pchannels; - public Builder clusterId(String clusterId) { + public MilvusClusterBuilder clusterId(String clusterId) { this.clusterId = clusterId; return this; } - public Builder uri(String uri) { + public MilvusClusterBuilder uri(String uri) { this.uri = uri; return this; } - public Builder token(String token) { + public MilvusClusterBuilder token(String token) { this.token = token; return this; } - public Builder pchannels(List pchannels) { + public MilvusClusterBuilder pchannels(List pchannels) { this.pchannels = pchannels; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/ReplicateConfiguration.java b/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/ReplicateConfiguration.java index 054ab5fd3..d91abc408 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/ReplicateConfiguration.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/ReplicateConfiguration.java @@ -20,7 +20,6 @@ package io.milvus.v2.service.cdc.request; import java.util.List; -import java.util.Objects; public class ReplicateConfiguration { private List clusters; @@ -43,7 +42,7 @@ public io.milvus.grpc.ReplicateConfiguration toGRPC() { return builder.build(); } - private ReplicateConfiguration(Builder builder) { + private ReplicateConfiguration(ReplicateConfigurationBuilder builder) { this.clusters = builder.clusters; this.crossClusterTopologies = builder.crossClusterTopologies; } @@ -64,18 +63,6 @@ public void setCrossClusterTopologies(List crossClusterTop this.crossClusterTopologies = crossClusterTopologies; } - @Override - public boolean equals(Object o) { - if (o == null || getClass() != o.getClass()) return false; - ReplicateConfiguration that = (ReplicateConfiguration) o; - return Objects.equals(clusters, that.clusters) && Objects.equals(crossClusterTopologies, that.crossClusterTopologies); - } - - @Override - public int hashCode() { - return Objects.hash(clusters, crossClusterTopologies); - } - @Override public String toString() { return "ReplicateConfiguration{" + @@ -84,20 +71,20 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static ReplicateConfigurationBuilder builder() { + return new ReplicateConfigurationBuilder(); } - public static class Builder { + public static class ReplicateConfigurationBuilder { private List clusters; private List crossClusterTopologies; - public Builder clusters(List clusters) { + public ReplicateConfigurationBuilder clusters(List clusters) { this.clusters = clusters; return this; } - public Builder crossClusterTopologies(List crossClusterTopologies) { + public ReplicateConfigurationBuilder crossClusterTopologies(List crossClusterTopologies) { this.crossClusterTopologies = crossClusterTopologies; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/UpdateReplicateConfigurationReq.java b/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/UpdateReplicateConfigurationReq.java index 78a43588f..be9e8f716 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/UpdateReplicateConfigurationReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/cdc/request/UpdateReplicateConfigurationReq.java @@ -19,16 +19,14 @@ package io.milvus.v2.service.cdc.request; -import java.util.Objects; - public class UpdateReplicateConfigurationReq { private ReplicateConfiguration replicateConfiguration; - public static Builder builder() { - return new Builder(); + public static UpdateReplicateConfigurationReqBuilder builder() { + return new UpdateReplicateConfigurationReqBuilder(); } - private UpdateReplicateConfigurationReq(Builder builder) { + private UpdateReplicateConfigurationReq(UpdateReplicateConfigurationReqBuilder builder) { this.replicateConfiguration = builder.replicateConfiguration; } @@ -40,18 +38,6 @@ public void setReplicateConfiguration(ReplicateConfiguration replicateConfigurat this.replicateConfiguration = replicateConfiguration; } - @Override - public boolean equals(Object o) { - if (o == null || getClass() != o.getClass()) return false; - UpdateReplicateConfigurationReq that = (UpdateReplicateConfigurationReq) o; - return Objects.equals(replicateConfiguration, that.replicateConfiguration); - } - - @Override - public int hashCode() { - return Objects.hashCode(replicateConfiguration); - } - @Override public String toString() { return "UpdateReplicateConfigurationReq{" + @@ -59,10 +45,10 @@ public String toString() { '}'; } - public static class Builder { + public static class UpdateReplicateConfigurationReqBuilder { private ReplicateConfiguration replicateConfiguration; - public Builder replicateConfiguration(ReplicateConfiguration replicateConfiguration) { + public UpdateReplicateConfigurationReqBuilder replicateConfiguration(ReplicateConfiguration replicateConfiguration) { this.replicateConfiguration = replicateConfiguration; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/cdc/response/UpdateReplicateConfigurationResp.java b/sdk-core/src/main/java/io/milvus/v2/service/cdc/response/UpdateReplicateConfigurationResp.java index deec59b39..4d9de697e 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/cdc/response/UpdateReplicateConfigurationResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/cdc/response/UpdateReplicateConfigurationResp.java @@ -21,14 +21,14 @@ public class UpdateReplicateConfigurationResp { - private UpdateReplicateConfigurationResp(Builder builder) { + private UpdateReplicateConfigurationResp(UpdateReplicateConfigurationRespBuilder builder) { } - public static Builder builder() { - return new Builder(); + public static UpdateReplicateConfigurationRespBuilder builder() { + return new UpdateReplicateConfigurationRespBuilder(); } - public static class Builder { + public static class UpdateReplicateConfigurationRespBuilder { public UpdateReplicateConfigurationResp build() { return new UpdateReplicateConfigurationResp(this); } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionInfo.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionInfo.java index e7a7e4ad0..056f142ef 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionInfo.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionInfo.java @@ -1,21 +1,18 @@ package io.milvus.v2.service.collection; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class CollectionInfo { private String collectionName; private Integer shardNum; // Private constructor for builder - private CollectionInfo(Builder builder) { + private CollectionInfo(CollectionInfoBuilder builder) { this.collectionName = builder.collectionName; this.shardNum = builder.shardNum; } // Static method to create builder - public static Builder builder() { - return new Builder(); + public static CollectionInfoBuilder builder() { + return new CollectionInfoBuilder(); } // Getter methods @@ -36,27 +33,6 @@ public void setShardNum(Integer shardNum) { this.shardNum = shardNum; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - CollectionInfo that = (CollectionInfo) o; - - return new EqualsBuilder() - .append(collectionName, that.collectionName) - .append(shardNum, that.shardNum) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(collectionName) - .append(shardNum) - .toHashCode(); - } - @Override public String toString() { return "CollectionInfo{" + @@ -66,16 +42,16 @@ public String toString() { } // Builder class - public static class Builder { + public static class CollectionInfoBuilder { private String collectionName; private Integer shardNum; - public Builder collectionName(String collectionName) { + public CollectionInfoBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder shardNum(Integer shardNum) { + public CollectionInfoBuilder shardNum(Integer shardNum) { this.shardNum = shardNum; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionService.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionService.java index b437d1da2..904b631c7 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionService.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionService.java @@ -27,7 +27,10 @@ import io.milvus.v2.exception.MilvusClientException; import io.milvus.v2.service.BaseService; import io.milvus.v2.service.collection.request.*; -import io.milvus.v2.service.collection.response.*; +import io.milvus.v2.service.collection.response.DescribeCollectionResp; +import io.milvus.v2.service.collection.response.DescribeReplicasResp; +import io.milvus.v2.service.collection.response.GetCollectionStatsResp; +import io.milvus.v2.service.collection.response.ListCollectionsResp; import io.milvus.v2.service.index.IndexService; import io.milvus.v2.service.index.request.CreateIndexReq; import io.milvus.v2.utils.SchemaUtils; @@ -95,15 +98,15 @@ public Void createCollection(MilvusServiceGrpc.MilvusServiceBlockingStub blockin //create index IndexParam indexParam = IndexParam.builder() - .metricType(IndexParam.MetricType.valueOf(request.getMetricType())) - .fieldName(request.getVectorFieldName()) - .build(); + .metricType(IndexParam.MetricType.valueOf(request.getMetricType())) + .fieldName(request.getVectorFieldName()) + .build(); CreateIndexReq createIndexReq = CreateIndexReq.builder() - .databaseName(dbName) - .collectionName(collectionName) - .indexParams(Collections.singletonList(indexParam)) - .sync(false) - .build(); + .databaseName(dbName) + .collectionName(collectionName) + .indexParams(Collections.singletonList(indexParam)) + .sync(false) + .build(); indexService.createIndex(blockingStub, createIndexReq); //load collection, set sync to false since no need to wait loading progress try { @@ -168,8 +171,8 @@ public Void createCollectionWithSchema(MilvusServiceGrpc.MilvusServiceBlockingSt rpcUtils.handleResponse(title, createCollectionResponse); //create index - if(request.getIndexParams() != null && !request.getIndexParams().isEmpty()) { - for(IndexParam indexParam : request.getIndexParams()) { + if (request.getIndexParams() != null && !request.getIndexParams().isEmpty()) { + for (IndexParam indexParam : request.getIndexParams()) { CreateIndexReq createIndexReq = CreateIndexReq.builder() .databaseName(dbName) .collectionName(collectionName) diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/ReplicaInfo.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/ReplicaInfo.java index 72ad3c3b6..b175c1517 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/ReplicaInfo.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/ReplicaInfo.java @@ -1,12 +1,9 @@ package io.milvus.v2.service.collection; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; public class ReplicaInfo { private Long replicaID; @@ -17,7 +14,7 @@ public class ReplicaInfo { private String resourceGroupName; private Map numOutboundNode; - private ReplicaInfo(Builder builder) { + private ReplicaInfo(ReplicaInfoBuilder builder) { this.replicaID = builder.replicaID; this.collectionID = builder.collectionID; this.partitionIDs = builder.partitionIDs != null ? builder.partitionIDs : new ArrayList<>(); @@ -27,8 +24,8 @@ private ReplicaInfo(Builder builder) { this.numOutboundNode = builder.numOutboundNode != null ? builder.numOutboundNode : new HashMap<>(); } - public static Builder builder() { - return new Builder(); + public static ReplicaInfoBuilder builder() { + return new ReplicaInfoBuilder(); } // Getters @@ -89,30 +86,6 @@ public void setNumOutboundNode(Map numOutboundNode) { this.numOutboundNode = numOutboundNode; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - ReplicaInfo that = (ReplicaInfo) obj; - - return new EqualsBuilder() - .append(replicaID, that.replicaID) - .append(collectionID, that.collectionID) - .append(partitionIDs, that.partitionIDs) - .append(shardReplicas, that.shardReplicas) - .append(nodeIDs, that.nodeIDs) - .append(resourceGroupName, that.resourceGroupName) - .append(numOutboundNode, that.numOutboundNode) - .isEquals(); - } - - @Override - public int hashCode() { - return Objects.hash(replicaID, collectionID, partitionIDs, shardReplicas, - nodeIDs, resourceGroupName, numOutboundNode); - } - @Override public String toString() { return "ReplicaInfo{" + @@ -126,7 +99,7 @@ public String toString() { '}'; } - public static class Builder { + public static class ReplicaInfoBuilder { private Long replicaID; private Long collectionID; private List partitionIDs; @@ -135,37 +108,37 @@ public static class Builder { private String resourceGroupName; private Map numOutboundNode; - public Builder replicaID(Long replicaID) { + public ReplicaInfoBuilder replicaID(Long replicaID) { this.replicaID = replicaID; return this; } - public Builder collectionID(Long collectionID) { + public ReplicaInfoBuilder collectionID(Long collectionID) { this.collectionID = collectionID; return this; } - public Builder partitionIDs(List partitionIDs) { + public ReplicaInfoBuilder partitionIDs(List partitionIDs) { this.partitionIDs = partitionIDs; return this; } - public Builder shardReplicas(List shardReplicas) { + public ReplicaInfoBuilder shardReplicas(List shardReplicas) { this.shardReplicas = shardReplicas; return this; } - public Builder nodeIDs(List nodeIDs) { + public ReplicaInfoBuilder nodeIDs(List nodeIDs) { this.nodeIDs = nodeIDs; return this; } - public Builder resourceGroupName(String resourceGroupName) { + public ReplicaInfoBuilder resourceGroupName(String resourceGroupName) { this.resourceGroupName = resourceGroupName; return this; } - public Builder numOutboundNode(Map numOutboundNode) { + public ReplicaInfoBuilder numOutboundNode(Map numOutboundNode) { this.numOutboundNode = numOutboundNode; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/ShardReplica.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/ShardReplica.java index 6f35f743e..3f7e191ce 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/ShardReplica.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/ShardReplica.java @@ -1,10 +1,7 @@ package io.milvus.v2.service.collection; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.ArrayList; import java.util.List; -import java.util.Objects; public class ShardReplica { private Long leaderID; @@ -12,15 +9,15 @@ public class ShardReplica { private String channelName; private List nodeIDs; - private ShardReplica(Builder builder) { + private ShardReplica(ShardReplicaBuilder builder) { this.leaderID = builder.leaderID; this.leaderAddress = builder.leaderAddress; this.channelName = builder.channelName != null ? builder.channelName : ""; this.nodeIDs = builder.nodeIDs != null ? builder.nodeIDs : new ArrayList<>(); } - public static Builder builder() { - return new Builder(); + public static ShardReplicaBuilder builder() { + return new ShardReplicaBuilder(); } // Getters @@ -57,26 +54,6 @@ public void setNodeIDs(List nodeIDs) { this.nodeIDs = nodeIDs; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - ShardReplica that = (ShardReplica) obj; - - return new EqualsBuilder() - .append(leaderID, that.leaderID) - .append(leaderAddress, that.leaderAddress) - .append(channelName, that.channelName) - .append(nodeIDs, that.nodeIDs) - .isEquals(); - } - - @Override - public int hashCode() { - return Objects.hash(leaderID, leaderAddress, channelName, nodeIDs); - } - @Override public String toString() { return "ShardReplica{" + @@ -87,28 +64,28 @@ public String toString() { '}'; } - public static class Builder { + public static class ShardReplicaBuilder { private Long leaderID; private String leaderAddress; private String channelName = ""; private List nodeIDs = new ArrayList<>(); - public Builder leaderID(Long leaderID) { + public ShardReplicaBuilder leaderID(Long leaderID) { this.leaderID = leaderID; return this; } - public Builder leaderAddress(String leaderAddress) { + public ShardReplicaBuilder leaderAddress(String leaderAddress) { this.leaderAddress = leaderAddress; return this; } - public Builder channelName(String channelName) { + public ShardReplicaBuilder channelName(String channelName) { this.channelName = channelName; return this; } - public Builder nodeIDs(List nodeIDs) { + public ShardReplicaBuilder nodeIDs(List nodeIDs) { this.nodeIDs = nodeIDs; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AddCollectionFieldReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AddCollectionFieldReq.java index 6b4acc968..1b88960e7 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AddCollectionFieldReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AddCollectionFieldReq.java @@ -19,14 +19,11 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class AddCollectionFieldReq extends AddFieldReq { private String collectionName; private String databaseName; - private AddCollectionFieldReq(Builder builder) { + private AddCollectionFieldReq(AddCollectionFieldReqBuilder builder) { super(builder); this.collectionName = builder.collectionName; this.databaseName = builder.databaseName; @@ -48,27 +45,6 @@ public void setDatabaseName(String databaseName) { this.databaseName = databaseName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - if (!super.equals(obj)) return false; - AddCollectionFieldReq that = (AddCollectionFieldReq) obj; - return new EqualsBuilder() - .append(collectionName, that.collectionName) - .append(databaseName, that.databaseName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .appendSuper(super.hashCode()) - .append(collectionName) - .append(databaseName) - .toHashCode(); - } - @Override public String toString() { return "AddCollectionFieldReq{" + @@ -78,141 +54,27 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static AddCollectionFieldReqBuilder builder() { + return new AddCollectionFieldReqBuilder(); } - public static class Builder extends AddFieldReq.Builder { + public static class AddCollectionFieldReqBuilder extends AddFieldReq.AddFieldReqBuilder { private String collectionName; private String databaseName; - private Builder() {} + private AddCollectionFieldReqBuilder() { + } - public Builder collectionName(String collectionName) { + public AddCollectionFieldReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder databaseName(String databaseName) { + public AddCollectionFieldReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - // Override all parent builder methods to return the correct type - @Override - public Builder fieldName(String fieldName) { - super.fieldName(fieldName); - return this; - } - - @Override - public Builder description(String description) { - super.description(description); - return this; - } - - @Override - public Builder dataType(io.milvus.v2.common.DataType dataType) { - super.dataType(dataType); - return this; - } - - @Override - public Builder maxLength(Integer maxLength) { - super.maxLength(maxLength); - return this; - } - - @Override - public Builder isPrimaryKey(Boolean isPrimaryKey) { - super.isPrimaryKey(isPrimaryKey); - return this; - } - - @Override - public Builder isPartitionKey(Boolean isPartitionKey) { - super.isPartitionKey(isPartitionKey); - return this; - } - - @Override - public Builder isClusteringKey(Boolean isClusteringKey) { - super.isClusteringKey(isClusteringKey); - return this; - } - - @Override - public Builder autoID(Boolean autoID) { - super.autoID(autoID); - return this; - } - - @Override - public Builder dimension(Integer dimension) { - super.dimension(dimension); - return this; - } - - @Override - public Builder elementType(io.milvus.v2.common.DataType elementType) { - super.elementType(elementType); - return this; - } - - @Override - public Builder maxCapacity(Integer maxCapacity) { - super.maxCapacity(maxCapacity); - return this; - } - - @Override - public Builder isNullable(Boolean isNullable) { - super.isNullable(isNullable); - return this; - } - - @Override - public Builder defaultValue(Object defaultValue) { - super.defaultValue(defaultValue); - return this; - } - - @Override - public Builder enableDefaultValue(boolean enableDefaultValue) { - super.enableDefaultValue(enableDefaultValue); - return this; - } - - @Override - public Builder enableAnalyzer(Boolean enableAnalyzer) { - super.enableAnalyzer(enableAnalyzer); - return this; - } - - @Override - public Builder analyzerParams(java.util.Map analyzerParams) { - super.analyzerParams(analyzerParams); - return this; - } - - @Override - public Builder enableMatch(Boolean enableMatch) { - super.enableMatch(enableMatch); - return this; - } - - @Override - public Builder typeParams(java.util.Map typeParams) { - super.typeParams(typeParams); - return this; - } - - @Override - public Builder multiAnalyzerParams(java.util.Map multiAnalyzerParams) { - super.multiAnalyzerParams(multiAnalyzerParams); - return this; - } - @Override public AddCollectionFieldReq build() { return new AddCollectionFieldReq(this); diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AddFieldReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AddFieldReq.java index 6fa8ea9fb..b7af86939 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AddFieldReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AddFieldReq.java @@ -23,12 +23,9 @@ import io.milvus.v2.service.collection.request.CreateCollectionReq.FieldSchema; import io.milvus.v2.utils.SchemaUtils; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Objects; public class AddFieldReq { private String fieldName; @@ -55,7 +52,7 @@ public class AddFieldReq { private List structFields; - AddFieldReq(Builder builder) { + AddFieldReq(AddFieldReqBuilder builder) { this.fieldName = builder.fieldName; this.description = builder.description != null ? builder.description : ""; this.dataType = builder.dataType; @@ -78,8 +75,8 @@ public class AddFieldReq { this.structFields = builder.structFields != null ? builder.structFields : new ArrayList<>(); } - public static Builder builder() { - return new Builder(); + public static AddFieldReqBuilder builder() { + return new AddFieldReqBuilder<>(); } // Getters @@ -244,46 +241,6 @@ public void setStructFields(List structFields) { this.structFields = structFields; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - AddFieldReq that = (AddFieldReq) obj; - - return new EqualsBuilder() - .append(enableDefaultValue, that.enableDefaultValue) - .append(fieldName, that.fieldName) - .append(description, that.description) - .append(dataType, that.dataType) - .append(maxLength, that.maxLength) - .append(isPrimaryKey, that.isPrimaryKey) - .append(isPartitionKey, that.isPartitionKey) - .append(isClusteringKey, that.isClusteringKey) - .append(autoID, that.autoID) - .append(dimension, that.dimension) - .append(elementType, that.elementType) - .append(maxCapacity, that.maxCapacity) - .append(isNullable, that.isNullable) - .append(defaultValue, that.defaultValue) - .append(enableAnalyzer, that.enableAnalyzer) - .append(analyzerParams, that.analyzerParams) - .append(enableMatch, that.enableMatch) - .append(typeParams, that.typeParams) - .append(multiAnalyzerParams, that.multiAnalyzerParams) - .append(structFields, that.structFields) - .isEquals(); - } - - @Override - public int hashCode() { - return Objects.hash(fieldName, description, dataType, maxLength, isPrimaryKey, - isPartitionKey, isClusteringKey, autoID, dimension, elementType, - maxCapacity, isNullable, defaultValue, enableDefaultValue, - enableAnalyzer, analyzerParams, enableMatch, typeParams, multiAnalyzerParams, - structFields); - } - @Override public String toString() { return "AddFieldReq{" + @@ -310,7 +267,7 @@ public String toString() { '}'; } - public static class Builder { + public static class AddFieldReqBuilder> { private String fieldName; private String description; private DataType dataType; @@ -332,109 +289,109 @@ public static class Builder { private Map multiAnalyzerParams; private List structFields; - public Builder fieldName(String fieldName) { + public T fieldName(String fieldName) { this.fieldName = fieldName; - return this; + return (T) this; } - public Builder description(String description) { + public T description(String description) { this.description = description; - return this; + return (T) this; } - public Builder dataType(DataType dataType) { + public T dataType(DataType dataType) { this.dataType = dataType; - return this; + return (T) this; } - public Builder maxLength(Integer maxLength) { + public T maxLength(Integer maxLength) { this.maxLength = maxLength; - return this; + return (T) this; } - public Builder isPrimaryKey(Boolean isPrimaryKey) { + public T isPrimaryKey(Boolean isPrimaryKey) { this.isPrimaryKey = isPrimaryKey; - return this; + return (T) this; } - public Builder isPartitionKey(Boolean isPartitionKey) { + public T isPartitionKey(Boolean isPartitionKey) { this.isPartitionKey = isPartitionKey; - return this; + return (T) this; } - public Builder isClusteringKey(Boolean isClusteringKey) { + public T isClusteringKey(Boolean isClusteringKey) { this.isClusteringKey = isClusteringKey; - return this; + return (T) this; } - public Builder autoID(Boolean autoID) { + public T autoID(Boolean autoID) { this.autoID = autoID; - return this; + return (T) this; } - public Builder dimension(Integer dimension) { + public T dimension(Integer dimension) { this.dimension = dimension; - return this; + return (T) this; } - public Builder elementType(DataType elementType) { + public T elementType(DataType elementType) { this.elementType = elementType; - return this; + return (T) this; } - public Builder maxCapacity(Integer maxCapacity) { + public T maxCapacity(Integer maxCapacity) { this.maxCapacity = maxCapacity; - return this; + return (T) this; } - public Builder isNullable(Boolean isNullable) { + public T isNullable(Boolean isNullable) { this.isNullable = isNullable; - return this; + return (T) this; } - public Builder defaultValue(Object defaultValue) { + public T defaultValue(Object defaultValue) { this.defaultValue = defaultValue; this.enableDefaultValue = true; - return this; + return (T) this; } - public Builder enableDefaultValue(boolean enableDefaultValue) { + public T enableDefaultValue(boolean enableDefaultValue) { this.enableDefaultValue = enableDefaultValue; - return this; + return (T) this; } - public Builder enableAnalyzer(Boolean enableAnalyzer) { + public T enableAnalyzer(Boolean enableAnalyzer) { this.enableAnalyzer = enableAnalyzer; - return this; + return (T) this; } - public Builder analyzerParams(Map analyzerParams) { + public T analyzerParams(Map analyzerParams) { this.analyzerParams = analyzerParams; - return this; + return (T) this; } - public Builder enableMatch(Boolean enableMatch) { + public T enableMatch(Boolean enableMatch) { this.enableMatch = enableMatch; - return this; + return (T) this; } - public Builder typeParams(Map typeParams) { + public T typeParams(Map typeParams) { this.typeParams = typeParams; - return this; + return (T) this; } - public Builder multiAnalyzerParams(Map multiAnalyzerParams) { + public T multiAnalyzerParams(Map multiAnalyzerParams) { this.multiAnalyzerParams = multiAnalyzerParams; - return this; + return (T) this; } - public Builder addStructField(AddFieldReq addFieldReq) { + public T addStructField(AddFieldReq addFieldReq) { if (this.structFields == null) { this.structFields = new ArrayList<>(); } CreateCollectionReq.FieldSchema field = SchemaUtils.convertFieldReqToFieldSchema(addFieldReq); this.structFields.add(field); - return this; + return (T) this; } public AddFieldReq build() { diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionFieldReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionFieldReq.java index a09ca3f67..5fde126e9 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionFieldReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionFieldReq.java @@ -19,9 +19,6 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.HashMap; import java.util.Map; @@ -31,7 +28,7 @@ public class AlterCollectionFieldReq { private String databaseName; private final Map properties = new HashMap<>(); - private AlterCollectionFieldReq(Builder builder) { + private AlterCollectionFieldReq(AlterCollectionFieldReqBuilder builder) { this.collectionName = builder.collectionName; this.fieldName = builder.fieldName; this.databaseName = builder.databaseName; @@ -68,29 +65,6 @@ public Map getProperties() { return properties; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AlterCollectionFieldReq that = (AlterCollectionFieldReq) obj; - return new EqualsBuilder() - .append(collectionName, that.collectionName) - .append(fieldName, that.fieldName) - .append(databaseName, that.databaseName) - .append(properties, that.properties) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(collectionName) - .append(fieldName) - .append(databaseName) - .append(properties) - .toHashCode(); - } - @Override public String toString() { return "AlterCollectionFieldReq{" + @@ -101,34 +75,35 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static AlterCollectionFieldReqBuilder builder() { + return new AlterCollectionFieldReqBuilder(); } - public static class Builder { + public static class AlterCollectionFieldReqBuilder { private String collectionName; private String fieldName; private String databaseName; private Map properties = new HashMap<>(); - private Builder() {} + private AlterCollectionFieldReqBuilder() { + } - public Builder collectionName(String collectionName) { + public AlterCollectionFieldReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder fieldName(String fieldName) { + public AlterCollectionFieldReqBuilder fieldName(String fieldName) { this.fieldName = fieldName; return this; } - public Builder databaseName(String databaseName) { + public AlterCollectionFieldReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder property(String key, String value) { + public AlterCollectionFieldReqBuilder property(String key, String value) { if (this.properties == null) { this.properties = new HashMap<>(); } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionPropertiesReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionPropertiesReq.java index c2bb3b0d4..e85f383a2 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionPropertiesReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionPropertiesReq.java @@ -19,9 +19,6 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.HashMap; import java.util.Map; @@ -30,7 +27,7 @@ public class AlterCollectionPropertiesReq { private String databaseName; private final Map properties = new HashMap<>(); - private AlterCollectionPropertiesReq(Builder builder) { + private AlterCollectionPropertiesReq(AlterCollectionPropertiesReqBuilder builder) { this.collectionName = builder.collectionName; this.databaseName = builder.databaseName; if (builder.properties != null) { @@ -58,27 +55,6 @@ public Map getProperties() { return properties; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AlterCollectionPropertiesReq that = (AlterCollectionPropertiesReq) obj; - return new EqualsBuilder() - .append(collectionName, that.collectionName) - .append(databaseName, that.databaseName) - .append(properties, that.properties) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(collectionName) - .append(databaseName) - .append(properties) - .toHashCode(); - } - @Override public String toString() { return "AlterCollectionPropertiesReq{" + @@ -88,33 +64,34 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static AlterCollectionPropertiesReqBuilder builder() { + return new AlterCollectionPropertiesReqBuilder(); } - public static class Builder { + public static class AlterCollectionPropertiesReqBuilder { private String collectionName; private String databaseName; private Map properties = new HashMap<>(); - private Builder() {} + private AlterCollectionPropertiesReqBuilder() { + } - public Builder collectionName(String collectionName) { + public AlterCollectionPropertiesReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder databaseName(String databaseName) { + public AlterCollectionPropertiesReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder properties(Map properties) { + public AlterCollectionPropertiesReqBuilder properties(Map properties) { this.properties = properties; return this; } - public Builder property(String key, String value) { + public AlterCollectionPropertiesReqBuilder property(String key, String value) { if (this.properties == null) { this.properties = new HashMap<>(); } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionReq.java index df3669ef7..7cb2424bf 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/AlterCollectionReq.java @@ -1,8 +1,5 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.HashMap; import java.util.Map; @@ -12,7 +9,7 @@ public class AlterCollectionReq { private String databaseName; private final Map properties = new HashMap<>(); - private AlterCollectionReq(Builder builder) { + private AlterCollectionReq(AlterCollectionReqBuilder builder) { this.collectionName = builder.collectionName; this.databaseName = builder.databaseName; if (builder.properties != null) { @@ -40,27 +37,6 @@ public Map getProperties() { return properties; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AlterCollectionReq that = (AlterCollectionReq) obj; - return new EqualsBuilder() - .append(collectionName, that.collectionName) - .append(databaseName, that.databaseName) - .append(properties, that.properties) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(collectionName) - .append(databaseName) - .append(properties) - .toHashCode(); - } - @Override public String toString() { return "AlterCollectionReq{" + @@ -70,28 +46,29 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static AlterCollectionReqBuilder builder() { + return new AlterCollectionReqBuilder(); } - public static class Builder { + public static class AlterCollectionReqBuilder { private String collectionName; private String databaseName; private Map properties = new HashMap<>(); - private Builder() {} + private AlterCollectionReqBuilder() { + } - public Builder collectionName(String collectionName) { + public AlterCollectionReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder databaseName(String databaseName) { + public AlterCollectionReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder property(String key, String value) { + public AlterCollectionReqBuilder property(String key, String value) { if (this.properties == null) { this.properties = new HashMap<>(); } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/BatchDescribeCollectionReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/BatchDescribeCollectionReq.java index 0257b6d88..613f354af 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/BatchDescribeCollectionReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/BatchDescribeCollectionReq.java @@ -19,9 +19,6 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.List; public class BatchDescribeCollectionReq { @@ -29,14 +26,14 @@ public class BatchDescribeCollectionReq { private List collectionNames; // Private constructor for builder - private BatchDescribeCollectionReq(Builder builder) { + private BatchDescribeCollectionReq(BatchDescribeCollectionReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionNames = builder.collectionNames; } // Static method to create builder - public static Builder builder() { - return new Builder(); + public static BatchDescribeCollectionReqBuilder builder() { + return new BatchDescribeCollectionReqBuilder(); } // Getter methods @@ -57,27 +54,6 @@ public void setCollectionNames(List collectionNames) { this.collectionNames = collectionNames; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - BatchDescribeCollectionReq that = (BatchDescribeCollectionReq) o; - - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionNames, that.collectionNames) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionNames) - .toHashCode(); - } - @Override public String toString() { return "BatchDescribeCollectionReq{" + @@ -87,16 +63,16 @@ public String toString() { } // Builder class - public static class Builder { + public static class BatchDescribeCollectionReqBuilder { private String databaseName; private List collectionNames; - public Builder databaseName(String databaseName) { + public BatchDescribeCollectionReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionNames(List collectionNames) { + public BatchDescribeCollectionReqBuilder collectionNames(List collectionNames) { this.collectionNames = collectionNames; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/CreateCollectionReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/CreateCollectionReq.java index fe6d5a778..b3bc09c46 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/CreateCollectionReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/CreateCollectionReq.java @@ -27,8 +27,6 @@ import io.milvus.v2.exception.ErrorCode; import io.milvus.v2.exception.MilvusClientException; import io.milvus.v2.utils.SchemaUtils; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.ArrayList; import java.util.HashMap; @@ -66,7 +64,7 @@ public class CreateCollectionReq { private final Map properties = new HashMap<>(); - private CreateCollectionReq(Builder builder) { + private CreateCollectionReq(CreateCollectionReqBuilder builder) { if (builder.collectionName == null) { throw new IllegalArgumentException("Collection name cannot be null"); } @@ -228,55 +226,6 @@ public Map getProperties() { return properties; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - CreateCollectionReq that = (CreateCollectionReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(description, that.description) - .append(dimension, that.dimension) - .append(primaryFieldName, that.primaryFieldName) - .append(idType, that.idType) - .append(maxLength, that.maxLength) - .append(vectorFieldName, that.vectorFieldName) - .append(metricType, that.metricType) - .append(autoID, that.autoID) - .append(enableDynamicField, that.enableDynamicField) - .append(numShards, that.numShards) - .append(collectionSchema, that.collectionSchema) - .append(indexParams, that.indexParams) - .append(numPartitions, that.numPartitions) - .append(consistencyLevel, that.consistencyLevel) - .append(properties, that.properties) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(description) - .append(dimension) - .append(primaryFieldName) - .append(idType) - .append(maxLength) - .append(vectorFieldName) - .append(metricType) - .append(autoID) - .append(enableDynamicField) - .append(numShards) - .append(collectionSchema) - .append(indexParams) - .append(numPartitions) - .append(consistencyLevel) - .append(properties) - .toHashCode(); - } - @Override public String toString() { return "CreateCollectionReq{" + @@ -300,11 +249,11 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static CreateCollectionReqBuilder builder() { + return new CreateCollectionReqBuilder(); } - public static class Builder { + public static class CreateCollectionReqBuilder { private String databaseName; private String collectionName; private String description = ""; @@ -324,14 +273,15 @@ public static class Builder { private Map properties = new HashMap<>(); private boolean enableDynamicFieldSet = false; - private Builder() {} + private CreateCollectionReqBuilder() { + } - public Builder databaseName(String databaseName) { + public CreateCollectionReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public CreateCollectionReqBuilder collectionName(String collectionName) { if (collectionName == null) { throw new IllegalArgumentException("Collection name cannot be null"); } @@ -339,67 +289,67 @@ public Builder collectionName(String collectionName) { return this; } - public Builder description(String description) { + public CreateCollectionReqBuilder description(String description) { this.description = description; return this; } - public Builder dimension(Integer dimension) { + public CreateCollectionReqBuilder dimension(Integer dimension) { this.dimension = dimension; return this; } - public Builder primaryFieldName(String primaryFieldName) { + public CreateCollectionReqBuilder primaryFieldName(String primaryFieldName) { this.primaryFieldName = primaryFieldName; return this; } - public Builder idType(DataType idType) { + public CreateCollectionReqBuilder idType(DataType idType) { this.idType = idType; return this; } - public Builder maxLength(Integer maxLength) { + public CreateCollectionReqBuilder maxLength(Integer maxLength) { this.maxLength = maxLength; return this; } - public Builder vectorFieldName(String vectorFieldName) { + public CreateCollectionReqBuilder vectorFieldName(String vectorFieldName) { this.vectorFieldName = vectorFieldName; return this; } - public Builder metricType(String metricType) { + public CreateCollectionReqBuilder metricType(String metricType) { this.metricType = metricType; return this; } - public Builder autoID(Boolean autoID) { + public CreateCollectionReqBuilder autoID(Boolean autoID) { this.autoID = autoID; return this; } - public Builder numShards(Integer numShards) { + public CreateCollectionReqBuilder numShards(Integer numShards) { this.numShards = numShards; return this; } - public Builder indexParams(List indexParams) { + public CreateCollectionReqBuilder indexParams(List indexParams) { this.indexParams = indexParams; return this; } - public Builder numPartitions(Integer numPartitions) { + public CreateCollectionReqBuilder numPartitions(Integer numPartitions) { this.numPartitions = numPartitions; return this; } - public Builder consistencyLevel(ConsistencyLevel consistencyLevel) { + public CreateCollectionReqBuilder consistencyLevel(ConsistencyLevel consistencyLevel) { this.consistencyLevel = consistencyLevel; return this; } - public Builder indexParam(IndexParam indexParam) { + public CreateCollectionReqBuilder indexParam(IndexParam indexParam) { if (this.indexParams == null) { this.indexParams = new ArrayList<>(); } @@ -412,7 +362,7 @@ public Builder indexParam(IndexParam indexParam) { return this; } - public Builder enableDynamicField(Boolean enableDynamicField) { + public CreateCollectionReqBuilder enableDynamicField(Boolean enableDynamicField) { if (this.collectionSchema != null && (this.collectionSchema.isEnableDynamicField() != enableDynamicField)) { throw new MilvusClientException(ErrorCode.INVALID_PARAMS, "The enableDynamicField flag has been set by CollectionSchema, not allow to set different value by enableDynamicField()."); @@ -422,7 +372,7 @@ public Builder enableDynamicField(Boolean enableDynamicField) { return this; } - public Builder collectionSchema(CollectionSchema collectionSchema) { + public CreateCollectionReqBuilder collectionSchema(CollectionSchema collectionSchema) { if (this.enableDynamicFieldSet && (collectionSchema.isEnableDynamicField() != this.enableDynamicField)) { throw new MilvusClientException(ErrorCode.INVALID_PARAMS, "The enableDynamicField flag has been set by enableDynamicField(), not allow to set different value by collectionSchema."); @@ -433,7 +383,7 @@ public Builder collectionSchema(CollectionSchema collectionSchema) { return this; } - public Builder property(String key, String value) { + public CreateCollectionReqBuilder property(String key, String value) { if (this.properties == null) { this.properties = new HashMap<>(); } @@ -453,7 +403,7 @@ public static class CollectionSchema { private boolean enableDynamicField = false; private List functionList = new ArrayList<>(); - private CollectionSchema(Builder builder) { + private CollectionSchema(CollectionSchemaBuilder builder) { this.fieldSchemaList = builder.fieldSchemaList; this.structFields = builder.structFields; this.enableDynamicField = builder.enableDynamicField; @@ -515,29 +465,6 @@ public void setFunctionList(List functionList) { this.functionList = functionList; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - CollectionSchema that = (CollectionSchema) obj; - return new EqualsBuilder() - .append(enableDynamicField, that.enableDynamicField) - .append(fieldSchemaList, that.fieldSchemaList) - .append(structFields, that.structFields) - .append(functionList, that.functionList) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(fieldSchemaList) - .append(structFields) - .append(enableDynamicField) - .append(functionList) - .toHashCode(); - } - @Override public String toString() { return "CollectionSchema{" + @@ -548,34 +475,35 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static CollectionSchemaBuilder builder() { + return new CollectionSchemaBuilder(); } - public static class Builder { + public static class CollectionSchemaBuilder { private List fieldSchemaList = new ArrayList<>(); private List structFields = new ArrayList<>(); private boolean enableDynamicField = false; private List functionList = new ArrayList<>(); - private Builder() {} + private CollectionSchemaBuilder() { + } - public Builder fieldSchemaList(List fieldSchemaList) { + public CollectionSchemaBuilder fieldSchemaList(List fieldSchemaList) { this.fieldSchemaList = fieldSchemaList; return this; } - public Builder structFields(List structFields) { + public CollectionSchemaBuilder structFields(List structFields) { this.structFields = structFields; return this; } - public Builder enableDynamicField(boolean enableDynamicField) { + public CollectionSchemaBuilder enableDynamicField(boolean enableDynamicField) { this.enableDynamicField = enableDynamicField; return this; } - public Builder functionList(List functionList) { + public CollectionSchemaBuilder functionList(List functionList) { this.functionList = functionList; return this; } @@ -608,7 +536,7 @@ public static class FieldSchema { private Map typeParams; private Map multiAnalyzerParams; // for multi‑language analyzers - private FieldSchema(Builder builder) { + private FieldSchema(FieldSchemaBuilder builder) { this.name = builder.name; this.description = builder.description; this.dataType = builder.dataType; @@ -774,57 +702,6 @@ public void setMultiAnalyzerParams(Map multiAnalyzerParams) { this.multiAnalyzerParams = multiAnalyzerParams; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - FieldSchema that = (FieldSchema) obj; - return new EqualsBuilder() - .append(name, that.name) - .append(description, that.description) - .append(dataType, that.dataType) - .append(maxLength, that.maxLength) - .append(dimension, that.dimension) - .append(isPrimaryKey, that.isPrimaryKey) - .append(isPartitionKey, that.isPartitionKey) - .append(isClusteringKey, that.isClusteringKey) - .append(autoID, that.autoID) - .append(elementType, that.elementType) - .append(maxCapacity, that.maxCapacity) - .append(isNullable, that.isNullable) - .append(defaultValue, that.defaultValue) - .append(enableAnalyzer, that.enableAnalyzer) - .append(analyzerParams, that.analyzerParams) - .append(enableMatch, that.enableMatch) - .append(typeParams, that.typeParams) - .append(multiAnalyzerParams, that.multiAnalyzerParams) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(name) - .append(description) - .append(dataType) - .append(maxLength) - .append(dimension) - .append(isPrimaryKey) - .append(isPartitionKey) - .append(isClusteringKey) - .append(autoID) - .append(elementType) - .append(maxCapacity) - .append(isNullable) - .append(defaultValue) - .append(enableAnalyzer) - .append(analyzerParams) - .append(enableMatch) - .append(typeParams) - .append(multiAnalyzerParams) - .toHashCode(); - } - @Override public String toString() { return "FieldSchema{" + @@ -849,11 +726,11 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static FieldSchemaBuilder builder() { + return new FieldSchemaBuilder(); } - public static class Builder { + public static class FieldSchemaBuilder { private String name; private String description = ""; private DataType dataType; @@ -873,94 +750,95 @@ public static class Builder { private Map typeParams; private Map multiAnalyzerParams; - private Builder() {} + private FieldSchemaBuilder() { + } - public Builder name(String name) { + public FieldSchemaBuilder name(String name) { this.name = name; return this; } - public Builder description(String description) { + public FieldSchemaBuilder description(String description) { this.description = description; return this; } - public Builder dataType(DataType dataType) { + public FieldSchemaBuilder dataType(DataType dataType) { this.dataType = dataType; return this; } - public Builder maxLength(Integer maxLength) { + public FieldSchemaBuilder maxLength(Integer maxLength) { this.maxLength = maxLength; return this; } - public Builder dimension(Integer dimension) { + public FieldSchemaBuilder dimension(Integer dimension) { this.dimension = dimension; return this; } - public Builder isPrimaryKey(Boolean isPrimaryKey) { + public FieldSchemaBuilder isPrimaryKey(Boolean isPrimaryKey) { this.isPrimaryKey = isPrimaryKey; return this; } - public Builder isPartitionKey(Boolean isPartitionKey) { + public FieldSchemaBuilder isPartitionKey(Boolean isPartitionKey) { this.isPartitionKey = isPartitionKey; return this; } - public Builder isClusteringKey(Boolean isClusteringKey) { + public FieldSchemaBuilder isClusteringKey(Boolean isClusteringKey) { this.isClusteringKey = isClusteringKey; return this; } - public Builder autoID(Boolean autoID) { + public FieldSchemaBuilder autoID(Boolean autoID) { this.autoID = autoID; return this; } - public Builder elementType(DataType elementType) { + public FieldSchemaBuilder elementType(DataType elementType) { this.elementType = elementType; return this; } - public Builder maxCapacity(Integer maxCapacity) { + public FieldSchemaBuilder maxCapacity(Integer maxCapacity) { this.maxCapacity = maxCapacity; return this; } - public Builder isNullable(Boolean isNullable) { + public FieldSchemaBuilder isNullable(Boolean isNullable) { this.isNullable = isNullable; return this; } - public Builder defaultValue(Object defaultValue) { + public FieldSchemaBuilder defaultValue(Object defaultValue) { this.defaultValue = defaultValue; return this; } - public Builder enableAnalyzer(Boolean enableAnalyzer) { + public FieldSchemaBuilder enableAnalyzer(Boolean enableAnalyzer) { this.enableAnalyzer = enableAnalyzer; return this; } - public Builder analyzerParams(Map analyzerParams) { + public FieldSchemaBuilder analyzerParams(Map analyzerParams) { this.analyzerParams = analyzerParams; return this; } - public Builder enableMatch(Boolean enableMatch) { + public FieldSchemaBuilder enableMatch(Boolean enableMatch) { this.enableMatch = enableMatch; return this; } - public Builder typeParams(Map typeParams) { + public FieldSchemaBuilder typeParams(Map typeParams) { this.typeParams = typeParams; return this; } - public Builder multiAnalyzerParams(Map multiAnalyzerParams) { + public FieldSchemaBuilder multiAnalyzerParams(Map multiAnalyzerParams) { this.multiAnalyzerParams = multiAnalyzerParams; return this; } @@ -979,7 +857,7 @@ public static class Function { private List outputFieldNames = new ArrayList<>(); private Map params = new HashMap<>(); - protected Function(FunctionBuilder builder) { + protected Function(FunctionBuilder builder) { this.name = builder.name; this.description = builder.description; this.functionType = builder.functionType; @@ -1036,33 +914,6 @@ public void setParams(Map params) { this.params = params; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - Function function = (Function) obj; - return new EqualsBuilder() - .append(name, function.name) - .append(description, function.description) - .append(functionType, function.functionType) - .append(inputFieldNames, function.inputFieldNames) - .append(outputFieldNames, function.outputFieldNames) - .append(params, function.params) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(name) - .append(description) - .append(functionType) - .append(inputFieldNames) - .append(outputFieldNames) - .append(params) - .toHashCode(); - } - @Override public String toString() { return "Function{" + @@ -1075,11 +926,11 @@ public String toString() { '}'; } - public static FunctionBuilder builder() { - return new FunctionBuilder(); + public static FunctionBuilder builder() { + return new FunctionBuilder<>(); } - public static class FunctionBuilder { + public static class FunctionBuilder> { private String name = ""; private String description = ""; private FunctionType functionType = FunctionType.UNKNOWN; @@ -1087,44 +938,45 @@ public static class FunctionBuilder { private List outputFieldNames = new ArrayList<>(); private Map params = new HashMap<>(); - protected FunctionBuilder() {} + protected FunctionBuilder() { + } - public FunctionBuilder name(String name) { + public T name(String name) { this.name = name; - return this; + return (T) this; } - public FunctionBuilder description(String description) { + public T description(String description) { this.description = description; - return this; + return (T) this; } - public FunctionBuilder functionType(FunctionType functionType) { + public T functionType(FunctionType functionType) { this.functionType = functionType; - return this; + return (T) this; } - public FunctionBuilder inputFieldNames(List inputFieldNames) { + public T inputFieldNames(List inputFieldNames) { this.inputFieldNames = inputFieldNames; - return this; + return (T) this; } - public FunctionBuilder outputFieldNames(List outputFieldNames) { + public T outputFieldNames(List outputFieldNames) { this.outputFieldNames = outputFieldNames; - return this; + return (T) this; } - public FunctionBuilder params(Map params) { + public T params(Map params) { this.params = params; - return this; + return (T) this; } - public FunctionBuilder param(String key, String value) { + public T param(String key, String value) { if (this.params == null) { this.params = new HashMap<>(); } this.params.put(key, value); - return this; + return (T) this; } public Function build() { @@ -1139,7 +991,7 @@ public static class StructFieldSchema { private List fields = new ArrayList<>(); private Integer maxCapacity; - private StructFieldSchema(Builder builder) { + private StructFieldSchema(StructFieldSchemaBuilder builder) { this.name = builder.name; this.description = builder.description; this.fields = builder.fields; @@ -1195,29 +1047,6 @@ public void setMaxCapacity(Integer maxCapacity) { this.maxCapacity = maxCapacity; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - StructFieldSchema that = (StructFieldSchema) obj; - return new EqualsBuilder() - .append(name, that.name) - .append(description, that.description) - .append(fields, that.fields) - .append(maxCapacity, that.maxCapacity) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(name) - .append(description) - .append(fields) - .append(maxCapacity) - .toHashCode(); - } - @Override public String toString() { return "StructFieldSchema{" + @@ -1228,34 +1057,35 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static StructFieldSchemaBuilder builder() { + return new StructFieldSchemaBuilder(); } - public static class Builder { + public static class StructFieldSchemaBuilder { private String name; private String description = ""; private List fields = new ArrayList<>(); private Integer maxCapacity; - private Builder() {} + private StructFieldSchemaBuilder() { + } - public Builder name(String name) { + public StructFieldSchemaBuilder name(String name) { this.name = name; return this; } - public Builder description(String description) { + public StructFieldSchemaBuilder description(String description) { this.description = description; return this; } - public Builder fields(List fields) { + public StructFieldSchemaBuilder fields(List fields) { this.fields = fields; return this; } - public Builder maxCapacity(Integer maxCapacity) { + public StructFieldSchemaBuilder maxCapacity(Integer maxCapacity) { this.maxCapacity = maxCapacity; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DescribeCollectionReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DescribeCollectionReq.java index cda1115a5..f008316a9 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DescribeCollectionReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DescribeCollectionReq.java @@ -19,14 +19,11 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class DescribeCollectionReq { private String databaseName; private String collectionName; - private DescribeCollectionReq(Builder builder) { + private DescribeCollectionReq(DescribeCollectionReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; } @@ -47,25 +44,6 @@ public void setCollectionName(String collectionName) { this.collectionName = collectionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DescribeCollectionReq that = (DescribeCollectionReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .toHashCode(); - } - @Override public String toString() { return "DescribeCollectionReq{" + @@ -74,22 +52,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DescribeCollectionReqBuilder builder() { + return new DescribeCollectionReqBuilder(); } - public static class Builder { + public static class DescribeCollectionReqBuilder { private String databaseName; private String collectionName; - private Builder() {} + private DescribeCollectionReqBuilder() { + } - public Builder databaseName(String databaseName) { + public DescribeCollectionReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public DescribeCollectionReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DescribeReplicasReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DescribeReplicasReq.java index 37167b969..2f5985ef0 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DescribeReplicasReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DescribeReplicasReq.java @@ -1,13 +1,10 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class DescribeReplicasReq { private String collectionName; private String databaseName; - private DescribeReplicasReq(Builder builder) { + private DescribeReplicasReq(DescribeReplicasReqBuilder builder) { this.collectionName = builder.collectionName; this.databaseName = builder.databaseName; } @@ -28,25 +25,6 @@ public void setDatabaseName(String databaseName) { this.databaseName = databaseName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DescribeReplicasReq that = (DescribeReplicasReq) obj; - return new EqualsBuilder() - .append(collectionName, that.collectionName) - .append(databaseName, that.databaseName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(collectionName) - .append(databaseName) - .toHashCode(); - } - @Override public String toString() { return "DescribeReplicasReq{" + @@ -55,22 +33,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DescribeReplicasReqBuilder builder() { + return new DescribeReplicasReqBuilder(); } - public static class Builder { + public static class DescribeReplicasReqBuilder { private String collectionName; private String databaseName; - private Builder() {} + private DescribeReplicasReqBuilder() { + } - public Builder collectionName(String collectionName) { + public DescribeReplicasReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder databaseName(String databaseName) { + public DescribeReplicasReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DropCollectionFieldPropertiesReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DropCollectionFieldPropertiesReq.java index ed889df0b..c46cfadef 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DropCollectionFieldPropertiesReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DropCollectionFieldPropertiesReq.java @@ -19,9 +19,6 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.ArrayList; import java.util.List; @@ -31,7 +28,7 @@ public class DropCollectionFieldPropertiesReq { private String fieldName; private List propertyKeys = new ArrayList<>(); - private DropCollectionFieldPropertiesReq(Builder builder) { + private DropCollectionFieldPropertiesReq(DropCollectionFieldPropertiesReqBuilder builder) { this.collectionName = builder.collectionName; this.databaseName = builder.databaseName; this.fieldName = builder.fieldName; @@ -70,29 +67,6 @@ public void setPropertyKeys(List propertyKeys) { this.propertyKeys = propertyKeys; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DropCollectionFieldPropertiesReq that = (DropCollectionFieldPropertiesReq) obj; - return new EqualsBuilder() - .append(collectionName, that.collectionName) - .append(databaseName, that.databaseName) - .append(fieldName, that.fieldName) - .append(propertyKeys, that.propertyKeys) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(collectionName) - .append(databaseName) - .append(fieldName) - .append(propertyKeys) - .toHashCode(); - } - @Override public String toString() { return "DropCollectionFieldPropertiesReq{" + @@ -103,34 +77,35 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DropCollectionFieldPropertiesReqBuilder builder() { + return new DropCollectionFieldPropertiesReqBuilder(); } - public static class Builder { + public static class DropCollectionFieldPropertiesReqBuilder { private String collectionName; private String databaseName; private String fieldName; private List propertyKeys = new ArrayList<>(); - private Builder() {} + private DropCollectionFieldPropertiesReqBuilder() { + } - public Builder collectionName(String collectionName) { + public DropCollectionFieldPropertiesReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder databaseName(String databaseName) { + public DropCollectionFieldPropertiesReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder fieldName(String fieldName) { + public DropCollectionFieldPropertiesReqBuilder fieldName(String fieldName) { this.fieldName = fieldName; return this; } - public Builder propertyKeys(List propertyKeys) { + public DropCollectionFieldPropertiesReqBuilder propertyKeys(List propertyKeys) { this.propertyKeys = propertyKeys; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DropCollectionPropertiesReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DropCollectionPropertiesReq.java index 933ddbbad..13c3b76f5 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DropCollectionPropertiesReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DropCollectionPropertiesReq.java @@ -19,9 +19,6 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.ArrayList; import java.util.List; @@ -30,7 +27,7 @@ public class DropCollectionPropertiesReq { private String databaseName; private List propertyKeys = new ArrayList<>(); - private DropCollectionPropertiesReq(Builder builder) { + private DropCollectionPropertiesReq(DropCollectionPropertiesReqBuilder builder) { this.collectionName = builder.collectionName; this.databaseName = builder.databaseName; this.propertyKeys = builder.propertyKeys; @@ -60,27 +57,6 @@ public void setPropertyKeys(List propertyKeys) { this.propertyKeys = propertyKeys; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DropCollectionPropertiesReq that = (DropCollectionPropertiesReq) obj; - return new EqualsBuilder() - .append(collectionName, that.collectionName) - .append(databaseName, that.databaseName) - .append(propertyKeys, that.propertyKeys) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(collectionName) - .append(databaseName) - .append(propertyKeys) - .toHashCode(); - } - @Override public String toString() { return "DropCollectionPropertiesReq{" + @@ -90,28 +66,29 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DropCollectionPropertiesReqBuilder builder() { + return new DropCollectionPropertiesReqBuilder(); } - public static class Builder { + public static class DropCollectionPropertiesReqBuilder { private String collectionName; private String databaseName; private List propertyKeys = new ArrayList<>(); - private Builder() {} + private DropCollectionPropertiesReqBuilder() { + } - public Builder collectionName(String collectionName) { + public DropCollectionPropertiesReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder databaseName(String databaseName) { + public DropCollectionPropertiesReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder propertyKeys(List propertyKeys) { + public DropCollectionPropertiesReqBuilder propertyKeys(List propertyKeys) { this.propertyKeys = propertyKeys; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DropCollectionReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DropCollectionReq.java index c7fea9d8f..0c982acec 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DropCollectionReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/DropCollectionReq.java @@ -19,10 +19,6 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - -import java.util.Objects; - public class DropCollectionReq { private String databaseName; private String collectionName; @@ -30,15 +26,15 @@ public class DropCollectionReq { private Boolean async; private Long timeout; - private DropCollectionReq(Builder builder) { + private DropCollectionReq(DropCollectionReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.async = builder.async != null ? builder.async : Boolean.TRUE; this.timeout = builder.timeout != null ? builder.timeout : 60000L; } - public static Builder builder() { - return new Builder(); + public static DropCollectionReqBuilder builder() { + return new DropCollectionReqBuilder(); } // Getters @@ -77,26 +73,6 @@ public void setTimeout(Long timeout) { this.timeout = timeout; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - DropCollectionReq that = (DropCollectionReq) obj; - - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(async, that.async) - .append(timeout, that.timeout) - .isEquals(); - } - - @Override - public int hashCode() { - return Objects.hash(databaseName, collectionName, async, timeout); - } - @Override public String toString() { return "DropCollectionReq{" + @@ -107,31 +83,32 @@ public String toString() { '}'; } - public static class Builder { + public static class DropCollectionReqBuilder { private String databaseName; private String collectionName; private Boolean async; private Long timeout; - private Builder() {} + private DropCollectionReqBuilder() { + } - public Builder databaseName(String databaseName) { + public DropCollectionReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public DropCollectionReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } @Deprecated - public Builder async(Boolean async) { + public DropCollectionReqBuilder async(Boolean async) { this.async = async; return this; } - public Builder timeout(Long timeout) { + public DropCollectionReqBuilder timeout(Long timeout) { this.timeout = timeout; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/GetCollectionStatsReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/GetCollectionStatsReq.java index c73b79547..8f9563e6d 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/GetCollectionStatsReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/GetCollectionStatsReq.java @@ -19,14 +19,11 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class GetCollectionStatsReq { private String databaseName; private String collectionName; - private GetCollectionStatsReq(Builder builder) { + private GetCollectionStatsReq(GetCollectionStatsReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; } @@ -47,25 +44,6 @@ public void setCollectionName(String collectionName) { this.collectionName = collectionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GetCollectionStatsReq that = (GetCollectionStatsReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .toHashCode(); - } - @Override public String toString() { return "GetCollectionStatsReq{" + @@ -74,22 +52,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static GetCollectionStatsReqBuilder builder() { + return new GetCollectionStatsReqBuilder(); } - public static class Builder { + public static class GetCollectionStatsReqBuilder { private String databaseName; private String collectionName; - private Builder() {} + private GetCollectionStatsReqBuilder() { + } - public Builder databaseName(String databaseName) { + public GetCollectionStatsReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public GetCollectionStatsReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/GetLoadStateReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/GetLoadStateReq.java index e171c8e11..8d70a2599 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/GetLoadStateReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/GetLoadStateReq.java @@ -19,15 +19,12 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class GetLoadStateReq { private String databaseName; private String collectionName; private String partitionName; - private GetLoadStateReq(Builder builder) { + private GetLoadStateReq(GetLoadStateReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionName = builder.partitionName; @@ -57,27 +54,6 @@ public void setPartitionName(String partitionName) { this.partitionName = partitionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GetLoadStateReq that = (GetLoadStateReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(partitionName, that.partitionName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(partitionName) - .toHashCode(); - } - @Override public String toString() { return "GetLoadStateReq{" + @@ -87,28 +63,29 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static GetLoadStateReqBuilder builder() { + return new GetLoadStateReqBuilder(); } - public static class Builder { + public static class GetLoadStateReqBuilder { private String databaseName; private String collectionName; private String partitionName; - private Builder() {} + private GetLoadStateReqBuilder() { + } - public Builder databaseName(String databaseName) { + public GetLoadStateReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public GetLoadStateReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionName(String partitionName) { + public GetLoadStateReqBuilder partitionName(String partitionName) { this.partitionName = partitionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/HasCollectionReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/HasCollectionReq.java index b6d223edd..62c59269d 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/HasCollectionReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/HasCollectionReq.java @@ -19,14 +19,11 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class HasCollectionReq { private String databaseName; private String collectionName; - private HasCollectionReq(Builder builder) { + private HasCollectionReq(HasCollectionReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; } @@ -47,25 +44,6 @@ public void setCollectionName(String collectionName) { this.collectionName = collectionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - HasCollectionReq that = (HasCollectionReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .toHashCode(); - } - @Override public String toString() { return "HasCollectionReq{" + @@ -74,22 +52,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static HasCollectionReqBuilder builder() { + return new HasCollectionReqBuilder(); } - public static class Builder { + public static class HasCollectionReqBuilder { private String databaseName; private String collectionName; - private Builder() {} + private HasCollectionReqBuilder() { + } - public Builder databaseName(String databaseName) { + public HasCollectionReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public HasCollectionReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/ListCollectionsReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/ListCollectionsReq.java index 9852bd402..25ed74a8a 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/ListCollectionsReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/ListCollectionsReq.java @@ -19,19 +19,15 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - -import java.util.Objects; - public class ListCollectionsReq { private String databaseName; - private ListCollectionsReq(Builder builder) { + private ListCollectionsReq(ListCollectionsReqBuilder builder) { this.databaseName = builder.databaseName; } - public static Builder builder() { - return new Builder(); + public static ListCollectionsReqBuilder builder() { + return new ListCollectionsReqBuilder(); } // Getters @@ -44,23 +40,6 @@ public void setDatabaseName(String databaseName) { this.databaseName = databaseName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - ListCollectionsReq that = (ListCollectionsReq) obj; - - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .isEquals(); - } - - @Override - public int hashCode() { - return Objects.hash(databaseName); - } - @Override public String toString() { return "ListCollectionsReq{" + @@ -68,12 +47,13 @@ public String toString() { '}'; } - public static class Builder { + public static class ListCollectionsReqBuilder { private String databaseName; - private Builder() {} + private ListCollectionsReqBuilder() { + } - public Builder databaseName(String databaseName) { + public ListCollectionsReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/LoadCollectionReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/LoadCollectionReq.java index 3f8837463..d18b4ea03 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/LoadCollectionReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/LoadCollectionReq.java @@ -19,9 +19,6 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.ArrayList; import java.util.List; @@ -38,7 +35,7 @@ public class LoadCollectionReq { private Boolean skipLoadDynamicField = Boolean.FALSE; private List resourceGroups = new ArrayList<>(); - private LoadCollectionReq(Builder builder) { + private LoadCollectionReq(LoadCollectionReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.numReplicas = builder.numReplicas; @@ -135,41 +132,6 @@ public void setResourceGroups(List resourceGroups) { this.resourceGroups = resourceGroups; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - LoadCollectionReq that = (LoadCollectionReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(numReplicas, that.numReplicas) - .append(async, that.async) - .append(sync, that.sync) - .append(timeout, that.timeout) - .append(refresh, that.refresh) - .append(loadFields, that.loadFields) - .append(skipLoadDynamicField, that.skipLoadDynamicField) - .append(resourceGroups, that.resourceGroups) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(numReplicas) - .append(async) - .append(sync) - .append(timeout) - .append(refresh) - .append(loadFields) - .append(skipLoadDynamicField) - .append(resourceGroups) - .toHashCode(); - } - @Override public String toString() { return "LoadCollectionReq{" + @@ -186,11 +148,11 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static LoadCollectionReqBuilder builder() { + return new LoadCollectionReqBuilder(); } - public static class Builder { + public static class LoadCollectionReqBuilder { private String databaseName; private String collectionName; private Integer numReplicas = 1; @@ -202,57 +164,58 @@ public static class Builder { private Boolean skipLoadDynamicField = Boolean.FALSE; private List resourceGroups = new ArrayList<>(); - private Builder() {} + private LoadCollectionReqBuilder() { + } - public Builder databaseName(String databaseName) { + public LoadCollectionReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public LoadCollectionReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder numReplicas(Integer numReplicas) { + public LoadCollectionReqBuilder numReplicas(Integer numReplicas) { this.numReplicas = numReplicas; return this; } @Deprecated - public Builder async(Boolean async) { + public LoadCollectionReqBuilder async(Boolean async) { this.async = async; this.sync = !async; return this; } - public Builder sync(Boolean sync) { + public LoadCollectionReqBuilder sync(Boolean sync) { this.sync = sync; this.async = !sync; return this; } - public Builder timeout(Long timeout) { + public LoadCollectionReqBuilder timeout(Long timeout) { this.timeout = timeout; return this; } - public Builder refresh(Boolean refresh) { + public LoadCollectionReqBuilder refresh(Boolean refresh) { this.refresh = refresh; return this; } - public Builder loadFields(List loadFields) { + public LoadCollectionReqBuilder loadFields(List loadFields) { this.loadFields = loadFields; return this; } - public Builder skipLoadDynamicField(Boolean skipLoadDynamicField) { + public LoadCollectionReqBuilder skipLoadDynamicField(Boolean skipLoadDynamicField) { this.skipLoadDynamicField = skipLoadDynamicField; return this; } - public Builder resourceGroups(List resourceGroups) { + public LoadCollectionReqBuilder resourceGroups(List resourceGroups) { this.resourceGroups = resourceGroups; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/RefreshLoadReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/RefreshLoadReq.java index 9842abb73..89549f07a 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/RefreshLoadReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/RefreshLoadReq.java @@ -19,9 +19,6 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class RefreshLoadReq { private String databaseName; private String collectionName; @@ -29,7 +26,7 @@ public class RefreshLoadReq { private Boolean sync = Boolean.TRUE; // wait the collection to be fully loaded. "async" is deprecated, use "sync" instead private Long timeout = 60000L; // timeout value for waiting the collection to be fully loaded - private RefreshLoadReq(Builder builder) { + private RefreshLoadReq(RefreshLoadReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.async = builder.async; @@ -79,31 +76,6 @@ public void setTimeout(Long timeout) { this.timeout = timeout; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - RefreshLoadReq that = (RefreshLoadReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(async, that.async) - .append(sync, that.sync) - .append(timeout, that.timeout) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(async) - .append(sync) - .append(timeout) - .toHashCode(); - } - @Override public String toString() { return "RefreshLoadReq{" + @@ -115,42 +87,43 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static RefreshLoadReqBuilder builder() { + return new RefreshLoadReqBuilder(); } - public static class Builder { + public static class RefreshLoadReqBuilder { private String databaseName; private String collectionName; private Boolean async = Boolean.TRUE; private Boolean sync = Boolean.TRUE; private Long timeout = 60000L; - private Builder() {} + private RefreshLoadReqBuilder() { + } - public Builder databaseName(String databaseName) { + public RefreshLoadReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public RefreshLoadReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder async(Boolean async) { + public RefreshLoadReqBuilder async(Boolean async) { this.async = async; this.sync = !async; return this; } - public Builder sync(Boolean sync) { + public RefreshLoadReqBuilder sync(Boolean sync) { this.sync = sync; this.async = !sync; return this; } - public Builder timeout(Long timeout) { + public RefreshLoadReqBuilder timeout(Long timeout) { this.timeout = timeout; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/ReleaseCollectionReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/ReleaseCollectionReq.java index e1cc81bac..11695bd12 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/ReleaseCollectionReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/ReleaseCollectionReq.java @@ -19,9 +19,6 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class ReleaseCollectionReq { private String databaseName; private String collectionName; @@ -29,7 +26,7 @@ public class ReleaseCollectionReq { private Boolean async = Boolean.TRUE; private Long timeout = 60000L; - private ReleaseCollectionReq(Builder builder) { + private ReleaseCollectionReq(ReleaseCollectionReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.async = builder.async; @@ -70,29 +67,6 @@ public void setTimeout(Long timeout) { this.timeout = timeout; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ReleaseCollectionReq that = (ReleaseCollectionReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(async, that.async) - .append(timeout, that.timeout) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(async) - .append(timeout) - .toHashCode(); - } - @Override public String toString() { return "ReleaseCollectionReq{" + @@ -103,35 +77,36 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static ReleaseCollectionReqBuilder builder() { + return new ReleaseCollectionReqBuilder(); } - public static class Builder { + public static class ReleaseCollectionReqBuilder { private String databaseName; private String collectionName; private Boolean async = Boolean.TRUE; private Long timeout = 60000L; - private Builder() {} + private ReleaseCollectionReqBuilder() { + } - public Builder databaseName(String databaseName) { + public ReleaseCollectionReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public ReleaseCollectionReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } @Deprecated - public Builder async(Boolean async) { + public ReleaseCollectionReqBuilder async(Boolean async) { this.async = async; return this; } - public Builder timeout(Long timeout) { + public ReleaseCollectionReqBuilder timeout(Long timeout) { this.timeout = timeout; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/RenameCollectionReq.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/RenameCollectionReq.java index c79fe9c37..aea80ecfe 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/request/RenameCollectionReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/request/RenameCollectionReq.java @@ -19,15 +19,12 @@ package io.milvus.v2.service.collection.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class RenameCollectionReq { private String databaseName; private String collectionName; private String newCollectionName; - private RenameCollectionReq(Builder builder) { + private RenameCollectionReq(RenameCollectionReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.newCollectionName = builder.newCollectionName; @@ -57,27 +54,6 @@ public void setNewCollectionName(String newCollectionName) { this.newCollectionName = newCollectionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - RenameCollectionReq that = (RenameCollectionReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(newCollectionName, that.newCollectionName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(newCollectionName) - .toHashCode(); - } - @Override public String toString() { return "RenameCollectionReq{" + @@ -87,28 +63,29 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static RenameCollectionReqBuilder builder() { + return new RenameCollectionReqBuilder(); } - public static class Builder { + public static class RenameCollectionReqBuilder { private String databaseName; private String collectionName; private String newCollectionName; - private Builder() {} + private RenameCollectionReqBuilder() { + } - public Builder databaseName(String databaseName) { + public RenameCollectionReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public RenameCollectionReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder newCollectionName(String newCollectionName) { + public RenameCollectionReqBuilder newCollectionName(String newCollectionName) { this.newCollectionName = newCollectionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/response/DescribeCollectionResp.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/response/DescribeCollectionResp.java index 9fee3b939..beede2c0b 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/response/DescribeCollectionResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/response/DescribeCollectionResp.java @@ -21,13 +21,11 @@ import io.milvus.v2.common.ConsistencyLevel; import io.milvus.v2.service.collection.request.CreateCollectionReq; -import org.apache.commons.lang3.builder.EqualsBuilder; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; public class DescribeCollectionResp { private String collectionName; @@ -47,7 +45,7 @@ public class DescribeCollectionResp { private Integer shardsNum; private final Map properties; - private DescribeCollectionResp(Builder builder) { + private DescribeCollectionResp(DescribeCollectionRespBuilder builder) { this.collectionName = builder.collectionName; this.collectionID = builder.collectionID; this.databaseName = builder.databaseName; @@ -66,8 +64,8 @@ private DescribeCollectionResp(Builder builder) { this.properties = builder.properties != null ? builder.properties : new HashMap<>(); } - public static Builder builder() { - return new Builder(); + public static DescribeCollectionRespBuilder builder() { + return new DescribeCollectionRespBuilder(); } // Getters @@ -196,41 +194,6 @@ public void setShardsNum(Integer shardsNum) { this.shardsNum = shardsNum; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - DescribeCollectionResp that = (DescribeCollectionResp) obj; - - return new EqualsBuilder() - .append(collectionName, that.collectionName) - .append(collectionID, that.collectionID) - .append(databaseName, that.databaseName) - .append(description, that.description) - .append(numOfPartitions, that.numOfPartitions) - .append(fieldNames, that.fieldNames) - .append(vectorFieldNames, that.vectorFieldNames) - .append(primaryFieldName, that.primaryFieldName) - .append(enableDynamicField, that.enableDynamicField) - .append(autoID, that.autoID) - .append(collectionSchema, that.collectionSchema) - .append(createTime, that.createTime) - .append(createUtcTime, that.createUtcTime) - .append(consistencyLevel, that.consistencyLevel) - .append(shardsNum, that.shardsNum) - .append(properties, that.properties) - .isEquals(); - } - - @Override - public int hashCode() { - return Objects.hash(collectionName, collectionID, databaseName, description, - numOfPartitions, fieldNames, vectorFieldNames, primaryFieldName, - enableDynamicField, autoID, collectionSchema, createTime, createUtcTime, - consistencyLevel, shardsNum, properties); - } - @Override public String toString() { return "DescribeCollectionResp{" + @@ -253,7 +216,7 @@ public String toString() { '}'; } - public static class Builder { + public static class DescribeCollectionRespBuilder { private String collectionName; private Long collectionID; private String databaseName; @@ -271,82 +234,82 @@ public static class Builder { private Integer shardsNum; private Map properties; - public Builder collectionName(String collectionName) { + public DescribeCollectionRespBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder collectionID(Long collectionID) { + public DescribeCollectionRespBuilder collectionID(Long collectionID) { this.collectionID = collectionID; return this; } - public Builder databaseName(String databaseName) { + public DescribeCollectionRespBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder description(String description) { + public DescribeCollectionRespBuilder description(String description) { this.description = description; return this; } - public Builder numOfPartitions(Long numOfPartitions) { + public DescribeCollectionRespBuilder numOfPartitions(Long numOfPartitions) { this.numOfPartitions = numOfPartitions; return this; } - public Builder fieldNames(List fieldNames) { + public DescribeCollectionRespBuilder fieldNames(List fieldNames) { this.fieldNames = fieldNames; return this; } - public Builder vectorFieldNames(List vectorFieldNames) { + public DescribeCollectionRespBuilder vectorFieldNames(List vectorFieldNames) { this.vectorFieldNames = vectorFieldNames; return this; } - public Builder primaryFieldName(String primaryFieldName) { + public DescribeCollectionRespBuilder primaryFieldName(String primaryFieldName) { this.primaryFieldName = primaryFieldName; return this; } - public Builder enableDynamicField(Boolean enableDynamicField) { + public DescribeCollectionRespBuilder enableDynamicField(Boolean enableDynamicField) { this.enableDynamicField = enableDynamicField; return this; } - public Builder autoID(Boolean autoID) { + public DescribeCollectionRespBuilder autoID(Boolean autoID) { this.autoID = autoID; return this; } - public Builder collectionSchema(CreateCollectionReq.CollectionSchema collectionSchema) { + public DescribeCollectionRespBuilder collectionSchema(CreateCollectionReq.CollectionSchema collectionSchema) { this.collectionSchema = collectionSchema; return this; } - public Builder createTime(Long createTime) { + public DescribeCollectionRespBuilder createTime(Long createTime) { this.createTime = createTime; return this; } - public Builder createUtcTime(Long createUtcTime) { + public DescribeCollectionRespBuilder createUtcTime(Long createUtcTime) { this.createUtcTime = createUtcTime; return this; } - public Builder consistencyLevel(ConsistencyLevel consistencyLevel) { + public DescribeCollectionRespBuilder consistencyLevel(ConsistencyLevel consistencyLevel) { this.consistencyLevel = consistencyLevel; return this; } - public Builder shardsNum(Integer shardsNum) { + public DescribeCollectionRespBuilder shardsNum(Integer shardsNum) { this.shardsNum = shardsNum; return this; } - public Builder properties(Map properties) { + public DescribeCollectionRespBuilder properties(Map properties) { this.properties = properties; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/response/DescribeReplicasResp.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/response/DescribeReplicasResp.java index 31954d624..eb5d8d011 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/response/DescribeReplicasResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/response/DescribeReplicasResp.java @@ -1,21 +1,19 @@ package io.milvus.v2.service.collection.response; import io.milvus.v2.service.collection.ReplicaInfo; -import org.apache.commons.lang3.builder.EqualsBuilder; import java.util.ArrayList; import java.util.List; -import java.util.Objects; public class DescribeReplicasResp { private List replicas; - private DescribeReplicasResp(Builder builder) { + private DescribeReplicasResp(DescribeReplicasRespBuilder builder) { this.replicas = builder.replicas != null ? builder.replicas : new ArrayList<>(); } - public static Builder builder() { - return new Builder(); + public static DescribeReplicasRespBuilder builder() { + return new DescribeReplicasRespBuilder(); } // Getter @@ -28,23 +26,6 @@ public void setReplicas(List replicas) { this.replicas = replicas; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - DescribeReplicasResp that = (DescribeReplicasResp) obj; - - return new EqualsBuilder() - .append(replicas, that.replicas) - .isEquals(); - } - - @Override - public int hashCode() { - return Objects.hash(replicas); - } - @Override public String toString() { return "DescribeReplicasResp{" + @@ -52,10 +33,10 @@ public String toString() { '}'; } - public static class Builder { + public static class DescribeReplicasRespBuilder { private List replicas; - public Builder replicas(List replicas) { + public DescribeReplicasRespBuilder replicas(List replicas) { this.replicas = replicas; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/response/GetCollectionStatsResp.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/response/GetCollectionStatsResp.java index 5be89630d..ed25c16c8 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/response/GetCollectionStatsResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/response/GetCollectionStatsResp.java @@ -19,19 +19,15 @@ package io.milvus.v2.service.collection.response; -import org.apache.commons.lang3.builder.EqualsBuilder; - -import java.util.Objects; - public class GetCollectionStatsResp { private Long numOfEntities; - private GetCollectionStatsResp(Builder builder) { + private GetCollectionStatsResp(GetCollectionStatsRespBuilder builder) { this.numOfEntities = builder.numOfEntities; } - public static Builder builder() { - return new Builder(); + public static GetCollectionStatsRespBuilder builder() { + return new GetCollectionStatsRespBuilder(); } // Getter @@ -44,23 +40,6 @@ public void setNumOfEntities(Long numOfEntities) { this.numOfEntities = numOfEntities; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - GetCollectionStatsResp that = (GetCollectionStatsResp) obj; - - return new EqualsBuilder() - .append(numOfEntities, that.numOfEntities) - .isEquals(); - } - - @Override - public int hashCode() { - return Objects.hash(numOfEntities); - } - @Override public String toString() { return "GetCollectionStatsResp{" + @@ -68,10 +47,10 @@ public String toString() { '}'; } - public static class Builder { + public static class GetCollectionStatsRespBuilder { private Long numOfEntities; - public Builder numOfEntities(Long numOfEntities) { + public GetCollectionStatsRespBuilder numOfEntities(Long numOfEntities) { this.numOfEntities = numOfEntities; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/response/ListCollectionsResp.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/response/ListCollectionsResp.java index 6164299f9..e4aaec310 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/response/ListCollectionsResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/response/ListCollectionsResp.java @@ -19,25 +19,22 @@ package io.milvus.v2.service.collection.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; +import io.milvus.v2.service.collection.CollectionInfo; import java.util.ArrayList; import java.util.List; -import io.milvus.v2.service.collection.CollectionInfo; - public class ListCollectionsResp { private List collectionNames; private List collectionInfos; - private ListCollectionsResp(Builder builder) { + private ListCollectionsResp(ListCollectionsRespBuilder builder) { this.collectionNames = builder.collectionNames != null ? builder.collectionNames : new ArrayList<>(); this.collectionInfos = builder.collectionInfos != null ? builder.collectionInfos : new ArrayList<>(); } - public static Builder builder() { - return new Builder(); + public static ListCollectionsRespBuilder builder() { + return new ListCollectionsRespBuilder(); } // Getters @@ -58,27 +55,6 @@ public void setCollectionInfos(List collectionInfos) { this.collectionInfos = collectionInfos; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - ListCollectionsResp that = (ListCollectionsResp) obj; - - return new EqualsBuilder() - .append(collectionNames, that.collectionNames) - .append(collectionInfos, that.collectionInfos) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(collectionNames) - .append(collectionInfos) - .toHashCode(); - } - @Override public String toString() { return "ListCollectionsResp{" + @@ -87,16 +63,16 @@ public String toString() { '}'; } - public static class Builder { + public static class ListCollectionsRespBuilder { private List collectionNames; private List collectionInfos; - public Builder collectionNames(List collectionNames) { + public ListCollectionsRespBuilder collectionNames(List collectionNames) { this.collectionNames = collectionNames; return this; } - public Builder collectionInfos(List collectionInfos) { + public ListCollectionsRespBuilder collectionInfos(List collectionInfos) { this.collectionInfos = collectionInfos; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/database/DatabaseService.java b/sdk-core/src/main/java/io/milvus/v2/service/database/DatabaseService.java index 8d0b66830..7ee7f827d 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/database/DatabaseService.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/database/DatabaseService.java @@ -23,7 +23,8 @@ import io.milvus.param.ParamUtils; import io.milvus.v2.service.BaseService; import io.milvus.v2.service.database.request.*; -import io.milvus.v2.service.database.response.*; +import io.milvus.v2.service.database.response.DescribeDatabaseResp; +import io.milvus.v2.service.database.response.ListDatabasesResp; import org.apache.commons.collections4.CollectionUtils; import java.util.HashMap; diff --git a/sdk-core/src/main/java/io/milvus/v2/service/database/request/AlterDatabasePropertiesReq.java b/sdk-core/src/main/java/io/milvus/v2/service/database/request/AlterDatabasePropertiesReq.java index 32e225137..20fe483ab 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/database/request/AlterDatabasePropertiesReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/database/request/AlterDatabasePropertiesReq.java @@ -19,8 +19,6 @@ package io.milvus.v2.service.database.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.HashMap; import java.util.Map; @@ -28,7 +26,7 @@ public class AlterDatabasePropertiesReq { private String databaseName; private Map properties; - private AlterDatabasePropertiesReq(Builder builder) { + private AlterDatabasePropertiesReq(AlterDatabasePropertiesReqBuilder builder) { this.databaseName = builder.databaseName; this.properties = builder.properties; } @@ -49,24 +47,6 @@ public void setProperties(Map properties) { this.properties = properties; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AlterDatabasePropertiesReq that = (AlterDatabasePropertiesReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(properties, that.properties) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (properties != null ? properties.hashCode() : 0); - return result; - } - @Override public String toString() { return "AlterDatabasePropertiesReq{" + @@ -75,27 +55,28 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static AlterDatabasePropertiesReqBuilder builder() { + return new AlterDatabasePropertiesReqBuilder(); } - public static class Builder { + public static class AlterDatabasePropertiesReqBuilder { private String databaseName; private Map properties = new HashMap<>(); - private Builder() {} + private AlterDatabasePropertiesReqBuilder() { + } - public Builder databaseName(String databaseName) { + public AlterDatabasePropertiesReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder properties(Map properties) { + public AlterDatabasePropertiesReqBuilder properties(Map properties) { this.properties = properties; return this; } - public Builder property(String key, String value) { + public AlterDatabasePropertiesReqBuilder property(String key, String value) { if (this.properties == null) { this.properties = new HashMap<>(); } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/database/request/AlterDatabaseReq.java b/sdk-core/src/main/java/io/milvus/v2/service/database/request/AlterDatabaseReq.java index f080b4485..71b2991e4 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/database/request/AlterDatabaseReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/database/request/AlterDatabaseReq.java @@ -19,8 +19,6 @@ package io.milvus.v2.service.database.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.HashMap; import java.util.Map; @@ -29,7 +27,7 @@ public class AlterDatabaseReq { private String databaseName; private Map properties = new HashMap<>(); - private AlterDatabaseReq(Builder builder) { + private AlterDatabaseReq(AlterDatabaseReqBuilder builder) { this.databaseName = builder.databaseName; this.properties = builder.properties; } @@ -50,24 +48,6 @@ public void setProperties(Map properties) { this.properties = properties; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AlterDatabaseReq that = (AlterDatabaseReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(properties, that.properties) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (properties != null ? properties.hashCode() : 0); - return result; - } - @Override public String toString() { return "AlterDatabaseReq{" + @@ -76,22 +56,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static AlterDatabaseReqBuilder builder() { + return new AlterDatabaseReqBuilder(); } - public static class Builder { + public static class AlterDatabaseReqBuilder { private String databaseName; private Map properties = new HashMap<>(); - private Builder() {} + private AlterDatabaseReqBuilder() { + } - public Builder databaseName(String databaseName) { + public AlterDatabaseReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder properties(Map properties) { + public AlterDatabaseReqBuilder properties(Map properties) { this.properties = properties; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/database/request/CreateDatabaseReq.java b/sdk-core/src/main/java/io/milvus/v2/service/database/request/CreateDatabaseReq.java index ae432ded2..9eef6f22e 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/database/request/CreateDatabaseReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/database/request/CreateDatabaseReq.java @@ -19,8 +19,6 @@ package io.milvus.v2.service.database.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.HashMap; import java.util.Map; @@ -28,7 +26,7 @@ public class CreateDatabaseReq { private String databaseName; private Map properties; - private CreateDatabaseReq(Builder builder) { + private CreateDatabaseReq(CreateDatabaseReqBuilder builder) { this.databaseName = builder.databaseName; this.properties = builder.properties; } @@ -49,24 +47,6 @@ public void setProperties(Map properties) { this.properties = properties; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - CreateDatabaseReq that = (CreateDatabaseReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(properties, that.properties) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (properties != null ? properties.hashCode() : 0); - return result; - } - @Override public String toString() { return "CreateDatabaseReq{" + @@ -75,22 +55,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static CreateDatabaseReqBuilder builder() { + return new CreateDatabaseReqBuilder(); } - public static class Builder { + public static class CreateDatabaseReqBuilder { private String databaseName; private Map properties = new HashMap<>(); - private Builder() {} + private CreateDatabaseReqBuilder() { + } - public Builder databaseName(String databaseName) { + public CreateDatabaseReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder properties(Map properties) { + public CreateDatabaseReqBuilder properties(Map properties) { this.properties = properties; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/database/request/DescribeDatabaseReq.java b/sdk-core/src/main/java/io/milvus/v2/service/database/request/DescribeDatabaseReq.java index 1e8ace3ad..18bd0d565 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/database/request/DescribeDatabaseReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/database/request/DescribeDatabaseReq.java @@ -19,12 +19,10 @@ package io.milvus.v2.service.database.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class DescribeDatabaseReq { private String databaseName; - private DescribeDatabaseReq(Builder builder) { + private DescribeDatabaseReq(DescribeDatabaseReqBuilder builder) { this.databaseName = builder.databaseName; } @@ -36,21 +34,6 @@ public void setDatabaseName(String databaseName) { this.databaseName = databaseName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DescribeDatabaseReq that = (DescribeDatabaseReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .isEquals(); - } - - @Override - public int hashCode() { - return databaseName != null ? databaseName.hashCode() : 0; - } - @Override public String toString() { return "DescribeDatabaseReq{" + @@ -58,16 +41,17 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DescribeDatabaseReqBuilder builder() { + return new DescribeDatabaseReqBuilder(); } - public static class Builder { + public static class DescribeDatabaseReqBuilder { private String databaseName; - private Builder() {} + private DescribeDatabaseReqBuilder() { + } - public Builder databaseName(String databaseName) { + public DescribeDatabaseReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/database/request/DropDatabasePropertiesReq.java b/sdk-core/src/main/java/io/milvus/v2/service/database/request/DropDatabasePropertiesReq.java index 7da6d9812..ddbefd00f 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/database/request/DropDatabasePropertiesReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/database/request/DropDatabasePropertiesReq.java @@ -19,8 +19,6 @@ package io.milvus.v2.service.database.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.ArrayList; import java.util.List; @@ -28,7 +26,7 @@ public class DropDatabasePropertiesReq { private String databaseName; private List propertyKeys; - private DropDatabasePropertiesReq(Builder builder) { + private DropDatabasePropertiesReq(DropDatabasePropertiesReqBuilder builder) { this.databaseName = builder.databaseName; this.propertyKeys = builder.propertyKeys; } @@ -49,24 +47,6 @@ public void setPropertyKeys(List propertyKeys) { this.propertyKeys = propertyKeys; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DropDatabasePropertiesReq that = (DropDatabasePropertiesReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(propertyKeys, that.propertyKeys) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (propertyKeys != null ? propertyKeys.hashCode() : 0); - return result; - } - @Override public String toString() { return "DropDatabasePropertiesReq{" + @@ -75,22 +55,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DropDatabasePropertiesReqBuilder builder() { + return new DropDatabasePropertiesReqBuilder(); } - public static class Builder { + public static class DropDatabasePropertiesReqBuilder { private String databaseName; private List propertyKeys = new ArrayList<>(); - private Builder() {} + private DropDatabasePropertiesReqBuilder() { + } - public Builder databaseName(String databaseName) { + public DropDatabasePropertiesReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder propertyKeys(List propertyKeys) { + public DropDatabasePropertiesReqBuilder propertyKeys(List propertyKeys) { this.propertyKeys = propertyKeys; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/database/request/DropDatabaseReq.java b/sdk-core/src/main/java/io/milvus/v2/service/database/request/DropDatabaseReq.java index 021d64c49..deded9736 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/database/request/DropDatabaseReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/database/request/DropDatabaseReq.java @@ -19,12 +19,10 @@ package io.milvus.v2.service.database.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class DropDatabaseReq { private String databaseName; - private DropDatabaseReq(Builder builder) { + private DropDatabaseReq(DropDatabaseReqBuilder builder) { this.databaseName = builder.databaseName; } @@ -36,21 +34,6 @@ public void setDatabaseName(String databaseName) { this.databaseName = databaseName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DropDatabaseReq that = (DropDatabaseReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .isEquals(); - } - - @Override - public int hashCode() { - return databaseName != null ? databaseName.hashCode() : 0; - } - @Override public String toString() { return "DropDatabaseReq{" + @@ -58,16 +41,17 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DropDatabaseReqBuilder builder() { + return new DropDatabaseReqBuilder(); } - public static class Builder { + public static class DropDatabaseReqBuilder { private String databaseName; - private Builder() {} + private DropDatabaseReqBuilder() { + } - public Builder databaseName(String databaseName) { + public DropDatabaseReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/database/response/DescribeDatabaseResp.java b/sdk-core/src/main/java/io/milvus/v2/service/database/response/DescribeDatabaseResp.java index 80318c905..7ad85ecd8 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/database/response/DescribeDatabaseResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/database/response/DescribeDatabaseResp.java @@ -19,8 +19,6 @@ package io.milvus.v2.service.database.response; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.HashMap; import java.util.Map; @@ -28,7 +26,7 @@ public class DescribeDatabaseResp { private String databaseName; private Map properties; - private DescribeDatabaseResp(Builder builder) { + private DescribeDatabaseResp(DescribeDatabaseRespBuilder builder) { this.databaseName = builder.databaseName; this.properties = builder.properties; } @@ -49,24 +47,6 @@ public void setProperties(Map properties) { this.properties = properties; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DescribeDatabaseResp that = (DescribeDatabaseResp) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(properties, that.properties) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (properties != null ? properties.hashCode() : 0); - return result; - } - @Override public String toString() { return "DescribeDatabaseResp{" + @@ -75,22 +55,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DescribeDatabaseRespBuilder builder() { + return new DescribeDatabaseRespBuilder(); } - public static class Builder { + public static class DescribeDatabaseRespBuilder { private String databaseName; private Map properties = new HashMap<>(); - private Builder() {} + private DescribeDatabaseRespBuilder() { + } - public Builder databaseName(String databaseName) { + public DescribeDatabaseRespBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder properties(Map properties) { + public DescribeDatabaseRespBuilder properties(Map properties) { this.properties = properties; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/database/response/ListDatabasesResp.java b/sdk-core/src/main/java/io/milvus/v2/service/database/response/ListDatabasesResp.java index a172a80d6..0786b304b 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/database/response/ListDatabasesResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/database/response/ListDatabasesResp.java @@ -19,15 +19,13 @@ package io.milvus.v2.service.database.response; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.ArrayList; import java.util.List; public class ListDatabasesResp { private List databaseNames; - private ListDatabasesResp(Builder builder) { + private ListDatabasesResp(ListDatabasesRespBuilder builder) { this.databaseNames = builder.databaseNames; } @@ -39,21 +37,6 @@ public void setDatabaseNames(List databaseNames) { this.databaseNames = databaseNames; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ListDatabasesResp that = (ListDatabasesResp) obj; - return new EqualsBuilder() - .append(databaseNames, that.databaseNames) - .isEquals(); - } - - @Override - public int hashCode() { - return databaseNames != null ? databaseNames.hashCode() : 0; - } - @Override public String toString() { return "ListDatabasesResp{" + @@ -61,16 +44,17 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static ListDatabasesRespBuilder builder() { + return new ListDatabasesRespBuilder(); } - public static class Builder { + public static class ListDatabasesRespBuilder { private List databaseNames = new ArrayList<>(); - private Builder() {} + private ListDatabasesRespBuilder() { + } - public Builder databaseNames(List databaseNames) { + public ListDatabasesRespBuilder databaseNames(List databaseNames) { this.databaseNames = databaseNames; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/index/IndexService.java b/sdk-core/src/main/java/io/milvus/v2/service/index/IndexService.java index d0c1bffe7..bc34b0f54 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/index/IndexService.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/index/IndexService.java @@ -19,17 +19,7 @@ package io.milvus.v2.service.index; -import io.milvus.grpc.AllocTimestampRequest; -import io.milvus.grpc.AllocTimestampResponse; -import io.milvus.grpc.AlterIndexRequest; -import io.milvus.grpc.CreateIndexRequest; -import io.milvus.grpc.DescribeIndexRequest; -import io.milvus.grpc.DescribeIndexResponse; -import io.milvus.grpc.DropIndexRequest; -import io.milvus.grpc.IndexDescription; -import io.milvus.grpc.KeyValuePair; -import io.milvus.grpc.MilvusServiceGrpc; -import io.milvus.grpc.Status; +import io.milvus.grpc.*; import io.milvus.param.Constant; import io.milvus.param.ParamUtils; import io.milvus.v2.common.IndexBuildState; @@ -37,12 +27,7 @@ import io.milvus.v2.exception.ErrorCode; import io.milvus.v2.exception.MilvusClientException; import io.milvus.v2.service.BaseService; -import io.milvus.v2.service.index.request.AlterIndexPropertiesReq; -import io.milvus.v2.service.index.request.CreateIndexReq; -import io.milvus.v2.service.index.request.DescribeIndexReq; -import io.milvus.v2.service.index.request.DropIndexPropertiesReq; -import io.milvus.v2.service.index.request.DropIndexReq; -import io.milvus.v2.service.index.request.ListIndexesReq; +import io.milvus.v2.service.index.request.*; import io.milvus.v2.service.index.response.DescribeIndexResp; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -57,7 +42,7 @@ public class IndexService extends BaseService { public Void createIndex(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, CreateIndexReq request) { String dbName = request.getDatabaseName(); String collectionName = request.getCollectionName(); - for(IndexParam indexParam : request.getIndexParams()) { + for (IndexParam indexParam : request.getIndexParams()) { String fieldName = indexParam.getFieldName(); String indexName = indexParam.getIndexName(); String title = String.format("Create index for field: '%s' in collection: '%s' in database: '%s'", @@ -76,7 +61,7 @@ public Void createIndex(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub builder.setDbName(dbName); } - if(indexParam.getMetricType()!= null){ + if (indexParam.getMetricType() != null) { // only vector field has a metric type builder.addExtraParams(KeyValuePair.newBuilder() .setKey(Constant.METRIC_TYPE) @@ -123,7 +108,7 @@ public Void dropIndex(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, return null; } - + public Void alterIndexProperties(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, AlterIndexPropertiesReq request) { String dbName = request.getDatabaseName(); String collectionName = request.getCollectionName(); diff --git a/sdk-core/src/main/java/io/milvus/v2/service/index/request/AlterIndexPropertiesReq.java b/sdk-core/src/main/java/io/milvus/v2/service/index/request/AlterIndexPropertiesReq.java index 687900851..c719ce697 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/index/request/AlterIndexPropertiesReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/index/request/AlterIndexPropertiesReq.java @@ -19,8 +19,6 @@ package io.milvus.v2.service.index.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.HashMap; import java.util.Map; @@ -30,7 +28,7 @@ public class AlterIndexPropertiesReq { private String indexName; private Map properties; - private AlterIndexPropertiesReq(Builder builder) { + private AlterIndexPropertiesReq(AlterIndexPropertiesReqBuilder builder) { this.collectionName = builder.collectionName; this.databaseName = builder.databaseName; this.indexName = builder.indexName; @@ -69,28 +67,6 @@ public void setProperties(Map properties) { this.properties = properties; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AlterIndexPropertiesReq that = (AlterIndexPropertiesReq) obj; - return new EqualsBuilder() - .append(collectionName, that.collectionName) - .append(databaseName, that.databaseName) - .append(indexName, that.indexName) - .append(properties, that.properties) - .isEquals(); - } - - @Override - public int hashCode() { - int result = collectionName != null ? collectionName.hashCode() : 0; - result = 31 * result + (databaseName != null ? databaseName.hashCode() : 0); - result = 31 * result + (indexName != null ? indexName.hashCode() : 0); - result = 31 * result + (properties != null ? properties.hashCode() : 0); - return result; - } - @Override public String toString() { return "AlterIndexPropertiesReq{" + @@ -101,39 +77,40 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static AlterIndexPropertiesReqBuilder builder() { + return new AlterIndexPropertiesReqBuilder(); } - public static class Builder { + public static class AlterIndexPropertiesReqBuilder { private String collectionName; private String databaseName; private String indexName; private Map properties = new HashMap<>(); - private Builder() {} + private AlterIndexPropertiesReqBuilder() { + } - public Builder collectionName(String collectionName) { + public AlterIndexPropertiesReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder databaseName(String databaseName) { + public AlterIndexPropertiesReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder indexName(String indexName) { + public AlterIndexPropertiesReqBuilder indexName(String indexName) { this.indexName = indexName; return this; } - public Builder properties(Map properties) { + public AlterIndexPropertiesReqBuilder properties(Map properties) { this.properties = properties; return this; } - public Builder property(String key, String value) { + public AlterIndexPropertiesReqBuilder property(String key, String value) { if (this.properties == null) { this.properties = new HashMap<>(); } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/index/request/AlterIndexReq.java b/sdk-core/src/main/java/io/milvus/v2/service/index/request/AlterIndexReq.java index b8cb9c714..b8a285d36 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/index/request/AlterIndexReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/index/request/AlterIndexReq.java @@ -1,7 +1,5 @@ package io.milvus.v2.service.index.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.HashMap; import java.util.Map; @@ -12,7 +10,7 @@ public class AlterIndexReq { private String indexName; private Map properties; - private AlterIndexReq(Builder builder) { + private AlterIndexReq(AlterIndexReqBuilder builder) { this.collectionName = builder.collectionName; this.databaseName = builder.databaseName; this.indexName = builder.indexName; @@ -51,28 +49,6 @@ public void setProperties(Map properties) { this.properties = properties; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AlterIndexReq that = (AlterIndexReq) obj; - return new EqualsBuilder() - .append(collectionName, that.collectionName) - .append(databaseName, that.databaseName) - .append(indexName, that.indexName) - .append(properties, that.properties) - .isEquals(); - } - - @Override - public int hashCode() { - int result = collectionName != null ? collectionName.hashCode() : 0; - result = 31 * result + (databaseName != null ? databaseName.hashCode() : 0); - result = 31 * result + (indexName != null ? indexName.hashCode() : 0); - result = 31 * result + (properties != null ? properties.hashCode() : 0); - return result; - } - @Override public String toString() { return "AlterIndexReq{" + @@ -83,34 +59,35 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static AlterIndexReqBuilder builder() { + return new AlterIndexReqBuilder(); } - public static class Builder { + public static class AlterIndexReqBuilder { private String collectionName; private String databaseName; private String indexName; private Map properties = new HashMap<>(); - private Builder() {} + private AlterIndexReqBuilder() { + } - public Builder collectionName(String collectionName) { + public AlterIndexReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder databaseName(String databaseName) { + public AlterIndexReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder indexName(String indexName) { + public AlterIndexReqBuilder indexName(String indexName) { this.indexName = indexName; return this; } - public Builder properties(Map properties) { + public AlterIndexReqBuilder properties(Map properties) { this.properties = properties; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/index/request/CreateIndexReq.java b/sdk-core/src/main/java/io/milvus/v2/service/index/request/CreateIndexReq.java index d8286578a..2f7928d4b 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/index/request/CreateIndexReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/index/request/CreateIndexReq.java @@ -20,7 +20,6 @@ package io.milvus.v2.service.index.request; import io.milvus.v2.common.IndexParam; -import org.apache.commons.lang3.builder.EqualsBuilder; import java.util.List; @@ -31,7 +30,7 @@ public class CreateIndexReq { private Boolean sync = Boolean.TRUE; // wait the index to complete private Long timeout = 60000L; // timeout value for waiting the index to complete - private CreateIndexReq(Builder builder) { + private CreateIndexReq(CreateIndexReqBuilder builder) { if (builder.collectionName == null) { throw new IllegalArgumentException("Collection name cannot be null"); } @@ -85,30 +84,6 @@ public void setTimeout(Long timeout) { this.timeout = timeout; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - CreateIndexReq that = (CreateIndexReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(indexParams, that.indexParams) - .append(sync, that.sync) - .append(timeout, that.timeout) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0); - result = 31 * result + (indexParams != null ? indexParams.hashCode() : 0); - result = 31 * result + (sync != null ? sync.hashCode() : 0); - result = 31 * result + (timeout != null ? timeout.hashCode() : 0); - return result; - } - @Override public String toString() { return "CreateIndexReq{" + @@ -120,25 +95,26 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static CreateIndexReqBuilder builder() { + return new CreateIndexReqBuilder(); } - public static class Builder { + public static class CreateIndexReqBuilder { private String databaseName; private String collectionName; private List indexParams; private Boolean sync = Boolean.TRUE; // wait the index to complete private Long timeout = 60000L; // timeout value for waiting the index to complete - private Builder() {} + private CreateIndexReqBuilder() { + } - public Builder databaseName(String databaseName) { + public CreateIndexReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public CreateIndexReqBuilder collectionName(String collectionName) { if (collectionName == null) { throw new IllegalArgumentException("Collection name cannot be null"); } @@ -146,17 +122,17 @@ public Builder collectionName(String collectionName) { return this; } - public Builder indexParams(List indexParams) { + public CreateIndexReqBuilder indexParams(List indexParams) { this.indexParams = indexParams; return this; } - public Builder sync(Boolean sync) { + public CreateIndexReqBuilder sync(Boolean sync) { this.sync = sync; return this; } - public Builder timeout(Long timeout) { + public CreateIndexReqBuilder timeout(Long timeout) { this.timeout = timeout; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/index/request/DescribeIndexReq.java b/sdk-core/src/main/java/io/milvus/v2/service/index/request/DescribeIndexReq.java index 2cf009fa8..894bd146a 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/index/request/DescribeIndexReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/index/request/DescribeIndexReq.java @@ -19,8 +19,6 @@ package io.milvus.v2.service.index.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class DescribeIndexReq { private String databaseName; private String collectionName; @@ -28,7 +26,7 @@ public class DescribeIndexReq { private String indexName; private Long timestamp = 0L; // only check segments generated before this timestamp. all the segments will be checked if this value is zero. - private DescribeIndexReq(Builder builder) { + private DescribeIndexReq(DescribeIndexReqBuilder builder) { if (builder.collectionName == null) { throw new IllegalArgumentException("Collection name cannot be null"); } @@ -82,30 +80,6 @@ public void setTimestamp(Long timestamp) { this.timestamp = timestamp; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DescribeIndexReq that = (DescribeIndexReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(fieldName, that.fieldName) - .append(indexName, that.indexName) - .append(timestamp, that.timestamp) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0); - result = 31 * result + (fieldName != null ? fieldName.hashCode() : 0); - result = 31 * result + (indexName != null ? indexName.hashCode() : 0); - result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0); - return result; - } - @Override public String toString() { return "DescribeIndexReq{" + @@ -117,25 +91,26 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DescribeIndexReqBuilder builder() { + return new DescribeIndexReqBuilder(); } - public static class Builder { + public static class DescribeIndexReqBuilder { private String databaseName; private String collectionName; private String fieldName; private String indexName; private Long timestamp = 0L; // only check segments generated before this timestamp. all the segments will be checked if this value is zero. - private Builder() {} + private DescribeIndexReqBuilder() { + } - public Builder databaseName(String databaseName) { + public DescribeIndexReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public DescribeIndexReqBuilder collectionName(String collectionName) { if (collectionName == null) { throw new IllegalArgumentException("Collection name cannot be null"); } @@ -143,17 +118,17 @@ public Builder collectionName(String collectionName) { return this; } - public Builder fieldName(String fieldName) { + public DescribeIndexReqBuilder fieldName(String fieldName) { this.fieldName = fieldName; return this; } - public Builder indexName(String indexName) { + public DescribeIndexReqBuilder indexName(String indexName) { this.indexName = indexName; return this; } - public Builder timestamp(Long timestamp) { + public DescribeIndexReqBuilder timestamp(Long timestamp) { this.timestamp = timestamp; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/index/request/DropIndexPropertiesReq.java b/sdk-core/src/main/java/io/milvus/v2/service/index/request/DropIndexPropertiesReq.java index 45c794fa7..f7a1a8244 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/index/request/DropIndexPropertiesReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/index/request/DropIndexPropertiesReq.java @@ -19,8 +19,6 @@ package io.milvus.v2.service.index.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.ArrayList; import java.util.List; @@ -30,7 +28,7 @@ public class DropIndexPropertiesReq { private String indexName; private List propertyKeys; - private DropIndexPropertiesReq(Builder builder) { + private DropIndexPropertiesReq(DropIndexPropertiesReqBuilder builder) { this.collectionName = builder.collectionName; this.databaseName = builder.databaseName; this.indexName = builder.indexName; @@ -69,28 +67,6 @@ public void setPropertyKeys(List propertyKeys) { this.propertyKeys = propertyKeys; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DropIndexPropertiesReq that = (DropIndexPropertiesReq) obj; - return new EqualsBuilder() - .append(collectionName, that.collectionName) - .append(databaseName, that.databaseName) - .append(indexName, that.indexName) - .append(propertyKeys, that.propertyKeys) - .isEquals(); - } - - @Override - public int hashCode() { - int result = collectionName != null ? collectionName.hashCode() : 0; - result = 31 * result + (databaseName != null ? databaseName.hashCode() : 0); - result = 31 * result + (indexName != null ? indexName.hashCode() : 0); - result = 31 * result + (propertyKeys != null ? propertyKeys.hashCode() : 0); - return result; - } - @Override public String toString() { return "DropIndexPropertiesReq{" + @@ -101,34 +77,35 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DropIndexPropertiesReqBuilder builder() { + return new DropIndexPropertiesReqBuilder(); } - public static class Builder { + public static class DropIndexPropertiesReqBuilder { private String collectionName; private String databaseName; private String indexName; private List propertyKeys = new ArrayList<>(); - private Builder() {} + private DropIndexPropertiesReqBuilder() { + } - public Builder collectionName(String collectionName) { + public DropIndexPropertiesReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder databaseName(String databaseName) { + public DropIndexPropertiesReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder indexName(String indexName) { + public DropIndexPropertiesReqBuilder indexName(String indexName) { this.indexName = indexName; return this; } - public Builder propertyKeys(List propertyKeys) { + public DropIndexPropertiesReqBuilder propertyKeys(List propertyKeys) { this.propertyKeys = propertyKeys; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/index/request/DropIndexReq.java b/sdk-core/src/main/java/io/milvus/v2/service/index/request/DropIndexReq.java index 928f7abb9..615b7f43d 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/index/request/DropIndexReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/index/request/DropIndexReq.java @@ -19,15 +19,13 @@ package io.milvus.v2.service.index.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class DropIndexReq { private String databaseName; private String collectionName; private String fieldName; private String indexName; - private DropIndexReq(Builder builder) { + private DropIndexReq(DropIndexReqBuilder builder) { if (builder.collectionName == null) { throw new IllegalArgumentException("Collection name cannot be null"); } @@ -72,28 +70,6 @@ public void setIndexName(String indexName) { this.indexName = indexName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DropIndexReq that = (DropIndexReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(fieldName, that.fieldName) - .append(indexName, that.indexName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0); - result = 31 * result + (fieldName != null ? fieldName.hashCode() : 0); - result = 31 * result + (indexName != null ? indexName.hashCode() : 0); - return result; - } - @Override public String toString() { return "DropIndexReq{" + @@ -104,24 +80,25 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DropIndexReqBuilder builder() { + return new DropIndexReqBuilder(); } - public static class Builder { + public static class DropIndexReqBuilder { private String databaseName; private String collectionName; private String fieldName; private String indexName; - private Builder() {} + private DropIndexReqBuilder() { + } - public Builder databaseName(String databaseName) { + public DropIndexReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public DropIndexReqBuilder collectionName(String collectionName) { if (collectionName == null) { throw new IllegalArgumentException("Collection name cannot be null"); } @@ -129,12 +106,12 @@ public Builder collectionName(String collectionName) { return this; } - public Builder fieldName(String fieldName) { + public DropIndexReqBuilder fieldName(String fieldName) { this.fieldName = fieldName; return this; } - public Builder indexName(String indexName) { + public DropIndexReqBuilder indexName(String indexName) { this.indexName = indexName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/index/request/ListIndexesReq.java b/sdk-core/src/main/java/io/milvus/v2/service/index/request/ListIndexesReq.java index c4d696d44..f276d83a3 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/index/request/ListIndexesReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/index/request/ListIndexesReq.java @@ -19,14 +19,12 @@ package io.milvus.v2.service.index.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class ListIndexesReq { private String databaseName; private String collectionName; private String fieldName; - private ListIndexesReq(Builder builder) { + private ListIndexesReq(ListIndexesReqBuilder builder) { if (builder.collectionName == null) { throw new IllegalArgumentException("Collection name cannot be null"); } @@ -62,26 +60,6 @@ public void setFieldName(String fieldName) { this.fieldName = fieldName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ListIndexesReq that = (ListIndexesReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(fieldName, that.fieldName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0); - result = 31 * result + (fieldName != null ? fieldName.hashCode() : 0); - return result; - } - @Override public String toString() { return "ListIndexesReq{" + @@ -91,23 +69,24 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static ListIndexesReqBuilder builder() { + return new ListIndexesReqBuilder(); } - public static class Builder { + public static class ListIndexesReqBuilder { private String databaseName; private String collectionName; private String fieldName; - private Builder() {} + private ListIndexesReqBuilder() { + } - public Builder databaseName(String databaseName) { + public ListIndexesReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public ListIndexesReqBuilder collectionName(String collectionName) { if (collectionName == null) { throw new IllegalArgumentException("Collection name cannot be null"); } @@ -115,7 +94,7 @@ public Builder collectionName(String collectionName) { return this; } - public Builder fieldName(String fieldName) { + public ListIndexesReqBuilder fieldName(String fieldName) { this.fieldName = fieldName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/index/response/DescribeIndexResp.java b/sdk-core/src/main/java/io/milvus/v2/service/index/response/DescribeIndexResp.java index 4d74502f9..07d4559af 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/index/response/DescribeIndexResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/index/response/DescribeIndexResp.java @@ -21,7 +21,6 @@ import io.milvus.v2.common.IndexBuildState; import io.milvus.v2.common.IndexParam; -import org.apache.commons.lang3.builder.EqualsBuilder; import java.util.ArrayList; import java.util.HashMap; @@ -31,7 +30,7 @@ public class DescribeIndexResp { private List indexDescriptions; - private DescribeIndexResp(Builder builder) { + private DescribeIndexResp(DescribeIndexRespBuilder builder) { this.indexDescriptions = builder.indexDescriptions; } @@ -67,21 +66,6 @@ public IndexDesc getIndexDescByIndexName(String indexName) { return null; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DescribeIndexResp that = (DescribeIndexResp) obj; - return new EqualsBuilder() - .append(indexDescriptions, that.indexDescriptions) - .isEquals(); - } - - @Override - public int hashCode() { - return indexDescriptions != null ? indexDescriptions.hashCode() : 0; - } - @Override public String toString() { return "DescribeIndexResp{" + @@ -89,16 +73,17 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DescribeIndexRespBuilder builder() { + return new DescribeIndexRespBuilder(); } - public static class Builder { + public static class DescribeIndexRespBuilder { private List indexDescriptions = new ArrayList<>(); - private Builder() {} + private DescribeIndexRespBuilder() { + } - public Builder indexDescriptions(List indexDescriptions) { + public DescribeIndexRespBuilder indexDescriptions(List indexDescriptions) { this.indexDescriptions = indexDescriptions; return this; } @@ -132,7 +117,7 @@ public static final class IndexDesc { @Deprecated private Map properties; - private IndexDesc(Builder builder) { + private IndexDesc(IndexDescBuilder builder) { this.fieldName = builder.fieldName; this.indexName = builder.indexName; this.id = builder.id; @@ -243,44 +228,6 @@ public void setProperties(Map properties) { this.properties = properties; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - IndexDesc indexDesc = (IndexDesc) obj; - return new EqualsBuilder() - .append(id, indexDesc.id) - .append(indexedRows, indexDesc.indexedRows) - .append(totalRows, indexDesc.totalRows) - .append(pendingIndexRows, indexDesc.pendingIndexRows) - .append(fieldName, indexDesc.fieldName) - .append(indexName, indexDesc.indexName) - .append(indexType, indexDesc.indexType) - .append(metricType, indexDesc.metricType) - .append(extraParams, indexDesc.extraParams) - .append(indexState, indexDesc.indexState) - .append(indexFailedReason, indexDesc.indexFailedReason) - .append(properties, indexDesc.properties) - .isEquals(); - } - - @Override - public int hashCode() { - int result = fieldName != null ? fieldName.hashCode() : 0; - result = 31 * result + (indexName != null ? indexName.hashCode() : 0); - result = 31 * result + (int) (id ^ (id >>> 32)); - result = 31 * result + (indexType != null ? indexType.hashCode() : 0); - result = 31 * result + (metricType != null ? metricType.hashCode() : 0); - result = 31 * result + (extraParams != null ? extraParams.hashCode() : 0); - result = 31 * result + (int) (indexedRows ^ (indexedRows >>> 32)); - result = 31 * result + (int) (totalRows ^ (totalRows >>> 32)); - result = 31 * result + (int) (pendingIndexRows ^ (pendingIndexRows >>> 32)); - result = 31 * result + (indexState != null ? indexState.hashCode() : 0); - result = 31 * result + (indexFailedReason != null ? indexFailedReason.hashCode() : 0); - result = 31 * result + (properties != null ? properties.hashCode() : 0); - return result; - } - @Override public String toString() { return "IndexDesc{" + @@ -299,11 +246,11 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static IndexDescBuilder builder() { + return new IndexDescBuilder(); } - public static class Builder { + public static class IndexDescBuilder { private String fieldName; private String indexName; private long id; @@ -317,64 +264,65 @@ public static class Builder { private String indexFailedReason = ""; private Map properties = new HashMap<>(); - private Builder() {} + private IndexDescBuilder() { + } - public Builder fieldName(String fieldName) { + public IndexDescBuilder fieldName(String fieldName) { this.fieldName = fieldName; return this; } - public Builder indexName(String indexName) { + public IndexDescBuilder indexName(String indexName) { this.indexName = indexName; return this; } - public Builder id(long id) { + public IndexDescBuilder id(long id) { this.id = id; return this; } - public Builder indexType(IndexParam.IndexType indexType) { + public IndexDescBuilder indexType(IndexParam.IndexType indexType) { this.indexType = indexType; return this; } - public Builder metricType(IndexParam.MetricType metricType) { + public IndexDescBuilder metricType(IndexParam.MetricType metricType) { this.metricType = metricType; return this; } - public Builder extraParams(Map extraParams) { + public IndexDescBuilder extraParams(Map extraParams) { this.extraParams = extraParams; return this; } - public Builder indexedRows(long indexedRows) { + public IndexDescBuilder indexedRows(long indexedRows) { this.indexedRows = indexedRows; return this; } - public Builder totalRows(long totalRows) { + public IndexDescBuilder totalRows(long totalRows) { this.totalRows = totalRows; return this; } - public Builder pendingIndexRows(long pendingIndexRows) { + public IndexDescBuilder pendingIndexRows(long pendingIndexRows) { this.pendingIndexRows = pendingIndexRows; return this; } - public Builder indexState(IndexBuildState indexState) { + public IndexDescBuilder indexState(IndexBuildState indexState) { this.indexState = indexState; return this; } - public Builder indexFailedReason(String indexFailedReason) { + public IndexDescBuilder indexFailedReason(String indexFailedReason) { this.indexFailedReason = indexFailedReason; return this; } - public Builder properties(Map properties) { + public IndexDescBuilder properties(Map properties) { this.properties = properties; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/partition/PartitionService.java b/sdk-core/src/main/java/io/milvus/v2/service/partition/PartitionService.java index a7fe9fbec..a9f005e49 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/partition/PartitionService.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/partition/PartitionService.java @@ -24,7 +24,7 @@ import io.milvus.v2.exception.MilvusClientException; import io.milvus.v2.service.BaseService; import io.milvus.v2.service.partition.request.*; -import io.milvus.v2.service.partition.response.*; +import io.milvus.v2.service.partition.response.GetPartitionStatsResp; import org.apache.commons.lang3.StringUtils; import java.util.List; diff --git a/sdk-core/src/main/java/io/milvus/v2/service/partition/request/CreatePartitionReq.java b/sdk-core/src/main/java/io/milvus/v2/service/partition/request/CreatePartitionReq.java index 2a3c5d4b7..7d9af6210 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/partition/request/CreatePartitionReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/partition/request/CreatePartitionReq.java @@ -19,14 +19,12 @@ package io.milvus.v2.service.partition.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class CreatePartitionReq { private String databaseName; private String collectionName; private String partitionName; - private CreatePartitionReq(Builder builder) { + private CreatePartitionReq(CreatePartitionReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionName = builder.partitionName; @@ -56,26 +54,6 @@ public void setPartitionName(String partitionName) { this.partitionName = partitionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - CreatePartitionReq that = (CreatePartitionReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(partitionName, that.partitionName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0); - result = 31 * result + (partitionName != null ? partitionName.hashCode() : 0); - return result; - } - @Override public String toString() { return "CreatePartitionReq{" + @@ -85,28 +63,29 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static CreatePartitionReqBuilder builder() { + return new CreatePartitionReqBuilder(); } - public static class Builder { + public static class CreatePartitionReqBuilder { private String databaseName; private String collectionName; private String partitionName; - private Builder() {} + private CreatePartitionReqBuilder() { + } - public Builder databaseName(String databaseName) { + public CreatePartitionReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public CreatePartitionReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionName(String partitionName) { + public CreatePartitionReqBuilder partitionName(String partitionName) { this.partitionName = partitionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/partition/request/DropPartitionReq.java b/sdk-core/src/main/java/io/milvus/v2/service/partition/request/DropPartitionReq.java index c6a9bb612..90213b03a 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/partition/request/DropPartitionReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/partition/request/DropPartitionReq.java @@ -19,14 +19,12 @@ package io.milvus.v2.service.partition.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class DropPartitionReq { private String databaseName; private String collectionName; private String partitionName; - private DropPartitionReq(Builder builder) { + private DropPartitionReq(DropPartitionReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionName = builder.partitionName; @@ -56,26 +54,6 @@ public void setPartitionName(String partitionName) { this.partitionName = partitionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DropPartitionReq that = (DropPartitionReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(partitionName, that.partitionName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0); - result = 31 * result + (partitionName != null ? partitionName.hashCode() : 0); - return result; - } - @Override public String toString() { return "DropPartitionReq{" + @@ -85,28 +63,29 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DropPartitionReqBuilder builder() { + return new DropPartitionReqBuilder(); } - public static class Builder { + public static class DropPartitionReqBuilder { private String databaseName; private String collectionName; private String partitionName; - private Builder() {} + private DropPartitionReqBuilder() { + } - public Builder databaseName(String databaseName) { + public DropPartitionReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public DropPartitionReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionName(String partitionName) { + public DropPartitionReqBuilder partitionName(String partitionName) { this.partitionName = partitionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/partition/request/GetPartitionStatsReq.java b/sdk-core/src/main/java/io/milvus/v2/service/partition/request/GetPartitionStatsReq.java index 9523a1fad..a2cb6070f 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/partition/request/GetPartitionStatsReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/partition/request/GetPartitionStatsReq.java @@ -19,14 +19,12 @@ package io.milvus.v2.service.partition.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class GetPartitionStatsReq { private String databaseName; private String collectionName; private String partitionName; - private GetPartitionStatsReq(Builder builder) { + private GetPartitionStatsReq(GetPartitionStatsReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionName = builder.partitionName; @@ -56,26 +54,6 @@ public void setPartitionName(String partitionName) { this.partitionName = partitionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GetPartitionStatsReq that = (GetPartitionStatsReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(partitionName, that.partitionName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0); - result = 31 * result + (partitionName != null ? partitionName.hashCode() : 0); - return result; - } - @Override public String toString() { return "GetPartitionStatsReq{" + @@ -85,28 +63,29 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static GetPartitionStatsReqBuilder builder() { + return new GetPartitionStatsReqBuilder(); } - public static class Builder { + public static class GetPartitionStatsReqBuilder { private String databaseName; private String collectionName; private String partitionName; - private Builder() {} + private GetPartitionStatsReqBuilder() { + } - public Builder databaseName(String databaseName) { + public GetPartitionStatsReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public GetPartitionStatsReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionName(String partitionName) { + public GetPartitionStatsReqBuilder partitionName(String partitionName) { this.partitionName = partitionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/partition/request/HasPartitionReq.java b/sdk-core/src/main/java/io/milvus/v2/service/partition/request/HasPartitionReq.java index e1f8c8635..a3f5f83fd 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/partition/request/HasPartitionReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/partition/request/HasPartitionReq.java @@ -19,14 +19,12 @@ package io.milvus.v2.service.partition.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class HasPartitionReq { private String databaseName; private String collectionName; private String partitionName; - private HasPartitionReq(Builder builder) { + private HasPartitionReq(HasPartitionReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionName = builder.partitionName; @@ -56,26 +54,6 @@ public void setPartitionName(String partitionName) { this.partitionName = partitionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - HasPartitionReq that = (HasPartitionReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(partitionName, that.partitionName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0); - result = 31 * result + (partitionName != null ? partitionName.hashCode() : 0); - return result; - } - @Override public String toString() { return "HasPartitionReq{" + @@ -85,28 +63,29 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static HasPartitionReqBuilder builder() { + return new HasPartitionReqBuilder(); } - public static class Builder { + public static class HasPartitionReqBuilder { private String databaseName; private String collectionName; private String partitionName; - private Builder() {} + private HasPartitionReqBuilder() { + } - public Builder databaseName(String databaseName) { + public HasPartitionReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public HasPartitionReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionName(String partitionName) { + public HasPartitionReqBuilder partitionName(String partitionName) { this.partitionName = partitionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/partition/request/ListPartitionsReq.java b/sdk-core/src/main/java/io/milvus/v2/service/partition/request/ListPartitionsReq.java index 683532b0f..1b6c1510e 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/partition/request/ListPartitionsReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/partition/request/ListPartitionsReq.java @@ -19,13 +19,11 @@ package io.milvus.v2.service.partition.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class ListPartitionsReq { private String databaseName; private String collectionName; - private ListPartitionsReq(Builder builder) { + private ListPartitionsReq(ListPartitionsReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; } @@ -46,24 +44,6 @@ public void setCollectionName(String collectionName) { this.collectionName = collectionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ListPartitionsReq that = (ListPartitionsReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0); - return result; - } - @Override public String toString() { return "ListPartitionsReq{" + @@ -72,22 +52,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static ListPartitionsReqBuilder builder() { + return new ListPartitionsReqBuilder(); } - public static class Builder { + public static class ListPartitionsReqBuilder { private String databaseName; private String collectionName; - private Builder() {} + private ListPartitionsReqBuilder() { + } - public Builder databaseName(String databaseName) { + public ListPartitionsReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public ListPartitionsReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/partition/request/LoadPartitionsReq.java b/sdk-core/src/main/java/io/milvus/v2/service/partition/request/LoadPartitionsReq.java index 99c4e911a..a8c1a25fe 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/partition/request/LoadPartitionsReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/partition/request/LoadPartitionsReq.java @@ -19,8 +19,6 @@ package io.milvus.v2.service.partition.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.ArrayList; import java.util.List; @@ -36,7 +34,7 @@ public class LoadPartitionsReq { private Boolean skipLoadDynamicField; private List resourceGroups; - private LoadPartitionsReq(Builder builder) { + private LoadPartitionsReq(LoadPartitionsReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionNames = builder.partitionNames; @@ -129,40 +127,6 @@ public void setResourceGroups(List resourceGroups) { this.resourceGroups = resourceGroups; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - LoadPartitionsReq that = (LoadPartitionsReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(partitionNames, that.partitionNames) - .append(numReplicas, that.numReplicas) - .append(sync, that.sync) - .append(timeout, that.timeout) - .append(refresh, that.refresh) - .append(loadFields, that.loadFields) - .append(skipLoadDynamicField, that.skipLoadDynamicField) - .append(resourceGroups, that.resourceGroups) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0); - result = 31 * result + (partitionNames != null ? partitionNames.hashCode() : 0); - result = 31 * result + (numReplicas != null ? numReplicas.hashCode() : 0); - result = 31 * result + (sync != null ? sync.hashCode() : 0); - result = 31 * result + (timeout != null ? timeout.hashCode() : 0); - result = 31 * result + (refresh != null ? refresh.hashCode() : 0); - result = 31 * result + (loadFields != null ? loadFields.hashCode() : 0); - result = 31 * result + (skipLoadDynamicField != null ? skipLoadDynamicField.hashCode() : 0); - result = 31 * result + (resourceGroups != null ? resourceGroups.hashCode() : 0); - return result; - } - @Override public String toString() { return "LoadPartitionsReq{" + @@ -179,11 +143,11 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static LoadPartitionsReqBuilder builder() { + return new LoadPartitionsReqBuilder(); } - public static class Builder { + public static class LoadPartitionsReqBuilder { private String databaseName; private String collectionName; private List partitionNames = new ArrayList<>(); @@ -195,54 +159,55 @@ public static class Builder { private Boolean skipLoadDynamicField = Boolean.FALSE; private List resourceGroups = new ArrayList<>(); - private Builder() {} + private LoadPartitionsReqBuilder() { + } - public Builder databaseName(String databaseName) { + public LoadPartitionsReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public LoadPartitionsReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionNames(List partitionNames) { + public LoadPartitionsReqBuilder partitionNames(List partitionNames) { this.partitionNames = partitionNames; return this; } - public Builder numReplicas(Integer numReplicas) { + public LoadPartitionsReqBuilder numReplicas(Integer numReplicas) { this.numReplicas = numReplicas; return this; } - public Builder sync(Boolean sync) { + public LoadPartitionsReqBuilder sync(Boolean sync) { this.sync = sync; return this; } - public Builder timeout(Long timeout) { + public LoadPartitionsReqBuilder timeout(Long timeout) { this.timeout = timeout; return this; } - public Builder refresh(Boolean refresh) { + public LoadPartitionsReqBuilder refresh(Boolean refresh) { this.refresh = refresh; return this; } - public Builder loadFields(List loadFields) { + public LoadPartitionsReqBuilder loadFields(List loadFields) { this.loadFields = loadFields; return this; } - public Builder skipLoadDynamicField(Boolean skipLoadDynamicField) { + public LoadPartitionsReqBuilder skipLoadDynamicField(Boolean skipLoadDynamicField) { this.skipLoadDynamicField = skipLoadDynamicField; return this; } - public Builder resourceGroups(List resourceGroups) { + public LoadPartitionsReqBuilder resourceGroups(List resourceGroups) { this.resourceGroups = resourceGroups; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/partition/request/ReleasePartitionsReq.java b/sdk-core/src/main/java/io/milvus/v2/service/partition/request/ReleasePartitionsReq.java index 930f79ea7..af2b33abc 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/partition/request/ReleasePartitionsReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/partition/request/ReleasePartitionsReq.java @@ -19,8 +19,6 @@ package io.milvus.v2.service.partition.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.List; public class ReleasePartitionsReq { @@ -28,7 +26,7 @@ public class ReleasePartitionsReq { private String collectionName; private List partitionNames; - private ReleasePartitionsReq(Builder builder) { + private ReleasePartitionsReq(ReleasePartitionsReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionNames = builder.partitionNames; @@ -58,26 +56,6 @@ public void setPartitionNames(List partitionNames) { this.partitionNames = partitionNames; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ReleasePartitionsReq that = (ReleasePartitionsReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(partitionNames, that.partitionNames) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0); - result = 31 * result + (partitionNames != null ? partitionNames.hashCode() : 0); - return result; - } - @Override public String toString() { return "ReleasePartitionsReq{" + @@ -87,28 +65,29 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static ReleasePartitionsReqBuilder builder() { + return new ReleasePartitionsReqBuilder(); } - public static class Builder { + public static class ReleasePartitionsReqBuilder { private String databaseName; private String collectionName; private List partitionNames; - private Builder() {} + private ReleasePartitionsReqBuilder() { + } - public Builder databaseName(String databaseName) { + public ReleasePartitionsReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public ReleasePartitionsReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionNames(List partitionNames) { + public ReleasePartitionsReqBuilder partitionNames(List partitionNames) { this.partitionNames = partitionNames; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/partition/response/GetPartitionStatsResp.java b/sdk-core/src/main/java/io/milvus/v2/service/partition/response/GetPartitionStatsResp.java index 43d051a50..92ac347d9 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/partition/response/GetPartitionStatsResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/partition/response/GetPartitionStatsResp.java @@ -20,12 +20,10 @@ package io.milvus.v2.service.partition.response; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class GetPartitionStatsResp { private Long numOfEntities; - private GetPartitionStatsResp(Builder builder) { + private GetPartitionStatsResp(GetPartitionStatsRespBuilder builder) { this.numOfEntities = builder.numOfEntities; } @@ -37,21 +35,6 @@ public void setNumOfEntities(Long numOfEntities) { this.numOfEntities = numOfEntities; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GetPartitionStatsResp that = (GetPartitionStatsResp) obj; - return new EqualsBuilder() - .append(numOfEntities, that.numOfEntities) - .isEquals(); - } - - @Override - public int hashCode() { - return numOfEntities != null ? numOfEntities.hashCode() : 0; - } - @Override public String toString() { return "GetPartitionStatsResp{" + @@ -59,16 +42,17 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static GetPartitionStatsRespBuilder builder() { + return new GetPartitionStatsRespBuilder(); } - public static class Builder { + public static class GetPartitionStatsRespBuilder { private Long numOfEntities; - private Builder() {} + private GetPartitionStatsRespBuilder() { + } - public Builder numOfEntities(Long numOfEntities) { + public GetPartitionStatsRespBuilder numOfEntities(Long numOfEntities) { this.numOfEntities = numOfEntities; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/PrivilegeGroup.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/PrivilegeGroup.java index 1a3e27060..17da10928 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/PrivilegeGroup.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/PrivilegeGroup.java @@ -19,8 +19,6 @@ package io.milvus.v2.service.rbac; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.ArrayList; import java.util.List; @@ -28,7 +26,7 @@ public class PrivilegeGroup { private String groupName; private List privileges; - private PrivilegeGroup(Builder builder) { + private PrivilegeGroup(PrivilegeGroupBuilder builder) { this.groupName = builder.groupName; this.privileges = builder.privileges; } @@ -49,24 +47,6 @@ public void setPrivileges(List privileges) { this.privileges = privileges; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - PrivilegeGroup that = (PrivilegeGroup) obj; - return new EqualsBuilder() - .append(groupName, that.groupName) - .append(privileges, that.privileges) - .isEquals(); - } - - @Override - public int hashCode() { - int result = groupName != null ? groupName.hashCode() : 0; - result = 31 * result + (privileges != null ? privileges.hashCode() : 0); - return result; - } - @Override public String toString() { return "PrivilegeGroup{" + @@ -75,22 +55,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static PrivilegeGroupBuilder builder() { + return new PrivilegeGroupBuilder(); } - public static class Builder { + public static class PrivilegeGroupBuilder { private String groupName; private List privileges = new ArrayList<>(); - private Builder() {} + private PrivilegeGroupBuilder() { + } - public Builder groupName(String groupName) { + public PrivilegeGroupBuilder groupName(String groupName) { this.groupName = groupName; return this; } - public Builder privileges(List privileges) { + public PrivilegeGroupBuilder privileges(List privileges) { this.privileges = privileges; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/RBACService.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/RBACService.java index 9f8a9be79..92bc36064 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/RBACService.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/RBACService.java @@ -167,7 +167,7 @@ public Void revokeRole(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, return null; } - //////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// ///////////////////////////////////////////////////////////////////////////////////////////////////////// public List listUsers(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub) { ListCredUsersRequest request = ListCredUsersRequest.newBuilder().build(); ListCredUsersResponse response = blockingStub.listCredUsers(request); @@ -184,7 +184,7 @@ public DescribeUserResp describeUser(MilvusServiceGrpc.MilvusServiceBlockingStub SelectUserResponse response = blockingStub.selectUser(selectUserRequest); rpcUtils.handleResponse(title, response.getStatus()); DescribeUserResp describeUserResp = DescribeUserResp.builder() - .roles(response.getResultsList().isEmpty()? null : response.getResultsList().get(0).getRolesList().stream().map(RoleEntity::getName).collect(Collectors.toList())) + .roles(response.getResultsList().isEmpty() ? null : response.getResultsList().get(0).getRolesList().stream().map(RoleEntity::getName).collect(Collectors.toList())) .build(); return describeUserResp; } @@ -226,7 +226,7 @@ public Void dropUser(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, D return null; } - //////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// ///////////////////////////////////////////////////////////////////////////////////////////////////////// public Void createPrivilegeGroup(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, CreatePrivilegeGroupReq request) { String title = String.format("Create privilege group: '%s'", request.getGroupName()); CreatePrivilegeGroupRequest createPrivilegeGroupRequest = CreatePrivilegeGroupRequest.newBuilder() @@ -256,9 +256,9 @@ public ListPrivilegeGroupsResp listPrivilegeGroups(MilvusServiceGrpc.MilvusServi rpcUtils.handleResponse("List privilege groups", response.getStatus()); List privilegeGroups = new ArrayList<>(); - response.getPrivilegeGroupsList().forEach((privilegeGroupInfo)->{ + response.getPrivilegeGroupsList().forEach((privilegeGroupInfo) -> { List privileges = new ArrayList<>(); - privilegeGroupInfo.getPrivilegesList().forEach((privilege)->{ + privilegeGroupInfo.getPrivilegesList().forEach((privilege) -> { privileges.add(privilege.getName()); }); privilegeGroups.add(PrivilegeGroup.builder().groupName(privilegeGroupInfo.getGroupName()).privileges(privileges).build()); diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/AddPrivilegesToGroupReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/AddPrivilegesToGroupReq.java index ee5a2f7e7..a9b6a398b 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/AddPrivilegesToGroupReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/AddPrivilegesToGroupReq.java @@ -19,8 +19,6 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.ArrayList; import java.util.List; @@ -28,7 +26,7 @@ public class AddPrivilegesToGroupReq { private String groupName; private List privileges = new ArrayList<>(); - private AddPrivilegesToGroupReq(Builder builder) { + private AddPrivilegesToGroupReq(AddPrivilegesToGroupReqBuilder builder) { this.groupName = builder.groupName; this.privileges = builder.privileges; } @@ -49,24 +47,6 @@ public void setPrivileges(List privileges) { this.privileges = privileges; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AddPrivilegesToGroupReq that = (AddPrivilegesToGroupReq) obj; - return new EqualsBuilder() - .append(groupName, that.groupName) - .append(privileges, that.privileges) - .isEquals(); - } - - @Override - public int hashCode() { - int result = groupName != null ? groupName.hashCode() : 0; - result = 31 * result + (privileges != null ? privileges.hashCode() : 0); - return result; - } - @Override public String toString() { return "AddPrivilegesToGroupReq{" + @@ -75,22 +55,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static AddPrivilegesToGroupReqBuilder builder() { + return new AddPrivilegesToGroupReqBuilder(); } - public static class Builder { + public static class AddPrivilegesToGroupReqBuilder { private String groupName; private List privileges = new ArrayList<>(); - private Builder() {} + private AddPrivilegesToGroupReqBuilder() { + } - public Builder groupName(String groupName) { + public AddPrivilegesToGroupReqBuilder groupName(String groupName) { this.groupName = groupName; return this; } - public Builder privileges(List privileges) { + public AddPrivilegesToGroupReqBuilder privileges(List privileges) { this.privileges = privileges; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/CreatePrivilegeGroupReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/CreatePrivilegeGroupReq.java index c9f02d9f3..d57691591 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/CreatePrivilegeGroupReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/CreatePrivilegeGroupReq.java @@ -19,12 +19,10 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class CreatePrivilegeGroupReq { private String groupName; - private CreatePrivilegeGroupReq(Builder builder) { + private CreatePrivilegeGroupReq(CreatePrivilegeGroupReqBuilder builder) { this.groupName = builder.groupName; } @@ -36,21 +34,6 @@ public void setGroupName(String groupName) { this.groupName = groupName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - CreatePrivilegeGroupReq that = (CreatePrivilegeGroupReq) obj; - return new EqualsBuilder() - .append(groupName, that.groupName) - .isEquals(); - } - - @Override - public int hashCode() { - return groupName != null ? groupName.hashCode() : 0; - } - @Override public String toString() { return "CreatePrivilegeGroupReq{" + @@ -58,16 +41,17 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static CreatePrivilegeGroupReqBuilder builder() { + return new CreatePrivilegeGroupReqBuilder(); } - public static class Builder { + public static class CreatePrivilegeGroupReqBuilder { private String groupName; - private Builder() {} + private CreatePrivilegeGroupReqBuilder() { + } - public Builder groupName(String groupName) { + public CreatePrivilegeGroupReqBuilder groupName(String groupName) { this.groupName = groupName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/CreateRoleReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/CreateRoleReq.java index c8718aacf..11afccf58 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/CreateRoleReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/CreateRoleReq.java @@ -19,12 +19,10 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class CreateRoleReq { private String roleName; - private CreateRoleReq(Builder builder) { + private CreateRoleReq(CreateRoleReqBuilder builder) { this.roleName = builder.roleName; } @@ -36,21 +34,6 @@ public void setRoleName(String roleName) { this.roleName = roleName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - CreateRoleReq that = (CreateRoleReq) obj; - return new EqualsBuilder() - .append(roleName, that.roleName) - .isEquals(); - } - - @Override - public int hashCode() { - return roleName != null ? roleName.hashCode() : 0; - } - @Override public String toString() { return "CreateRoleReq{" + @@ -58,16 +41,17 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static CreateRoleReqBuilder builder() { + return new CreateRoleReqBuilder(); } - public static class Builder { + public static class CreateRoleReqBuilder { private String roleName; - private Builder() {} + private CreateRoleReqBuilder() { + } - public Builder roleName(String roleName) { + public CreateRoleReqBuilder roleName(String roleName) { this.roleName = roleName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/CreateUserReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/CreateUserReq.java index 35276d41c..ae237ddcd 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/CreateUserReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/CreateUserReq.java @@ -19,13 +19,11 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class CreateUserReq { private String userName; private String password; - private CreateUserReq(Builder builder) { + private CreateUserReq(CreateUserReqBuilder builder) { this.userName = builder.userName; this.password = builder.password; } @@ -46,24 +44,6 @@ public void setPassword(String password) { this.password = password; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - CreateUserReq that = (CreateUserReq) obj; - return new EqualsBuilder() - .append(userName, that.userName) - .append(password, that.password) - .isEquals(); - } - - @Override - public int hashCode() { - int result = userName != null ? userName.hashCode() : 0; - result = 31 * result + (password != null ? password.hashCode() : 0); - return result; - } - @Override public String toString() { return "CreateUserReq{" + @@ -72,22 +52,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static CreateUserReqBuilder builder() { + return new CreateUserReqBuilder(); } - public static class Builder { + public static class CreateUserReqBuilder { private String userName; private String password; - private Builder() {} + private CreateUserReqBuilder() { + } - public Builder userName(String userName) { + public CreateUserReqBuilder userName(String userName) { this.userName = userName; return this; } - public Builder password(String password) { + public CreateUserReqBuilder password(String password) { this.password = password; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DescribeRoleReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DescribeRoleReq.java index 260e21240..a72bd184f 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DescribeRoleReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DescribeRoleReq.java @@ -19,13 +19,11 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class DescribeRoleReq { private String roleName; private String dbName; - private DescribeRoleReq(Builder builder) { + private DescribeRoleReq(DescribeRoleReqBuilder builder) { this.roleName = builder.roleName; this.dbName = builder.dbName; } @@ -46,24 +44,6 @@ public void setDbName(String dbName) { this.dbName = dbName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DescribeRoleReq that = (DescribeRoleReq) obj; - return new EqualsBuilder() - .append(roleName, that.roleName) - .append(dbName, that.dbName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = roleName != null ? roleName.hashCode() : 0; - result = 31 * result + (dbName != null ? dbName.hashCode() : 0); - return result; - } - @Override public String toString() { return "DescribeRoleReq{" + @@ -72,22 +52,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DescribeRoleReqBuilder builder() { + return new DescribeRoleReqBuilder(); } - public static class Builder { + public static class DescribeRoleReqBuilder { private String roleName; private String dbName; - private Builder() {} + private DescribeRoleReqBuilder() { + } - public Builder roleName(String roleName) { + public DescribeRoleReqBuilder roleName(String roleName) { this.roleName = roleName; return this; } - public Builder dbName(String dbName) { + public DescribeRoleReqBuilder dbName(String dbName) { this.dbName = dbName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DescribeUserReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DescribeUserReq.java index 9ad428866..41836b61c 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DescribeUserReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DescribeUserReq.java @@ -19,12 +19,10 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class DescribeUserReq { private String userName; - private DescribeUserReq(Builder builder) { + private DescribeUserReq(DescribeUserReqBuilder builder) { this.userName = builder.userName; } @@ -36,21 +34,6 @@ public void setUserName(String userName) { this.userName = userName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DescribeUserReq that = (DescribeUserReq) obj; - return new EqualsBuilder() - .append(userName, that.userName) - .isEquals(); - } - - @Override - public int hashCode() { - return userName != null ? userName.hashCode() : 0; - } - @Override public String toString() { return "DescribeUserReq{" + @@ -58,16 +41,17 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DescribeUserReqBuilder builder() { + return new DescribeUserReqBuilder(); } - public static class Builder { + public static class DescribeUserReqBuilder { private String userName; - private Builder() {} + private DescribeUserReqBuilder() { + } - public Builder userName(String userName) { + public DescribeUserReqBuilder userName(String userName) { this.userName = userName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DropPrivilegeGroupReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DropPrivilegeGroupReq.java index 363c0d22a..2061542ae 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DropPrivilegeGroupReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DropPrivilegeGroupReq.java @@ -19,12 +19,10 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class DropPrivilegeGroupReq { private String groupName; - private DropPrivilegeGroupReq(Builder builder) { + private DropPrivilegeGroupReq(DropPrivilegeGroupReqBuilder builder) { this.groupName = builder.groupName; } @@ -36,21 +34,6 @@ public void setGroupName(String groupName) { this.groupName = groupName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DropPrivilegeGroupReq that = (DropPrivilegeGroupReq) obj; - return new EqualsBuilder() - .append(groupName, that.groupName) - .isEquals(); - } - - @Override - public int hashCode() { - return groupName != null ? groupName.hashCode() : 0; - } - @Override public String toString() { return "DropPrivilegeGroupReq{" + @@ -58,16 +41,17 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DropPrivilegeGroupReqBuilder builder() { + return new DropPrivilegeGroupReqBuilder(); } - public static class Builder { + public static class DropPrivilegeGroupReqBuilder { private String groupName; - private Builder() {} + private DropPrivilegeGroupReqBuilder() { + } - public Builder groupName(String groupName) { + public DropPrivilegeGroupReqBuilder groupName(String groupName) { this.groupName = groupName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DropRoleReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DropRoleReq.java index 34dd9c935..5d1a72f08 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DropRoleReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DropRoleReq.java @@ -19,12 +19,10 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class DropRoleReq { private String roleName; - private DropRoleReq(Builder builder) { + private DropRoleReq(DropRoleReqBuilder builder) { this.roleName = builder.roleName; } @@ -36,21 +34,6 @@ public void setRoleName(String roleName) { this.roleName = roleName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DropRoleReq that = (DropRoleReq) obj; - return new EqualsBuilder() - .append(roleName, that.roleName) - .isEquals(); - } - - @Override - public int hashCode() { - return roleName != null ? roleName.hashCode() : 0; - } - @Override public String toString() { return "DropRoleReq{" + @@ -58,16 +41,17 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DropRoleReqBuilder builder() { + return new DropRoleReqBuilder(); } - public static class Builder { + public static class DropRoleReqBuilder { private String roleName; - private Builder() {} + private DropRoleReqBuilder() { + } - public Builder roleName(String roleName) { + public DropRoleReqBuilder roleName(String roleName) { this.roleName = roleName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DropUserReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DropUserReq.java index ab4fbe583..331fa494a 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DropUserReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/DropUserReq.java @@ -19,12 +19,10 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class DropUserReq { private String userName; - private DropUserReq(Builder builder) { + private DropUserReq(DropUserReqBuilder builder) { this.userName = builder.userName; } @@ -36,21 +34,6 @@ public void setUserName(String userName) { this.userName = userName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DropUserReq that = (DropUserReq) obj; - return new EqualsBuilder() - .append(userName, that.userName) - .isEquals(); - } - - @Override - public int hashCode() { - return userName != null ? userName.hashCode() : 0; - } - @Override public String toString() { return "DropUserReq{" + @@ -58,16 +41,17 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DropUserReqBuilder builder() { + return new DropUserReqBuilder(); } - public static class Builder { + public static class DropUserReqBuilder { private String userName; - private Builder() {} + private DropUserReqBuilder() { + } - public Builder userName(String userName) { + public DropUserReqBuilder userName(String userName) { this.userName = userName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/GrantPrivilegeReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/GrantPrivilegeReq.java index 9b2b2efba..7111dcf3f 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/GrantPrivilegeReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/GrantPrivilegeReq.java @@ -19,15 +19,13 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class GrantPrivilegeReq { private String roleName; private String objectType; private String privilege; private String objectName; - private GrantPrivilegeReq(Builder builder) { + private GrantPrivilegeReq(GrantPrivilegeReqBuilder builder) { this.roleName = builder.roleName; this.objectType = builder.objectType; this.privilege = builder.privilege; @@ -66,28 +64,6 @@ public void setObjectName(String objectName) { this.objectName = objectName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GrantPrivilegeReq that = (GrantPrivilegeReq) obj; - return new EqualsBuilder() - .append(roleName, that.roleName) - .append(objectType, that.objectType) - .append(privilege, that.privilege) - .append(objectName, that.objectName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = roleName != null ? roleName.hashCode() : 0; - result = 31 * result + (objectType != null ? objectType.hashCode() : 0); - result = 31 * result + (privilege != null ? privilege.hashCode() : 0); - result = 31 * result + (objectName != null ? objectName.hashCode() : 0); - return result; - } - @Override public String toString() { return "GrantPrivilegeReq{" + @@ -98,34 +74,35 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static GrantPrivilegeReqBuilder builder() { + return new GrantPrivilegeReqBuilder(); } - public static class Builder { + public static class GrantPrivilegeReqBuilder { private String roleName; private String objectType; private String privilege; private String objectName; - private Builder() {} + private GrantPrivilegeReqBuilder() { + } - public Builder roleName(String roleName) { + public GrantPrivilegeReqBuilder roleName(String roleName) { this.roleName = roleName; return this; } - public Builder objectType(String objectType) { + public GrantPrivilegeReqBuilder objectType(String objectType) { this.objectType = objectType; return this; } - public Builder privilege(String privilege) { + public GrantPrivilegeReqBuilder privilege(String privilege) { this.privilege = privilege; return this; } - public Builder objectName(String objectName) { + public GrantPrivilegeReqBuilder objectName(String objectName) { this.objectName = objectName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/GrantPrivilegeReqV2.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/GrantPrivilegeReqV2.java index c1e23a4cf..4d3dee0d4 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/GrantPrivilegeReqV2.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/GrantPrivilegeReqV2.java @@ -19,15 +19,13 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class GrantPrivilegeReqV2 { private String roleName; private String privilege; private String dbName; private String collectionName; - private GrantPrivilegeReqV2(Builder builder) { + private GrantPrivilegeReqV2(GrantPrivilegeReqV2Builder builder) { this.roleName = builder.roleName; this.privilege = builder.privilege; this.dbName = builder.dbName; @@ -66,28 +64,6 @@ public void setCollectionName(String collectionName) { this.collectionName = collectionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GrantPrivilegeReqV2 that = (GrantPrivilegeReqV2) obj; - return new EqualsBuilder() - .append(roleName, that.roleName) - .append(privilege, that.privilege) - .append(dbName, that.dbName) - .append(collectionName, that.collectionName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = roleName != null ? roleName.hashCode() : 0; - result = 31 * result + (privilege != null ? privilege.hashCode() : 0); - result = 31 * result + (dbName != null ? dbName.hashCode() : 0); - result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0); - return result; - } - @Override public String toString() { return "GrantPrivilegeReqV2{" + @@ -98,34 +74,35 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static GrantPrivilegeReqV2Builder builder() { + return new GrantPrivilegeReqV2Builder(); } - public static class Builder { + public static class GrantPrivilegeReqV2Builder { private String roleName; private String privilege; private String dbName; private String collectionName; - private Builder() {} + private GrantPrivilegeReqV2Builder() { + } - public Builder roleName(String roleName) { + public GrantPrivilegeReqV2Builder roleName(String roleName) { this.roleName = roleName; return this; } - public Builder privilege(String privilege) { + public GrantPrivilegeReqV2Builder privilege(String privilege) { this.privilege = privilege; return this; } - public Builder dbName(String dbName) { + public GrantPrivilegeReqV2Builder dbName(String dbName) { this.dbName = dbName; return this; } - public Builder collectionName(String collectionName) { + public GrantPrivilegeReqV2Builder collectionName(String collectionName) { this.collectionName = collectionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/GrantRoleReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/GrantRoleReq.java index 0ca68c3e6..ae282e9f8 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/GrantRoleReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/GrantRoleReq.java @@ -19,13 +19,11 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class GrantRoleReq { private String userName; private String roleName; - private GrantRoleReq(Builder builder) { + private GrantRoleReq(GrantRoleReqBuilder builder) { this.userName = builder.userName; this.roleName = builder.roleName; } @@ -46,24 +44,6 @@ public void setRoleName(String roleName) { this.roleName = roleName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GrantRoleReq that = (GrantRoleReq) obj; - return new EqualsBuilder() - .append(userName, that.userName) - .append(roleName, that.roleName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = userName != null ? userName.hashCode() : 0; - result = 31 * result + (roleName != null ? roleName.hashCode() : 0); - return result; - } - @Override public String toString() { return "GrantRoleReq{" + @@ -72,22 +52,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static GrantRoleReqBuilder builder() { + return new GrantRoleReqBuilder(); } - public static class Builder { + public static class GrantRoleReqBuilder { private String userName; private String roleName; - private Builder() {} + private GrantRoleReqBuilder() { + } - public Builder userName(String userName) { + public GrantRoleReqBuilder userName(String userName) { this.userName = userName; return this; } - public Builder roleName(String roleName) { + public GrantRoleReqBuilder roleName(String roleName) { this.roleName = roleName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/ListPrivilegeGroupsReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/ListPrivilegeGroupsReq.java index bd135eb8c..dadc35780 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/ListPrivilegeGroupsReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/ListPrivilegeGroupsReq.java @@ -19,27 +19,10 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; public class ListPrivilegeGroupsReq { - - private ListPrivilegeGroupsReq(Builder builder) { - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - return new EqualsBuilder() - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .toHashCode(); + private ListPrivilegeGroupsReq(ListPrivilegeGroupsReqBuilder builder) { } @Override @@ -48,13 +31,14 @@ public String toString() { .toString(); } - public static Builder builder() { - return new Builder(); + public static ListPrivilegeGroupsReqBuilder builder() { + return new ListPrivilegeGroupsReqBuilder(); } - public static class Builder { + public static class ListPrivilegeGroupsReqBuilder { - private Builder() {} + private ListPrivilegeGroupsReqBuilder() { + } public ListPrivilegeGroupsReq build() { return new ListPrivilegeGroupsReq(this); diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RemovePrivilegesFromGroupReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RemovePrivilegesFromGroupReq.java index 39004aec4..8d9d5b633 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RemovePrivilegesFromGroupReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RemovePrivilegesFromGroupReq.java @@ -19,8 +19,6 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.ArrayList; import java.util.List; @@ -28,7 +26,7 @@ public class RemovePrivilegesFromGroupReq { private String groupName; private List privileges = new ArrayList<>(); - private RemovePrivilegesFromGroupReq(Builder builder) { + private RemovePrivilegesFromGroupReq(RemovePrivilegesFromGroupReqBuilder builder) { this.groupName = builder.groupName; this.privileges = builder.privileges; } @@ -49,24 +47,6 @@ public void setPrivileges(List privileges) { this.privileges = privileges; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - RemovePrivilegesFromGroupReq that = (RemovePrivilegesFromGroupReq) obj; - return new EqualsBuilder() - .append(groupName, that.groupName) - .append(privileges, that.privileges) - .isEquals(); - } - - @Override - public int hashCode() { - int result = groupName != null ? groupName.hashCode() : 0; - result = 31 * result + (privileges != null ? privileges.hashCode() : 0); - return result; - } - @Override public String toString() { return "RemovePrivilegesFromGroupReq{" + @@ -75,22 +55,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static RemovePrivilegesFromGroupReqBuilder builder() { + return new RemovePrivilegesFromGroupReqBuilder(); } - public static class Builder { + public static class RemovePrivilegesFromGroupReqBuilder { private String groupName; private List privileges = new ArrayList<>(); - private Builder() {} + private RemovePrivilegesFromGroupReqBuilder() { + } - public Builder groupName(String groupName) { + public RemovePrivilegesFromGroupReqBuilder groupName(String groupName) { this.groupName = groupName; return this; } - public Builder privileges(List privileges) { + public RemovePrivilegesFromGroupReqBuilder privileges(List privileges) { this.privileges = privileges; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RevokePrivilegeReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RevokePrivilegeReq.java index bf040a6ee..1821acdbe 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RevokePrivilegeReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RevokePrivilegeReq.java @@ -19,8 +19,6 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class RevokePrivilegeReq { private String roleName; private String dbName; @@ -28,7 +26,7 @@ public class RevokePrivilegeReq { private String privilege; private String objectName; - private RevokePrivilegeReq(Builder builder) { + private RevokePrivilegeReq(RevokePrivilegeReqBuilder builder) { this.roleName = builder.roleName; this.dbName = builder.dbName; this.objectType = builder.objectType; @@ -76,30 +74,6 @@ public void setObjectName(String objectName) { this.objectName = objectName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - RevokePrivilegeReq that = (RevokePrivilegeReq) obj; - return new EqualsBuilder() - .append(roleName, that.roleName) - .append(dbName, that.dbName) - .append(objectType, that.objectType) - .append(privilege, that.privilege) - .append(objectName, that.objectName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = roleName != null ? roleName.hashCode() : 0; - result = 31 * result + (dbName != null ? dbName.hashCode() : 0); - result = 31 * result + (objectType != null ? objectType.hashCode() : 0); - result = 31 * result + (privilege != null ? privilege.hashCode() : 0); - result = 31 * result + (objectName != null ? objectName.hashCode() : 0); - return result; - } - @Override public String toString() { return "RevokePrivilegeReq{" + @@ -111,40 +85,41 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static RevokePrivilegeReqBuilder builder() { + return new RevokePrivilegeReqBuilder(); } - public static class Builder { + public static class RevokePrivilegeReqBuilder { private String roleName; private String dbName; private String objectType; private String privilege; private String objectName; - private Builder() {} + private RevokePrivilegeReqBuilder() { + } - public Builder roleName(String roleName) { + public RevokePrivilegeReqBuilder roleName(String roleName) { this.roleName = roleName; return this; } - public Builder dbName(String dbName) { + public RevokePrivilegeReqBuilder dbName(String dbName) { this.dbName = dbName; return this; } - public Builder objectType(String objectType) { + public RevokePrivilegeReqBuilder objectType(String objectType) { this.objectType = objectType; return this; } - public Builder privilege(String privilege) { + public RevokePrivilegeReqBuilder privilege(String privilege) { this.privilege = privilege; return this; } - public Builder objectName(String objectName) { + public RevokePrivilegeReqBuilder objectName(String objectName) { this.objectName = objectName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RevokePrivilegeReqV2.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RevokePrivilegeReqV2.java index b63e797d6..751acdaec 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RevokePrivilegeReqV2.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RevokePrivilegeReqV2.java @@ -19,15 +19,13 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class RevokePrivilegeReqV2 { private String roleName; private String privilege; private String dbName; private String collectionName; - private RevokePrivilegeReqV2(Builder builder) { + private RevokePrivilegeReqV2(RevokePrivilegeReqV2Builder builder) { this.roleName = builder.roleName; this.privilege = builder.privilege; this.dbName = builder.dbName; @@ -66,28 +64,6 @@ public void setCollectionName(String collectionName) { this.collectionName = collectionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - RevokePrivilegeReqV2 that = (RevokePrivilegeReqV2) obj; - return new EqualsBuilder() - .append(roleName, that.roleName) - .append(privilege, that.privilege) - .append(dbName, that.dbName) - .append(collectionName, that.collectionName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = roleName != null ? roleName.hashCode() : 0; - result = 31 * result + (privilege != null ? privilege.hashCode() : 0); - result = 31 * result + (dbName != null ? dbName.hashCode() : 0); - result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0); - return result; - } - @Override public String toString() { return "RevokePrivilegeReqV2{" + @@ -98,34 +74,35 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static RevokePrivilegeReqV2Builder builder() { + return new RevokePrivilegeReqV2Builder(); } - public static class Builder { + public static class RevokePrivilegeReqV2Builder { private String roleName; private String privilege; private String dbName; private String collectionName; - private Builder() {} + private RevokePrivilegeReqV2Builder() { + } - public Builder roleName(String roleName) { + public RevokePrivilegeReqV2Builder roleName(String roleName) { this.roleName = roleName; return this; } - public Builder privilege(String privilege) { + public RevokePrivilegeReqV2Builder privilege(String privilege) { this.privilege = privilege; return this; } - public Builder dbName(String dbName) { + public RevokePrivilegeReqV2Builder dbName(String dbName) { this.dbName = dbName; return this; } - public Builder collectionName(String collectionName) { + public RevokePrivilegeReqV2Builder collectionName(String collectionName) { this.collectionName = collectionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RevokeRoleReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RevokeRoleReq.java index 38f3b3d68..38f868c61 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RevokeRoleReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/RevokeRoleReq.java @@ -19,13 +19,11 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class RevokeRoleReq { private String userName; private String roleName; - private RevokeRoleReq(Builder builder) { + private RevokeRoleReq(RevokeRoleReqBuilder builder) { this.userName = builder.userName; this.roleName = builder.roleName; } @@ -46,24 +44,6 @@ public void setRoleName(String roleName) { this.roleName = roleName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - RevokeRoleReq that = (RevokeRoleReq) obj; - return new EqualsBuilder() - .append(userName, that.userName) - .append(roleName, that.roleName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = userName != null ? userName.hashCode() : 0; - result = 31 * result + (roleName != null ? roleName.hashCode() : 0); - return result; - } - @Override public String toString() { return "RevokeRoleReq{" + @@ -72,22 +52,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static RevokeRoleReqBuilder builder() { + return new RevokeRoleReqBuilder(); } - public static class Builder { + public static class RevokeRoleReqBuilder { private String userName; private String roleName; - private Builder() {} + private RevokeRoleReqBuilder() { + } - public Builder userName(String userName) { + public RevokeRoleReqBuilder userName(String userName) { this.userName = userName; return this; } - public Builder roleName(String roleName) { + public RevokeRoleReqBuilder roleName(String roleName) { this.roleName = roleName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/UpdatePasswordReq.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/UpdatePasswordReq.java index 3e400c004..8f9bc5c30 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/UpdatePasswordReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/request/UpdatePasswordReq.java @@ -19,14 +19,12 @@ package io.milvus.v2.service.rbac.request; -import org.apache.commons.lang3.builder.EqualsBuilder; - public class UpdatePasswordReq { private String userName; private String password; private String newPassword; - private UpdatePasswordReq(Builder builder) { + private UpdatePasswordReq(UpdatePasswordReqBuilder builder) { this.userName = builder.userName; this.password = builder.password; this.newPassword = builder.newPassword; @@ -56,26 +54,6 @@ public void setNewPassword(String newPassword) { this.newPassword = newPassword; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - UpdatePasswordReq that = (UpdatePasswordReq) obj; - return new EqualsBuilder() - .append(userName, that.userName) - .append(password, that.password) - .append(newPassword, that.newPassword) - .isEquals(); - } - - @Override - public int hashCode() { - int result = userName != null ? userName.hashCode() : 0; - result = 31 * result + (password != null ? password.hashCode() : 0); - result = 31 * result + (newPassword != null ? newPassword.hashCode() : 0); - return result; - } - @Override public String toString() { return "UpdatePasswordReq{" + @@ -85,28 +63,29 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static UpdatePasswordReqBuilder builder() { + return new UpdatePasswordReqBuilder(); } - public static class Builder { + public static class UpdatePasswordReqBuilder { private String userName; private String password; private String newPassword; - private Builder() {} + private UpdatePasswordReqBuilder() { + } - public Builder userName(String userName) { + public UpdatePasswordReqBuilder userName(String userName) { this.userName = userName; return this; } - public Builder password(String password) { + public UpdatePasswordReqBuilder password(String password) { this.password = password; return this; } - public Builder newPassword(String newPassword) { + public UpdatePasswordReqBuilder newPassword(String newPassword) { this.newPassword = newPassword; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/response/DescribeRoleResp.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/response/DescribeRoleResp.java index 8eac3f3e4..161034ced 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/response/DescribeRoleResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/response/DescribeRoleResp.java @@ -19,15 +19,13 @@ package io.milvus.v2.service.rbac.response; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.ArrayList; import java.util.List; public class DescribeRoleResp { private List grantInfos; - private DescribeRoleResp(Builder builder) { + private DescribeRoleResp(DescribeRoleRespBuilder builder) { this.grantInfos = builder.grantInfos; } @@ -39,21 +37,6 @@ public void setGrantInfos(List grantInfos) { this.grantInfos = grantInfos; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DescribeRoleResp that = (DescribeRoleResp) obj; - return new EqualsBuilder() - .append(grantInfos, that.grantInfos) - .isEquals(); - } - - @Override - public int hashCode() { - return grantInfos != null ? grantInfos.hashCode() : 0; - } - @Override public String toString() { return "DescribeRoleResp{" + @@ -61,16 +44,17 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DescribeRoleRespBuilder builder() { + return new DescribeRoleRespBuilder(); } - public static class Builder { + public static class DescribeRoleRespBuilder { private List grantInfos = new ArrayList<>(); - private Builder() {} + private DescribeRoleRespBuilder() { + } - public Builder grantInfos(List grantInfos) { + public DescribeRoleRespBuilder grantInfos(List grantInfos) { this.grantInfos = grantInfos; return this; } @@ -88,7 +72,7 @@ public static class GrantInfo { private String privilege; private String dbName; - private GrantInfo(Builder builder) { + private GrantInfo(GrantInfoBuilder builder) { this.objectType = builder.objectType; this.objectName = builder.objectName; this.roleName = builder.roleName; @@ -145,32 +129,6 @@ public void setDbName(String dbName) { this.dbName = dbName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GrantInfo grantInfo = (GrantInfo) obj; - return new EqualsBuilder() - .append(objectType, grantInfo.objectType) - .append(objectName, grantInfo.objectName) - .append(roleName, grantInfo.roleName) - .append(grantor, grantInfo.grantor) - .append(privilege, grantInfo.privilege) - .append(dbName, grantInfo.dbName) - .isEquals(); - } - - @Override - public int hashCode() { - int result = objectType != null ? objectType.hashCode() : 0; - result = 31 * result + (objectName != null ? objectName.hashCode() : 0); - result = 31 * result + (roleName != null ? roleName.hashCode() : 0); - result = 31 * result + (grantor != null ? grantor.hashCode() : 0); - result = 31 * result + (privilege != null ? privilege.hashCode() : 0); - result = 31 * result + (dbName != null ? dbName.hashCode() : 0); - return result; - } - @Override public String toString() { return "GrantInfo{" + @@ -183,11 +141,11 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static GrantInfoBuilder builder() { + return new GrantInfoBuilder(); } - public static class Builder { + public static class GrantInfoBuilder { private String objectType; private String objectName; private String roleName; @@ -195,34 +153,35 @@ public static class Builder { private String privilege; private String dbName; - private Builder() {} + private GrantInfoBuilder() { + } - public Builder objectType(String objectType) { + public GrantInfoBuilder objectType(String objectType) { this.objectType = objectType; return this; } - public Builder objectName(String objectName) { + public GrantInfoBuilder objectName(String objectName) { this.objectName = objectName; return this; } - public Builder roleName(String roleName) { + public GrantInfoBuilder roleName(String roleName) { this.roleName = roleName; return this; } - public Builder grantor(String grantor) { + public GrantInfoBuilder grantor(String grantor) { this.grantor = grantor; return this; } - public Builder privilege(String privilege) { + public GrantInfoBuilder privilege(String privilege) { this.privilege = privilege; return this; } - public Builder dbName(String dbName) { + public GrantInfoBuilder dbName(String dbName) { this.dbName = dbName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/response/DescribeUserResp.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/response/DescribeUserResp.java index 30cb066bd..6e3d2394e 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/response/DescribeUserResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/response/DescribeUserResp.java @@ -19,15 +19,13 @@ package io.milvus.v2.service.rbac.response; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.ArrayList; import java.util.List; public class DescribeUserResp { private List roles; - private DescribeUserResp(Builder builder) { + private DescribeUserResp(DescribeUserRespBuilder builder) { this.roles = builder.roles; } @@ -39,21 +37,6 @@ public void setRoles(List roles) { this.roles = roles; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DescribeUserResp that = (DescribeUserResp) obj; - return new EqualsBuilder() - .append(roles, that.roles) - .isEquals(); - } - - @Override - public int hashCode() { - return roles != null ? roles.hashCode() : 0; - } - @Override public String toString() { return "DescribeUserResp{" + @@ -61,16 +44,17 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static DescribeUserRespBuilder builder() { + return new DescribeUserRespBuilder(); } - public static class Builder { + public static class DescribeUserRespBuilder { private List roles = new ArrayList<>(); - private Builder() {} + private DescribeUserRespBuilder() { + } - public Builder roles(List roles) { + public DescribeUserRespBuilder roles(List roles) { this.roles = roles; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/rbac/response/ListPrivilegeGroupsResp.java b/sdk-core/src/main/java/io/milvus/v2/service/rbac/response/ListPrivilegeGroupsResp.java index 769030824..448a28960 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/rbac/response/ListPrivilegeGroupsResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/rbac/response/ListPrivilegeGroupsResp.java @@ -20,7 +20,6 @@ package io.milvus.v2.service.rbac.response; import io.milvus.v2.service.rbac.PrivilegeGroup; -import org.apache.commons.lang3.builder.EqualsBuilder; import java.util.ArrayList; import java.util.List; @@ -28,7 +27,7 @@ public class ListPrivilegeGroupsResp { private List privilegeGroups; - private ListPrivilegeGroupsResp(Builder builder) { + private ListPrivilegeGroupsResp(ListPrivilegeGroupsRespBuilder builder) { this.privilegeGroups = builder.privilegeGroups; } @@ -40,21 +39,6 @@ public void setPrivilegeGroups(List privilegeGroups) { this.privilegeGroups = privilegeGroups; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ListPrivilegeGroupsResp that = (ListPrivilegeGroupsResp) obj; - return new EqualsBuilder() - .append(privilegeGroups, that.privilegeGroups) - .isEquals(); - } - - @Override - public int hashCode() { - return privilegeGroups != null ? privilegeGroups.hashCode() : 0; - } - @Override public String toString() { return "ListPrivilegeGroupsResp{" + @@ -62,16 +46,17 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static ListPrivilegeGroupsRespBuilder builder() { + return new ListPrivilegeGroupsRespBuilder(); } - public static class Builder { + public static class ListPrivilegeGroupsRespBuilder { private List privilegeGroups = new ArrayList<>(); - private Builder() {} + private ListPrivilegeGroupsRespBuilder() { + } - public Builder privilegeGroups(List privilegeGroups) { + public ListPrivilegeGroupsRespBuilder privilegeGroups(List privilegeGroups) { this.privilegeGroups = privilegeGroups; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/ResourceGroupService.java b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/ResourceGroupService.java index 575b3da19..7fb5faeb7 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/ResourceGroupService.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/ResourceGroupService.java @@ -5,7 +5,8 @@ import io.milvus.v2.exception.MilvusClientException; import io.milvus.v2.service.BaseService; import io.milvus.v2.service.resourcegroup.request.*; -import io.milvus.v2.service.resourcegroup.response.*; +import io.milvus.v2.service.resourcegroup.response.DescribeResourceGroupResp; +import io.milvus.v2.service.resourcegroup.response.ListResourceGroupsResp; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; @@ -20,21 +21,21 @@ private static ResourceGroupConfig convertResourceGroupConfig(io.milvus.common.r ResourceGroupConfig.Builder builder = ResourceGroupConfig.newBuilder(); builder.setRequests(ResourceGroupLimit.newBuilder() - .setNodeNum(config.getRequests().getNodeNum())) + .setNodeNum(config.getRequests().getNodeNum())) .build(); builder.setLimits(ResourceGroupLimit.newBuilder() - .setNodeNum(config.getLimits().getNodeNum())) + .setNodeNum(config.getLimits().getNodeNum())) .build(); for (io.milvus.common.resourcegroup.ResourceGroupTransfer groupFrom : config.getFrom()) { builder.addTransferFrom(ResourceGroupTransfer.newBuilder() - .setResourceGroup(groupFrom.getResourceGroupName())) + .setResourceGroup(groupFrom.getResourceGroupName())) .build(); } for (io.milvus.common.resourcegroup.ResourceGroupTransfer groupTo : config.getTo()) { builder.addTransferTo(ResourceGroupTransfer.newBuilder() - .setResourceGroup(groupTo.getResourceGroupName())) + .setResourceGroup(groupTo.getResourceGroupName())) .build(); } @@ -47,12 +48,12 @@ private static ResourceGroupConfig convertResourceGroupConfig(io.milvus.common.r private static io.milvus.common.resourcegroup.ResourceGroupConfig convertResourceGroupConfig(ResourceGroupConfig config) { List fromList = new ArrayList<>(); - config.getTransferFromList().forEach((groupFrom)->{ + config.getTransferFromList().forEach((groupFrom) -> { fromList.add(new io.milvus.common.resourcegroup.ResourceGroupTransfer(groupFrom.getResourceGroup())); }); List toList = new ArrayList<>(); - config.getTransferToList().forEach((groupTo)->{ + config.getTransferToList().forEach((groupTo) -> { toList.add(new io.milvus.common.resourcegroup.ResourceGroupTransfer(groupTo.getResourceGroup())); }); @@ -132,7 +133,7 @@ public DescribeResourceGroupResp describeResourceGroup(MilvusServiceGrpc.MilvusS ResourceGroup rgroup = response.getResourceGroup(); List nodes = new ArrayList<>(); - rgroup.getNodesList().forEach((node)->{ + rgroup.getNodesList().forEach((node) -> { nodes.add(io.milvus.common.resourcegroup.NodeInfo.builder() .nodeId(node.getNodeId()) .address(node.getAddress()) diff --git a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/CreateResourceGroupReq.java b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/CreateResourceGroupReq.java index b349323b9..0fe156c98 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/CreateResourceGroupReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/CreateResourceGroupReq.java @@ -1,20 +1,18 @@ package io.milvus.v2.service.resourcegroup.request; import io.milvus.common.resourcegroup.ResourceGroupConfig; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; public class CreateResourceGroupReq { private String groupName; private ResourceGroupConfig config; - private CreateResourceGroupReq(Builder builder) { + private CreateResourceGroupReq(CreateResourceGroupReqBuilder builder) { this.groupName = builder.groupName; this.config = builder.config; } - public static Builder builder() { - return new Builder(); + public static CreateResourceGroupReqBuilder builder() { + return new CreateResourceGroupReqBuilder(); } public String getGroupName() { @@ -33,25 +31,6 @@ public void setConfig(ResourceGroupConfig config) { this.config = config; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - CreateResourceGroupReq that = (CreateResourceGroupReq) obj; - return new EqualsBuilder() - .append(groupName, that.groupName) - .append(config, that.config) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(groupName) - .append(config) - .toHashCode(); - } - @Override public String toString() { return "CreateResourceGroupReq{" + @@ -60,16 +39,16 @@ public String toString() { '}'; } - public static class Builder { + public static class CreateResourceGroupReqBuilder { private String groupName; private ResourceGroupConfig config; - public Builder groupName(String groupName) { + public CreateResourceGroupReqBuilder groupName(String groupName) { this.groupName = groupName; return this; } - public Builder config(ResourceGroupConfig config) { + public CreateResourceGroupReqBuilder config(ResourceGroupConfig config) { this.config = config; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/DescribeResourceGroupReq.java b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/DescribeResourceGroupReq.java index 57301fc90..d46dbd032 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/DescribeResourceGroupReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/DescribeResourceGroupReq.java @@ -1,17 +1,14 @@ package io.milvus.v2.service.resourcegroup.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class DescribeResourceGroupReq { private String groupName; - private DescribeResourceGroupReq(Builder builder) { + private DescribeResourceGroupReq(DescribeResourceGroupReqBuilder builder) { this.groupName = builder.groupName; } - public static Builder builder() { - return new Builder(); + public static DescribeResourceGroupReqBuilder builder() { + return new DescribeResourceGroupReqBuilder(); } public String getGroupName() { @@ -22,23 +19,6 @@ public void setGroupName(String groupName) { this.groupName = groupName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DescribeResourceGroupReq that = (DescribeResourceGroupReq) obj; - return new EqualsBuilder() - .append(groupName, that.groupName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(groupName) - .toHashCode(); - } - @Override public String toString() { return "DescribeResourceGroupReq{" + @@ -46,10 +26,10 @@ public String toString() { '}'; } - public static class Builder { + public static class DescribeResourceGroupReqBuilder { private String groupName; - public Builder groupName(String groupName) { + public DescribeResourceGroupReqBuilder groupName(String groupName) { this.groupName = groupName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/DropResourceGroupReq.java b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/DropResourceGroupReq.java index 6030d16c6..315bde44d 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/DropResourceGroupReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/DropResourceGroupReq.java @@ -1,17 +1,14 @@ package io.milvus.v2.service.resourcegroup.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class DropResourceGroupReq { private String groupName; - private DropResourceGroupReq(Builder builder) { + private DropResourceGroupReq(DropResourceGroupReqBuilder builder) { this.groupName = builder.groupName; } - public static Builder builder() { - return new Builder(); + public static DropResourceGroupReqBuilder builder() { + return new DropResourceGroupReqBuilder(); } public String getGroupName() { @@ -22,23 +19,6 @@ public void setGroupName(String groupName) { this.groupName = groupName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DropResourceGroupReq that = (DropResourceGroupReq) obj; - return new EqualsBuilder() - .append(groupName, that.groupName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(groupName) - .toHashCode(); - } - @Override public String toString() { return "DropResourceGroupReq{" + @@ -46,10 +26,10 @@ public String toString() { '}'; } - public static class Builder { + public static class DropResourceGroupReqBuilder { private String groupName; - public Builder groupName(String groupName) { + public DropResourceGroupReqBuilder groupName(String groupName) { this.groupName = groupName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/ListResourceGroupsReq.java b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/ListResourceGroupsReq.java index af04b1237..20245d752 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/ListResourceGroupsReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/ListResourceGroupsReq.java @@ -1,28 +1,13 @@ package io.milvus.v2.service.resourcegroup.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class ListResourceGroupsReq { - private ListResourceGroupsReq(Builder builder) { + private ListResourceGroupsReq(ListResourceGroupsReqBuilder builder) { // No fields to initialize } - public static Builder builder() { - return new Builder(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - return new EqualsBuilder().isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37).toHashCode(); + public static ListResourceGroupsReqBuilder builder() { + return new ListResourceGroupsReqBuilder(); } @Override @@ -30,7 +15,7 @@ public String toString() { return "ListResourceGroupsReq{}"; } - public static class Builder { + public static class ListResourceGroupsReqBuilder { public ListResourceGroupsReq build() { return new ListResourceGroupsReq(this); diff --git a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/TransferNodeReq.java b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/TransferNodeReq.java index 245110cc2..a59cde251 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/TransferNodeReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/TransferNodeReq.java @@ -1,21 +1,18 @@ package io.milvus.v2.service.resourcegroup.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class TransferNodeReq { private String sourceGroupName; private String targetGroupName; private Integer numOfNodes; - private TransferNodeReq(Builder builder) { + private TransferNodeReq(TransferNodeReqBuilder builder) { this.sourceGroupName = builder.sourceGroupName; this.targetGroupName = builder.targetGroupName; this.numOfNodes = builder.numOfNodes; } - public static Builder builder() { - return new Builder(); + public static TransferNodeReqBuilder builder() { + return new TransferNodeReqBuilder(); } public String getSourceGroupName() { @@ -42,27 +39,6 @@ public void setNumOfNodes(Integer numOfNodes) { this.numOfNodes = numOfNodes; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - TransferNodeReq that = (TransferNodeReq) obj; - return new EqualsBuilder() - .append(sourceGroupName, that.sourceGroupName) - .append(targetGroupName, that.targetGroupName) - .append(numOfNodes, that.numOfNodes) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(sourceGroupName) - .append(targetGroupName) - .append(numOfNodes) - .toHashCode(); - } - @Override public String toString() { return "TransferNodeReq{" + @@ -72,22 +48,22 @@ public String toString() { '}'; } - public static class Builder { + public static class TransferNodeReqBuilder { private String sourceGroupName; private String targetGroupName; private Integer numOfNodes; - public Builder sourceGroupName(String sourceGroupName) { + public TransferNodeReqBuilder sourceGroupName(String sourceGroupName) { this.sourceGroupName = sourceGroupName; return this; } - public Builder targetGroupName(String targetGroupName) { + public TransferNodeReqBuilder targetGroupName(String targetGroupName) { this.targetGroupName = targetGroupName; return this; } - public Builder numOfNodes(Integer numOfNodes) { + public TransferNodeReqBuilder numOfNodes(Integer numOfNodes) { this.numOfNodes = numOfNodes; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/TransferReplicaReq.java b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/TransferReplicaReq.java index 5a6030919..c24944120 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/TransferReplicaReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/TransferReplicaReq.java @@ -1,8 +1,5 @@ package io.milvus.v2.service.resourcegroup.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class TransferReplicaReq { private String sourceGroupName; private String targetGroupName; @@ -10,7 +7,7 @@ public class TransferReplicaReq { private String databaseName; private Long numberOfReplicas; - private TransferReplicaReq(Builder builder) { + private TransferReplicaReq(TransferReplicaReqBuilder builder) { this.sourceGroupName = builder.sourceGroupName; this.targetGroupName = builder.targetGroupName; this.collectionName = builder.collectionName; @@ -18,8 +15,8 @@ private TransferReplicaReq(Builder builder) { this.numberOfReplicas = builder.numberOfReplicas; } - public static Builder builder() { - return new Builder(); + public static TransferReplicaReqBuilder builder() { + return new TransferReplicaReqBuilder(); } public String getSourceGroupName() { @@ -62,31 +59,6 @@ public void setNumberOfReplicas(Long numberOfReplicas) { this.numberOfReplicas = numberOfReplicas; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - TransferReplicaReq that = (TransferReplicaReq) obj; - return new EqualsBuilder() - .append(sourceGroupName, that.sourceGroupName) - .append(targetGroupName, that.targetGroupName) - .append(collectionName, that.collectionName) - .append(databaseName, that.databaseName) - .append(numberOfReplicas, that.numberOfReplicas) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(sourceGroupName) - .append(targetGroupName) - .append(collectionName) - .append(databaseName) - .append(numberOfReplicas) - .toHashCode(); - } - @Override public String toString() { return "TransferReplicaReq{" + @@ -98,34 +70,34 @@ public String toString() { '}'; } - public static class Builder { + public static class TransferReplicaReqBuilder { private String sourceGroupName; private String targetGroupName; private String collectionName; private String databaseName; private Long numberOfReplicas; - public Builder sourceGroupName(String sourceGroupName) { + public TransferReplicaReqBuilder sourceGroupName(String sourceGroupName) { this.sourceGroupName = sourceGroupName; return this; } - public Builder targetGroupName(String targetGroupName) { + public TransferReplicaReqBuilder targetGroupName(String targetGroupName) { this.targetGroupName = targetGroupName; return this; } - public Builder collectionName(String collectionName) { + public TransferReplicaReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder databaseName(String databaseName) { + public TransferReplicaReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder numberOfReplicas(Long numberOfReplicas) { + public TransferReplicaReqBuilder numberOfReplicas(Long numberOfReplicas) { this.numberOfReplicas = numberOfReplicas; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/UpdateResourceGroupsReq.java b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/UpdateResourceGroupsReq.java index 186efe49c..dcd57792c 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/UpdateResourceGroupsReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/request/UpdateResourceGroupsReq.java @@ -1,8 +1,6 @@ package io.milvus.v2.service.resourcegroup.request; import io.milvus.common.resourcegroup.ResourceGroupConfig; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.HashMap; import java.util.Map; @@ -10,12 +8,12 @@ public class UpdateResourceGroupsReq { private Map resourceGroups; - private UpdateResourceGroupsReq(Builder builder) { + private UpdateResourceGroupsReq(UpdateResourceGroupsReqBuilder builder) { this.resourceGroups = builder.resourceGroups; } - public static Builder builder() { - return new Builder(); + public static UpdateResourceGroupsReqBuilder builder() { + return new UpdateResourceGroupsReqBuilder(); } public Map getResourceGroups() { @@ -26,23 +24,6 @@ public void setResourceGroups(Map resourceGroups) { this.resourceGroups = resourceGroups; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - UpdateResourceGroupsReq that = (UpdateResourceGroupsReq) obj; - return new EqualsBuilder() - .append(resourceGroups, that.resourceGroups) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(resourceGroups) - .toHashCode(); - } - @Override public String toString() { return "UpdateResourceGroupsReq{" + @@ -50,10 +31,10 @@ public String toString() { '}'; } - public static class Builder { + public static class UpdateResourceGroupsReqBuilder { private Map resourceGroups = new HashMap<>(); - public Builder resourceGroups(Map resourceGroups) { + public UpdateResourceGroupsReqBuilder resourceGroups(Map resourceGroups) { this.resourceGroups = resourceGroups; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/response/DescribeResourceGroupResp.java b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/response/DescribeResourceGroupResp.java index 3f206682d..20e7ad562 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/response/DescribeResourceGroupResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/response/DescribeResourceGroupResp.java @@ -2,10 +2,11 @@ import io.milvus.common.resourcegroup.NodeInfo; import io.milvus.common.resourcegroup.ResourceGroupConfig; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class DescribeResourceGroupResp { private String groupName; @@ -17,7 +18,7 @@ public class DescribeResourceGroupResp { private ResourceGroupConfig config; private List nodes; - private DescribeResourceGroupResp(Builder builder) { + private DescribeResourceGroupResp(DescribeResourceGroupRespBuilder builder) { this.groupName = builder.groupName; this.capacity = builder.capacity; this.numberOfAvailableNode = builder.numberOfAvailableNode; @@ -28,8 +29,8 @@ private DescribeResourceGroupResp(Builder builder) { this.nodes = builder.nodes; } - public static Builder builder() { - return new Builder(); + public static DescribeResourceGroupRespBuilder builder() { + return new DescribeResourceGroupRespBuilder(); } public String getGroupName() { @@ -96,37 +97,6 @@ public void setNodes(List nodes) { this.nodes = nodes; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DescribeResourceGroupResp that = (DescribeResourceGroupResp) obj; - return new EqualsBuilder() - .append(groupName, that.groupName) - .append(capacity, that.capacity) - .append(numberOfAvailableNode, that.numberOfAvailableNode) - .append(numberOfLoadedReplica, that.numberOfLoadedReplica) - .append(numberOfOutgoingNode, that.numberOfOutgoingNode) - .append(numberOfIncomingNode, that.numberOfIncomingNode) - .append(config, that.config) - .append(nodes, that.nodes) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(groupName) - .append(capacity) - .append(numberOfAvailableNode) - .append(numberOfLoadedReplica) - .append(numberOfOutgoingNode) - .append(numberOfIncomingNode) - .append(config) - .append(nodes) - .toHashCode(); - } - @Override public String toString() { return "DescribeResourceGroupResp{" + @@ -141,7 +111,7 @@ public String toString() { '}'; } - public static class Builder { + public static class DescribeResourceGroupRespBuilder { private String groupName; private Integer capacity; private Integer numberOfAvailableNode; @@ -151,42 +121,42 @@ public static class Builder { private Map numberOfIncomingNode = new HashMap<>(); private List nodes = new ArrayList<>(); - public Builder groupName(String groupName) { + public DescribeResourceGroupRespBuilder groupName(String groupName) { this.groupName = groupName; return this; } - public Builder capacity(Integer capacity) { + public DescribeResourceGroupRespBuilder capacity(Integer capacity) { this.capacity = capacity; return this; } - public Builder numberOfAvailableNode(Integer numberOfAvailableNode) { + public DescribeResourceGroupRespBuilder numberOfAvailableNode(Integer numberOfAvailableNode) { this.numberOfAvailableNode = numberOfAvailableNode; return this; } - public Builder numberOfLoadedReplica(Map numberOfLoadedReplica) { + public DescribeResourceGroupRespBuilder numberOfLoadedReplica(Map numberOfLoadedReplica) { this.numberOfLoadedReplica = numberOfLoadedReplica; return this; } - public Builder numberOfOutgoingNode(Map numberOfOutgoingNode) { + public DescribeResourceGroupRespBuilder numberOfOutgoingNode(Map numberOfOutgoingNode) { this.numberOfOutgoingNode = numberOfOutgoingNode; return this; } - public Builder numberOfIncomingNode(Map numberOfIncomingNode) { + public DescribeResourceGroupRespBuilder numberOfIncomingNode(Map numberOfIncomingNode) { this.numberOfIncomingNode = numberOfIncomingNode; return this; } - public Builder config(ResourceGroupConfig config) { + public DescribeResourceGroupRespBuilder config(ResourceGroupConfig config) { this.config = config; return this; } - public Builder nodes(List nodes) { + public DescribeResourceGroupRespBuilder nodes(List nodes) { this.nodes = nodes; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/response/ListResourceGroupsResp.java b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/response/ListResourceGroupsResp.java index 18735dad8..93c3a84b1 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/response/ListResourceGroupsResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/resourcegroup/response/ListResourceGroupsResp.java @@ -1,20 +1,17 @@ package io.milvus.v2.service.resourcegroup.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.ArrayList; import java.util.List; public class ListResourceGroupsResp { private List groupNames; - private ListResourceGroupsResp(Builder builder) { + private ListResourceGroupsResp(ListResourceGroupsRespBuilder builder) { this.groupNames = builder.groupNames; } - public static Builder builder() { - return new Builder(); + public static ListResourceGroupsRespBuilder builder() { + return new ListResourceGroupsRespBuilder(); } public List getGroupNames() { @@ -25,23 +22,6 @@ public void setGroupNames(List groupNames) { this.groupNames = groupNames; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ListResourceGroupsResp that = (ListResourceGroupsResp) obj; - return new EqualsBuilder() - .append(groupNames, that.groupNames) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(groupNames) - .toHashCode(); - } - @Override public String toString() { return "ListResourceGroupsResp{" + @@ -49,10 +29,10 @@ public String toString() { '}'; } - public static class Builder { + public static class ListResourceGroupsRespBuilder { private List groupNames = new ArrayList<>(); - public Builder groupNames(List groupNames) { + public ListResourceGroupsRespBuilder groupNames(List groupNames) { this.groupNames = groupNames; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/UtilityService.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/UtilityService.java index c6ad07c95..e016a8d4e 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/UtilityService.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/UtilityService.java @@ -28,7 +28,10 @@ import io.milvus.v2.service.utility.response.*; import org.apache.commons.lang3.StringUtils; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; public class UtilityService extends BaseService { @@ -51,7 +54,7 @@ public FlushResp flush(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, Map rpcCollSegIDs = response.getCollSegIDsMap(); Map> collectionSegmentIDs = new HashMap<>(); - rpcCollSegIDs.forEach((key, value)->{ + rpcCollSegIDs.forEach((key, value) -> { collectionSegmentIDs.put(key, value.getDataList()); }); Map collectionFlushTs = response.getCollFlushTsMap(); @@ -66,7 +69,7 @@ public FlushResp flush(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, public Void waitFlush(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, FlushResp flushResp) { Map> collectionSegmentIDs = flushResp.getCollectionSegmentIDs(); Map collectionFlushTs = flushResp.getCollectionFlushTs(); - collectionSegmentIDs.forEach((collectionName, segmentIDs)->{ + collectionSegmentIDs.forEach((collectionName, segmentIDs) -> { if (collectionFlushTs.containsKey(collectionName)) { Long flushTs = collectionFlushTs.get(collectionName); boolean flushed = false; @@ -223,7 +226,7 @@ public CheckHealthResp checkHealth(MilvusServiceGrpc.MilvusServiceBlockingStub b rpcUtils.handleResponse(title, response.getStatus()); List states = new ArrayList<>(); - response.getQuotaStatesList().forEach(s->states.add(s.name())); + response.getQuotaStatesList().forEach(s -> states.add(s.name())); return CheckHealthResp.builder() .isHealthy(response.getIsHealthy()) .reasons(response.getReasonsList().stream().collect(Collectors.toList())) @@ -232,7 +235,7 @@ public CheckHealthResp checkHealth(MilvusServiceGrpc.MilvusServiceBlockingStub b } public GetPersistentSegmentInfoResp getPersistentSegmentInfo(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, - GetPersistentSegmentInfoReq request) { + GetPersistentSegmentInfoReq request) { String dbName = request.getDatabaseName(); String collectionName = request.getCollectionName(); String title = String.format("Get persistent segment info in collection: '%s' in database: '%s'", collectionName, dbName); @@ -245,15 +248,17 @@ public GetPersistentSegmentInfoResp getPersistentSegmentInfo(MilvusServiceGrpc.M rpcUtils.handleResponse(title, response.getStatus()); List segmentInfos = new ArrayList<>(); - response.getInfosList().forEach(info->{segmentInfos.add(GetPersistentSegmentInfoResp.PersistentSegmentInfo.builder() - .segmentID(info.getSegmentID()) - .collectionID(info.getCollectionID()) - .partitionID(info.getPartitionID()) - .numOfRows(info.getNumRows()) - .state(info.getState().name()) - .level(info.getLevel().name()) - .isSorted(info.getIsSorted()) - .build());}); + response.getInfosList().forEach(info -> { + segmentInfos.add(GetPersistentSegmentInfoResp.PersistentSegmentInfo.builder() + .segmentID(info.getSegmentID()) + .collectionID(info.getCollectionID()) + .partitionID(info.getPartitionID()) + .numOfRows(info.getNumRows()) + .state(info.getState().name()) + .level(info.getLevel().name()) + .isSorted(info.getIsSorted()) + .build()); + }); return GetPersistentSegmentInfoResp.builder() .segmentInfos(segmentInfos) .build(); @@ -273,19 +278,21 @@ public GetQuerySegmentInfoResp getQuerySegmentInfo(MilvusServiceGrpc.MilvusServi rpcUtils.handleResponse(title, response.getStatus()); List segmentInfos = new ArrayList<>(); - response.getInfosList().forEach(info->{segmentInfos.add(GetQuerySegmentInfoResp.QuerySegmentInfo.builder() - .segmentID(info.getSegmentID()) - .collectionID(info.getCollectionID()) - .partitionID(info.getPartitionID()) - .memSize(info.getMemSize()) - .numOfRows(info.getNumRows()) - .indexName(info.getIndexName()) - .indexID(info.getIndexID()) - .state(info.getState().name()) - .level(info.getLevel().name()) - .nodeIDs(info.getNodeIdsList()) - .isSorted(info.getIsSorted()) - .build());}); + response.getInfosList().forEach(info -> { + segmentInfos.add(GetQuerySegmentInfoResp.QuerySegmentInfo.builder() + .segmentID(info.getSegmentID()) + .collectionID(info.getCollectionID()) + .partitionID(info.getPartitionID()) + .memSize(info.getMemSize()) + .numOfRows(info.getNumRows()) + .indexName(info.getIndexName()) + .indexID(info.getIndexID()) + .state(info.getState().name()) + .level(info.getLevel().name()) + .nodeIDs(info.getNodeIdsList()) + .isSorted(info.getIsSorted()) + .build()); + }); return GetQuerySegmentInfoResp.builder() .segmentInfos(segmentInfos) .build(); diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/AlterAliasReq.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/AlterAliasReq.java index 4c774ef3b..e39583c07 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/AlterAliasReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/AlterAliasReq.java @@ -19,22 +19,19 @@ package io.milvus.v2.service.utility.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class AlterAliasReq { private String databaseName; private String collectionName; private String alias; - private AlterAliasReq(Builder builder) { + private AlterAliasReq(AlterAliasReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.alias = builder.alias; } - public static Builder builder() { - return new Builder(); + public static AlterAliasReqBuilder builder() { + return new AlterAliasReqBuilder(); } public String getDatabaseName() { @@ -61,27 +58,6 @@ public void setAlias(String alias) { this.alias = alias; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AlterAliasReq that = (AlterAliasReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(alias, that.alias) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(alias) - .toHashCode(); - } - @Override public String toString() { return "AlterAliasReq{" + @@ -91,22 +67,22 @@ public String toString() { '}'; } - public static class Builder { + public static class AlterAliasReqBuilder { private String databaseName; private String collectionName; private String alias; - public Builder databaseName(String databaseName) { + public AlterAliasReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public AlterAliasReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder alias(String alias) { + public AlterAliasReqBuilder alias(String alias) { this.alias = alias; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/CompactReq.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/CompactReq.java index 58d80786d..d1c3be133 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/CompactReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/CompactReq.java @@ -19,22 +19,19 @@ package io.milvus.v2.service.utility.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class CompactReq { private String databaseName; private String collectionName; private Boolean isClustering = Boolean.FALSE; - private CompactReq(Builder builder) { + private CompactReq(CompactReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.isClustering = builder.isClustering; } - public static Builder builder() { - return new Builder(); + public static CompactReqBuilder builder() { + return new CompactReqBuilder(); } public String getDatabaseName() { @@ -61,27 +58,6 @@ public void setIsClustering(Boolean isClustering) { this.isClustering = isClustering; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - CompactReq that = (CompactReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(isClustering, that.isClustering) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(isClustering) - .toHashCode(); - } - @Override public String toString() { return "CompactReq{" + @@ -91,22 +67,22 @@ public String toString() { '}'; } - public static class Builder { + public static class CompactReqBuilder { private String databaseName; private String collectionName; private Boolean isClustering = Boolean.FALSE; - public Builder databaseName(String databaseName) { + public CompactReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public CompactReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder isClustering(Boolean isClustering) { + public CompactReqBuilder isClustering(Boolean isClustering) { this.isClustering = isClustering; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/CreateAliasReq.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/CreateAliasReq.java index c1a25ebf1..0795b5f68 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/CreateAliasReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/CreateAliasReq.java @@ -19,22 +19,19 @@ package io.milvus.v2.service.utility.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class CreateAliasReq { private String databaseName; private String collectionName; private String alias; - private CreateAliasReq(Builder builder) { + private CreateAliasReq(CreateAliasReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.alias = builder.alias; } - public static Builder builder() { - return new Builder(); + public static CreateAliasReqBuilder builder() { + return new CreateAliasReqBuilder(); } public String getDatabaseName() { @@ -61,27 +58,6 @@ public void setAlias(String alias) { this.alias = alias; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - CreateAliasReq that = (CreateAliasReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(alias, that.alias) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(alias) - .toHashCode(); - } - @Override public String toString() { return "CreateAliasReq{" + @@ -91,22 +67,22 @@ public String toString() { '}'; } - public static class Builder { + public static class CreateAliasReqBuilder { private String databaseName; private String collectionName; private String alias; - public Builder databaseName(String databaseName) { + public CreateAliasReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public CreateAliasReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder alias(String alias) { + public CreateAliasReqBuilder alias(String alias) { this.alias = alias; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/DescribeAliasReq.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/DescribeAliasReq.java index 37b54d479..da3633432 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/DescribeAliasReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/DescribeAliasReq.java @@ -19,20 +19,17 @@ package io.milvus.v2.service.utility.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class DescribeAliasReq { private String databaseName; private String alias; - private DescribeAliasReq(Builder builder) { + private DescribeAliasReq(DescribeAliasReqBuilder builder) { this.databaseName = builder.databaseName; this.alias = builder.alias; } - public static Builder builder() { - return new Builder(); + public static DescribeAliasReqBuilder builder() { + return new DescribeAliasReqBuilder(); } public String getDatabaseName() { @@ -51,25 +48,6 @@ public void setAlias(String alias) { this.alias = alias; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DescribeAliasReq that = (DescribeAliasReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(alias, that.alias) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(alias) - .toHashCode(); - } - @Override public String toString() { return "DescribeAliasReq{" + @@ -78,16 +56,16 @@ public String toString() { '}'; } - public static class Builder { + public static class DescribeAliasReqBuilder { private String databaseName; private String alias; - public Builder databaseName(String databaseName) { + public DescribeAliasReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder alias(String alias) { + public DescribeAliasReqBuilder alias(String alias) { this.alias = alias; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/DropAliasReq.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/DropAliasReq.java index 675239550..8afa6e7e9 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/DropAliasReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/DropAliasReq.java @@ -19,20 +19,17 @@ package io.milvus.v2.service.utility.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class DropAliasReq { private String databaseName; private String alias; - private DropAliasReq(Builder builder) { + private DropAliasReq(DropAliasReqBuilder builder) { this.databaseName = builder.databaseName; this.alias = builder.alias; } - public static Builder builder() { - return new Builder(); + public static DropAliasReqBuilder builder() { + return new DropAliasReqBuilder(); } public String getDatabaseName() { @@ -51,25 +48,6 @@ public void setAlias(String alias) { this.alias = alias; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DropAliasReq that = (DropAliasReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(alias, that.alias) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(alias) - .toHashCode(); - } - @Override public String toString() { return "DropAliasReq{" + @@ -78,16 +56,16 @@ public String toString() { '}'; } - public static class Builder { + public static class DropAliasReqBuilder { private String databaseName; private String alias; - public Builder databaseName(String databaseName) { + public DropAliasReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder alias(String alias) { + public DropAliasReqBuilder alias(String alias) { this.alias = alias; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/FlushReq.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/FlushReq.java index 17f442629..4a3591d90 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/FlushReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/FlushReq.java @@ -19,9 +19,6 @@ package io.milvus.v2.service.utility.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.ArrayList; import java.util.List; @@ -30,14 +27,14 @@ public class FlushReq { private List collectionNames; private Long waitFlushedTimeoutMs; // 0 - waiting util flush task is done - private FlushReq(Builder builder) { + private FlushReq(FlushReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionNames = builder.collectionNames; this.waitFlushedTimeoutMs = builder.waitFlushedTimeoutMs; } - public static Builder builder() { - return new Builder(); + public static FlushReqBuilder builder() { + return new FlushReqBuilder(); } public String getDatabaseName() { @@ -64,27 +61,6 @@ public void setWaitFlushedTimeoutMs(Long waitFlushedTimeoutMs) { this.waitFlushedTimeoutMs = waitFlushedTimeoutMs; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - FlushReq that = (FlushReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionNames, that.collectionNames) - .append(waitFlushedTimeoutMs, that.waitFlushedTimeoutMs) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionNames) - .append(waitFlushedTimeoutMs) - .toHashCode(); - } - @Override public String toString() { return "FlushReq{" + @@ -94,22 +70,22 @@ public String toString() { '}'; } - public static class Builder { + public static class FlushReqBuilder { private String databaseName; private List collectionNames = new ArrayList<>(); private Long waitFlushedTimeoutMs = 0L; // 0 - waiting util flush task is done - public Builder databaseName(String databaseName) { + public FlushReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionNames(List collectionNames) { + public FlushReqBuilder collectionNames(List collectionNames) { this.collectionNames = collectionNames; return this; } - public Builder waitFlushedTimeoutMs(Long waitFlushedTimeoutMs) { + public FlushReqBuilder waitFlushedTimeoutMs(Long waitFlushedTimeoutMs) { this.waitFlushedTimeoutMs = waitFlushedTimeoutMs; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/GetCompactionStateReq.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/GetCompactionStateReq.java index e35d05520..52677acc9 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/GetCompactionStateReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/GetCompactionStateReq.java @@ -19,18 +19,15 @@ package io.milvus.v2.service.utility.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class GetCompactionStateReq { private Long compactionID; - private GetCompactionStateReq(Builder builder) { + private GetCompactionStateReq(GetCompactionStateReqBuilder builder) { this.compactionID = builder.compactionID; } - public static Builder builder() { - return new Builder(); + public static GetCompactionStateReqBuilder builder() { + return new GetCompactionStateReqBuilder(); } public Long getCompactionID() { @@ -41,23 +38,6 @@ public void setCompactionID(Long compactionID) { this.compactionID = compactionID; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GetCompactionStateReq that = (GetCompactionStateReq) obj; - return new EqualsBuilder() - .append(compactionID, that.compactionID) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(compactionID) - .toHashCode(); - } - @Override public String toString() { return "GetCompactionStateReq{" + @@ -65,10 +45,10 @@ public String toString() { '}'; } - public static class Builder { + public static class GetCompactionStateReqBuilder { private Long compactionID; - public Builder compactionID(Long compactionID) { + public GetCompactionStateReqBuilder compactionID(Long compactionID) { this.compactionID = compactionID; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/GetPersistentSegmentInfoReq.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/GetPersistentSegmentInfoReq.java index 3ad6ea4d7..f8820fcc0 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/GetPersistentSegmentInfoReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/GetPersistentSegmentInfoReq.java @@ -1,19 +1,16 @@ package io.milvus.v2.service.utility.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class GetPersistentSegmentInfoReq { private String databaseName; private String collectionName; - private GetPersistentSegmentInfoReq(Builder builder) { + private GetPersistentSegmentInfoReq(GetPersistentSegmentInfoReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; } - public static Builder builder() { - return new Builder(); + public static GetPersistentSegmentInfoReqBuilder builder() { + return new GetPersistentSegmentInfoReqBuilder(); } public String getDatabaseName() { @@ -32,25 +29,6 @@ public void setCollectionName(String collectionName) { this.collectionName = collectionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GetPersistentSegmentInfoReq that = (GetPersistentSegmentInfoReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .toHashCode(); - } - @Override public String toString() { return "GetPersistentSegmentInfoReq{" + @@ -59,16 +37,16 @@ public String toString() { '}'; } - public static class Builder { + public static class GetPersistentSegmentInfoReqBuilder { private String databaseName; private String collectionName; - public Builder databaseName(String databaseName) { + public GetPersistentSegmentInfoReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public GetPersistentSegmentInfoReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/GetQuerySegmentInfoReq.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/GetQuerySegmentInfoReq.java index 1253b2b5b..0732185cf 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/GetQuerySegmentInfoReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/GetQuerySegmentInfoReq.java @@ -1,19 +1,16 @@ package io.milvus.v2.service.utility.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class GetQuerySegmentInfoReq { private String databaseName; private String collectionName; - private GetQuerySegmentInfoReq(Builder builder) { + private GetQuerySegmentInfoReq(GetQuerySegmentInfoReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; } - public static Builder builder() { - return new Builder(); + public static GetQuerySegmentInfoReqBuilder builder() { + return new GetQuerySegmentInfoReqBuilder(); } public String getDatabaseName() { @@ -32,25 +29,6 @@ public void setCollectionName(String collectionName) { this.collectionName = collectionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GetQuerySegmentInfoReq that = (GetQuerySegmentInfoReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .toHashCode(); - } - @Override public String toString() { return "GetQuerySegmentInfoReq{" + @@ -59,16 +37,16 @@ public String toString() { '}'; } - public static class Builder { + public static class GetQuerySegmentInfoReqBuilder { private String databaseName; private String collectionName; - public Builder databaseName(String databaseName) { + public GetQuerySegmentInfoReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public GetQuerySegmentInfoReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/ListAliasesReq.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/ListAliasesReq.java index 7546bf64f..1a67ee371 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/request/ListAliasesReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/request/ListAliasesReq.java @@ -19,20 +19,17 @@ package io.milvus.v2.service.utility.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class ListAliasesReq { private String databaseName; private String collectionName; - private ListAliasesReq(Builder builder) { + private ListAliasesReq(ListAliasesReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; } - public static Builder builder() { - return new Builder(); + public static ListAliasesReqBuilder builder() { + return new ListAliasesReqBuilder(); } public String getDatabaseName() { @@ -51,25 +48,6 @@ public void setCollectionName(String collectionName) { this.collectionName = collectionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ListAliasesReq that = (ListAliasesReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .toHashCode(); - } - @Override public String toString() { return "ListAliasesReq{" + @@ -78,16 +56,16 @@ public String toString() { '}'; } - public static class Builder { + public static class ListAliasesReqBuilder { private String databaseName; private String collectionName; - public Builder databaseName(String databaseName) { + public ListAliasesReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public ListAliasesReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/CheckHealthResp.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/CheckHealthResp.java index 066afd60f..8cd67f83e 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/CheckHealthResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/CheckHealthResp.java @@ -1,8 +1,5 @@ package io.milvus.v2.service.utility.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.ArrayList; import java.util.List; @@ -11,14 +8,14 @@ public class CheckHealthResp { private List reasons; private List quotaStates; - private CheckHealthResp(Builder builder) { + private CheckHealthResp(CheckHealthRespBuilder builder) { this.isHealthy = builder.isHealthy; this.reasons = builder.reasons; this.quotaStates = builder.quotaStates; } - public static Builder builder() { - return new Builder(); + public static CheckHealthRespBuilder builder() { + return new CheckHealthRespBuilder(); } public Boolean getIsHealthy() { @@ -45,27 +42,6 @@ public void setQuotaStates(List quotaStates) { this.quotaStates = quotaStates; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - CheckHealthResp that = (CheckHealthResp) obj; - return new EqualsBuilder() - .append(isHealthy, that.isHealthy) - .append(reasons, that.reasons) - .append(quotaStates, that.quotaStates) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(isHealthy) - .append(reasons) - .append(quotaStates) - .toHashCode(); - } - @Override public String toString() { return "CheckHealthResp{" + @@ -75,22 +51,22 @@ public String toString() { '}'; } - public static class Builder { + public static class CheckHealthRespBuilder { private Boolean isHealthy = false; private List reasons = new ArrayList<>(); private List quotaStates = new ArrayList<>(); - public Builder isHealthy(Boolean isHealthy) { + public CheckHealthRespBuilder isHealthy(Boolean isHealthy) { this.isHealthy = isHealthy; return this; } - public Builder reasons(List reasons) { + public CheckHealthRespBuilder reasons(List reasons) { this.reasons = reasons; return this; } - public Builder quotaStates(List quotaStates) { + public CheckHealthRespBuilder quotaStates(List quotaStates) { this.quotaStates = quotaStates; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/CompactResp.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/CompactResp.java index b91c014bc..a9a0f7d02 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/CompactResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/CompactResp.java @@ -19,18 +19,15 @@ package io.milvus.v2.service.utility.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class CompactResp { private Long compactionID; - private CompactResp(Builder builder) { + private CompactResp(CompactRespBuilder builder) { this.compactionID = builder.compactionID; } - public static Builder builder() { - return new Builder(); + public static CompactRespBuilder builder() { + return new CompactRespBuilder(); } public Long getCompactionID() { @@ -41,23 +38,6 @@ public void setCompactionID(Long compactionID) { this.compactionID = compactionID; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - CompactResp that = (CompactResp) obj; - return new EqualsBuilder() - .append(compactionID, that.compactionID) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(compactionID) - .toHashCode(); - } - @Override public String toString() { return "CompactResp{" + @@ -65,10 +45,10 @@ public String toString() { '}'; } - public static class Builder { + public static class CompactRespBuilder { private Long compactionID = 0L; - public Builder compactionID(Long compactionID) { + public CompactRespBuilder compactionID(Long compactionID) { this.compactionID = compactionID; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/DescribeAliasResp.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/DescribeAliasResp.java index 5544c6f42..84654d829 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/DescribeAliasResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/DescribeAliasResp.java @@ -19,22 +19,19 @@ package io.milvus.v2.service.utility.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class DescribeAliasResp { private String databaseName; private String collectionName; private String alias; - private DescribeAliasResp(Builder builder) { + private DescribeAliasResp(DescribeAliasRespBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.alias = builder.alias; } - public static Builder builder() { - return new Builder(); + public static DescribeAliasRespBuilder builder() { + return new DescribeAliasRespBuilder(); } public String getDatabaseName() { @@ -61,27 +58,6 @@ public void setAlias(String alias) { this.alias = alias; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DescribeAliasResp that = (DescribeAliasResp) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(alias, that.alias) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(alias) - .toHashCode(); - } - @Override public String toString() { return "DescribeAliasResp{" + @@ -91,22 +67,22 @@ public String toString() { '}'; } - public static class Builder { + public static class DescribeAliasRespBuilder { private String databaseName; private String collectionName; private String alias; - public Builder databaseName(String databaseName) { + public DescribeAliasRespBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public DescribeAliasRespBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder alias(String alias) { + public DescribeAliasRespBuilder alias(String alias) { this.alias = alias; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/FlushResp.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/FlushResp.java index 2acf300db..c0a957a3a 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/FlushResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/FlushResp.java @@ -19,24 +19,23 @@ package io.milvus.v2.service.utility.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class FlushResp { private String databaseName; private Map> collectionSegmentIDs; private Map collectionFlushTs; - private FlushResp(Builder builder) { + private FlushResp(FlushRespBuilder builder) { this.databaseName = builder.databaseName; this.collectionSegmentIDs = builder.collectionSegmentIDs; this.collectionFlushTs = builder.collectionFlushTs; } - public static Builder builder() { - return new Builder(); + public static FlushRespBuilder builder() { + return new FlushRespBuilder(); } public String getDatabaseName() { @@ -63,27 +62,6 @@ public void setCollectionFlushTs(Map collectionFlushTs) { this.collectionFlushTs = collectionFlushTs; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - FlushResp that = (FlushResp) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionSegmentIDs, that.collectionSegmentIDs) - .append(collectionFlushTs, that.collectionFlushTs) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionSegmentIDs) - .append(collectionFlushTs) - .toHashCode(); - } - @Override public String toString() { return "FlushResp{" + @@ -93,22 +71,22 @@ public String toString() { '}'; } - public static class Builder { + public static class FlushRespBuilder { private String databaseName = ""; private Map> collectionSegmentIDs = new HashMap<>(); private Map collectionFlushTs = new HashMap<>(); - public Builder databaseName(String databaseName) { + public FlushRespBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionSegmentIDs(Map> collectionSegmentIDs) { + public FlushRespBuilder collectionSegmentIDs(Map> collectionSegmentIDs) { this.collectionSegmentIDs = collectionSegmentIDs; return this; } - public Builder collectionFlushTs(Map collectionFlushTs) { + public FlushRespBuilder collectionFlushTs(Map collectionFlushTs) { this.collectionFlushTs = collectionFlushTs; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/GetCompactionStateResp.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/GetCompactionStateResp.java index dc99f05e2..79e4d8070 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/GetCompactionStateResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/GetCompactionStateResp.java @@ -20,8 +20,6 @@ package io.milvus.v2.service.utility.response; import io.milvus.v2.common.CompactionState; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; public class GetCompactionStateResp { private CompactionState state; @@ -29,15 +27,15 @@ public class GetCompactionStateResp { private Long timeoutPlanNo; private Long completedPlanNo; - private GetCompactionStateResp(Builder builder) { + private GetCompactionStateResp(GetCompactionStateRespBuilder builder) { this.state = builder.state; this.executingPlanNo = builder.executingPlanNo; this.timeoutPlanNo = builder.timeoutPlanNo; this.completedPlanNo = builder.completedPlanNo; } - public static Builder builder() { - return new Builder(); + public static GetCompactionStateRespBuilder builder() { + return new GetCompactionStateRespBuilder(); } public CompactionState getState() { @@ -72,29 +70,6 @@ public void setCompletedPlanNo(Long completedPlanNo) { this.completedPlanNo = completedPlanNo; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GetCompactionStateResp that = (GetCompactionStateResp) obj; - return new EqualsBuilder() - .append(state, that.state) - .append(executingPlanNo, that.executingPlanNo) - .append(timeoutPlanNo, that.timeoutPlanNo) - .append(completedPlanNo, that.completedPlanNo) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(state) - .append(executingPlanNo) - .append(timeoutPlanNo) - .append(completedPlanNo) - .toHashCode(); - } - @Override public String toString() { return "GetCompactionStateResp{" + @@ -105,28 +80,28 @@ public String toString() { '}'; } - public static class Builder { + public static class GetCompactionStateRespBuilder { private CompactionState state = CompactionState.UndefiedState; private Long executingPlanNo = 0L; private Long timeoutPlanNo = 0L; private Long completedPlanNo = 0L; - public Builder state(CompactionState state) { + public GetCompactionStateRespBuilder state(CompactionState state) { this.state = state; return this; } - public Builder executingPlanNo(Long executingPlanNo) { + public GetCompactionStateRespBuilder executingPlanNo(Long executingPlanNo) { this.executingPlanNo = executingPlanNo; return this; } - public Builder timeoutPlanNo(Long timeoutPlanNo) { + public GetCompactionStateRespBuilder timeoutPlanNo(Long timeoutPlanNo) { this.timeoutPlanNo = timeoutPlanNo; return this; } - public Builder completedPlanNo(Long completedPlanNo) { + public GetCompactionStateRespBuilder completedPlanNo(Long completedPlanNo) { this.completedPlanNo = completedPlanNo; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/GetPersistentSegmentInfoResp.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/GetPersistentSegmentInfoResp.java index 0533474d4..e77f19836 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/GetPersistentSegmentInfoResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/GetPersistentSegmentInfoResp.java @@ -1,8 +1,5 @@ package io.milvus.v2.service.utility.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.ArrayList; import java.util.List; @@ -16,7 +13,7 @@ public static class PersistentSegmentInfo { private String level; private Boolean isSorted; - private PersistentSegmentInfo(Builder builder) { + private PersistentSegmentInfo(PersistentSegmentInfoBuilder builder) { this.segmentID = builder.segmentID; this.collectionID = builder.collectionID; this.partitionID = builder.partitionID; @@ -26,8 +23,8 @@ private PersistentSegmentInfo(Builder builder) { this.isSorted = builder.isSorted; } - public static Builder builder() { - return new Builder(); + public static PersistentSegmentInfoBuilder builder() { + return new PersistentSegmentInfoBuilder(); } public Long getSegmentID() { @@ -86,35 +83,6 @@ public void setIsSorted(Boolean isSorted) { this.isSorted = isSorted; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - PersistentSegmentInfo that = (PersistentSegmentInfo) obj; - return new EqualsBuilder() - .append(segmentID, that.segmentID) - .append(collectionID, that.collectionID) - .append(partitionID, that.partitionID) - .append(numOfRows, that.numOfRows) - .append(state, that.state) - .append(level, that.level) - .append(isSorted, that.isSorted) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(segmentID) - .append(collectionID) - .append(partitionID) - .append(numOfRows) - .append(state) - .append(level) - .append(isSorted) - .toHashCode(); - } - @Override public String toString() { return "PersistentSegmentInfo{" + @@ -128,7 +96,7 @@ public String toString() { '}'; } - public static class Builder { + public static class PersistentSegmentInfoBuilder { private Long segmentID; private Long collectionID; private Long partitionID; @@ -137,37 +105,37 @@ public static class Builder { private String level; private Boolean isSorted; - public Builder segmentID(Long segmentID) { + public PersistentSegmentInfoBuilder segmentID(Long segmentID) { this.segmentID = segmentID; return this; } - public Builder collectionID(Long collectionID) { + public PersistentSegmentInfoBuilder collectionID(Long collectionID) { this.collectionID = collectionID; return this; } - public Builder partitionID(Long partitionID) { + public PersistentSegmentInfoBuilder partitionID(Long partitionID) { this.partitionID = partitionID; return this; } - public Builder numOfRows(Long numOfRows) { + public PersistentSegmentInfoBuilder numOfRows(Long numOfRows) { this.numOfRows = numOfRows; return this; } - public Builder state(String state) { + public PersistentSegmentInfoBuilder state(String state) { this.state = state; return this; } - public Builder level(String level) { + public PersistentSegmentInfoBuilder level(String level) { this.level = level; return this; } - public Builder isSorted(Boolean isSorted) { + public PersistentSegmentInfoBuilder isSorted(Boolean isSorted) { this.isSorted = isSorted; return this; } @@ -180,12 +148,12 @@ public PersistentSegmentInfo build() { private List segmentInfos; - private GetPersistentSegmentInfoResp(Builder builder) { + private GetPersistentSegmentInfoResp(GetPersistentSegmentInfoRespBuilder builder) { this.segmentInfos = builder.segmentInfos; } - public static Builder builder() { - return new Builder(); + public static GetPersistentSegmentInfoRespBuilder builder() { + return new GetPersistentSegmentInfoRespBuilder(); } public List getSegmentInfos() { @@ -196,23 +164,6 @@ public void setSegmentInfos(List segmentInfos) { this.segmentInfos = segmentInfos; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GetPersistentSegmentInfoResp that = (GetPersistentSegmentInfoResp) obj; - return new EqualsBuilder() - .append(segmentInfos, that.segmentInfos) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(segmentInfos) - .toHashCode(); - } - @Override public String toString() { return "GetPersistentSegmentInfoResp{" + @@ -220,10 +171,10 @@ public String toString() { '}'; } - public static class Builder { + public static class GetPersistentSegmentInfoRespBuilder { private List segmentInfos = new ArrayList<>(); - public Builder segmentInfos(List segmentInfos) { + public GetPersistentSegmentInfoRespBuilder segmentInfos(List segmentInfos) { this.segmentInfos = segmentInfos; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/GetQuerySegmentInfoResp.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/GetQuerySegmentInfoResp.java index b2cd27825..06e8dc2d8 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/GetQuerySegmentInfoResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/GetQuerySegmentInfoResp.java @@ -1,8 +1,5 @@ package io.milvus.v2.service.utility.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.ArrayList; import java.util.List; @@ -20,7 +17,7 @@ public static class QuerySegmentInfo { private List nodeIDs; private Boolean isSorted; - private QuerySegmentInfo(Builder builder) { + private QuerySegmentInfo(QuerySegmentInfoBuilder builder) { this.segmentID = builder.segmentID; this.collectionID = builder.collectionID; this.partitionID = builder.partitionID; @@ -34,8 +31,8 @@ private QuerySegmentInfo(Builder builder) { this.isSorted = builder.isSorted; } - public static Builder builder() { - return new Builder(); + public static QuerySegmentInfoBuilder builder() { + return new QuerySegmentInfoBuilder(); } public Long getSegmentID() { @@ -126,43 +123,6 @@ public void setIsSorted(Boolean isSorted) { this.isSorted = isSorted; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - QuerySegmentInfo that = (QuerySegmentInfo) obj; - return new EqualsBuilder() - .append(segmentID, that.segmentID) - .append(collectionID, that.collectionID) - .append(partitionID, that.partitionID) - .append(memSize, that.memSize) - .append(numOfRows, that.numOfRows) - .append(indexName, that.indexName) - .append(indexID, that.indexID) - .append(state, that.state) - .append(level, that.level) - .append(nodeIDs, that.nodeIDs) - .append(isSorted, that.isSorted) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(segmentID) - .append(collectionID) - .append(partitionID) - .append(memSize) - .append(numOfRows) - .append(indexName) - .append(indexID) - .append(state) - .append(level) - .append(nodeIDs) - .append(isSorted) - .toHashCode(); - } - @Override public String toString() { return "QuerySegmentInfo{" + @@ -180,7 +140,7 @@ public String toString() { '}'; } - public static class Builder { + public static class QuerySegmentInfoBuilder { private Long segmentID; private Long collectionID; private Long partitionID; @@ -193,57 +153,57 @@ public static class Builder { private List nodeIDs = new ArrayList<>(); private Boolean isSorted; - public Builder segmentID(Long segmentID) { + public QuerySegmentInfoBuilder segmentID(Long segmentID) { this.segmentID = segmentID; return this; } - public Builder collectionID(Long collectionID) { + public QuerySegmentInfoBuilder collectionID(Long collectionID) { this.collectionID = collectionID; return this; } - public Builder partitionID(Long partitionID) { + public QuerySegmentInfoBuilder partitionID(Long partitionID) { this.partitionID = partitionID; return this; } - public Builder memSize(Long memSize) { + public QuerySegmentInfoBuilder memSize(Long memSize) { this.memSize = memSize; return this; } - public Builder numOfRows(Long numOfRows) { + public QuerySegmentInfoBuilder numOfRows(Long numOfRows) { this.numOfRows = numOfRows; return this; } - public Builder indexName(String indexName) { + public QuerySegmentInfoBuilder indexName(String indexName) { this.indexName = indexName; return this; } - public Builder indexID(Long indexID) { + public QuerySegmentInfoBuilder indexID(Long indexID) { this.indexID = indexID; return this; } - public Builder state(String state) { + public QuerySegmentInfoBuilder state(String state) { this.state = state; return this; } - public Builder level(String level) { + public QuerySegmentInfoBuilder level(String level) { this.level = level; return this; } - public Builder nodeIDs(List nodeIDs) { + public QuerySegmentInfoBuilder nodeIDs(List nodeIDs) { this.nodeIDs = nodeIDs; return this; } - public Builder isSorted(Boolean isSorted) { + public QuerySegmentInfoBuilder isSorted(Boolean isSorted) { this.isSorted = isSorted; return this; } @@ -256,12 +216,12 @@ public QuerySegmentInfo build() { private List segmentInfos; - private GetQuerySegmentInfoResp(Builder builder) { + private GetQuerySegmentInfoResp(GetQuerySegmentInfoRespBuilder builder) { this.segmentInfos = builder.segmentInfos; } - public static Builder builder() { - return new Builder(); + public static GetQuerySegmentInfoRespBuilder builder() { + return new GetQuerySegmentInfoRespBuilder(); } public List getSegmentInfos() { @@ -272,23 +232,6 @@ public void setSegmentInfos(List segmentInfos) { this.segmentInfos = segmentInfos; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GetQuerySegmentInfoResp that = (GetQuerySegmentInfoResp) obj; - return new EqualsBuilder() - .append(segmentInfos, that.segmentInfos) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(segmentInfos) - .toHashCode(); - } - @Override public String toString() { return "GetQuerySegmentInfoResp{" + @@ -296,10 +239,10 @@ public String toString() { '}'; } - public static class Builder { + public static class GetQuerySegmentInfoRespBuilder { private List segmentInfos = new ArrayList<>(); - public Builder segmentInfos(List segmentInfos) { + public GetQuerySegmentInfoRespBuilder segmentInfos(List segmentInfos) { this.segmentInfos = segmentInfos; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/ListAliasResp.java b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/ListAliasResp.java index 8d880bfc3..952687763 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/utility/response/ListAliasResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/utility/response/ListAliasResp.java @@ -19,22 +19,19 @@ package io.milvus.v2.service.utility.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.List; public class ListAliasResp { private String collectionName; private List alias; - private ListAliasResp(Builder builder) { + private ListAliasResp(ListAliasRespBuilder builder) { this.collectionName = builder.collectionName; this.alias = builder.alias; } - public static Builder builder() { - return new Builder(); + public static ListAliasRespBuilder builder() { + return new ListAliasRespBuilder(); } public String getCollectionName() { @@ -53,25 +50,6 @@ public void setAlias(List alias) { this.alias = alias; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ListAliasResp that = (ListAliasResp) obj; - return new EqualsBuilder() - .append(collectionName, that.collectionName) - .append(alias, that.alias) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(collectionName) - .append(alias) - .toHashCode(); - } - @Override public String toString() { return "ListAliasResp{" + @@ -80,16 +58,16 @@ public String toString() { '}'; } - public static class Builder { + public static class ListAliasRespBuilder { private String collectionName; private List alias; - public Builder collectionName(String collectionName) { + public ListAliasRespBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder alias(List alias) { + public ListAliasRespBuilder alias(List alias) { this.alias = alias; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/VectorService.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/VectorService.java index ee28abb12..7836cffc1 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/VectorService.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/VectorService.java @@ -23,7 +23,9 @@ import io.milvus.common.utils.GTsDict; import io.milvus.common.utils.JsonUtils; import io.milvus.grpc.*; -import io.milvus.orm.iterator.*; +import io.milvus.orm.iterator.QueryIterator; +import io.milvus.orm.iterator.SearchIterator; +import io.milvus.orm.iterator.SearchIteratorV2; import io.milvus.v2.exception.ErrorCode; import io.milvus.v2.exception.MilvusClientException; import io.milvus.v2.service.BaseService; @@ -290,7 +292,7 @@ public SearchResp hybridSearch(MilvusServiceGrpc.MilvusServiceBlockingStub block } public QueryIterator queryIterator(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, - QueryIteratorReq request) { + QueryIteratorReq request) { DescribeCollectionResponse descResp = getCollectionInfo(blockingStub, request.getDatabaseName(), request.getCollectionName(), false); DescribeCollectionResp respR = convertUtils.convertDescCollectionResp(descResp); @@ -299,7 +301,7 @@ public QueryIterator queryIterator(MilvusServiceGrpc.MilvusServiceBlockingStub b } public SearchIterator searchIterator(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, - SearchIteratorReq request) { + SearchIteratorReq request) { DescribeCollectionResponse descResp = getCollectionInfo(blockingStub, request.getDatabaseName(), request.getCollectionName(), false); DescribeCollectionResp respR = convertUtils.convertDescCollectionResp(descResp); @@ -393,10 +395,10 @@ public RunAnalyzerResp runAnalyzer(MilvusServiceGrpc.MilvusServiceBlockingStub b List toResults = new ArrayList<>(); List results = response.getResultsList(); - results.forEach((item)->{ + results.forEach((item) -> { List toTokens = new ArrayList<>(); List tokens = item.getTokensList(); - tokens.forEach((token)->{ + tokens.forEach((token) -> { toTokens.add(RunAnalyzerResp.AnalyzerToken.builder() .token(token.getToken()) .startOffset(token.getStartOffset()) diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/AnnSearchReq.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/AnnSearchReq.java index 5e89311c5..99a0eb912 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/AnnSearchReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/AnnSearchReq.java @@ -21,8 +21,6 @@ import io.milvus.v2.common.IndexParam; import io.milvus.v2.service.vector.request.data.BaseVector; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.List; @@ -38,7 +36,7 @@ public class AnnSearchReq { private String params; private IndexParam.MetricType metricType; - private AnnSearchReq(Builder builder) { + private AnnSearchReq(AnnSearchReqBuilder builder) { this.vectorFieldName = builder.vectorFieldName; this.topK = builder.topK; this.limit = builder.limit; @@ -49,8 +47,8 @@ private AnnSearchReq(Builder builder) { this.metricType = builder.metricType; } - public static Builder builder() { - return new Builder(); + public static AnnSearchReqBuilder builder() { + return new AnnSearchReqBuilder(); } public String getVectorFieldName() { @@ -125,37 +123,6 @@ public void setMetricType(IndexParam.MetricType metricType) { this.metricType = metricType; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AnnSearchReq that = (AnnSearchReq) obj; - return new EqualsBuilder() - .append(topK, that.topK) - .append(limit, that.limit) - .append(vectorFieldName, that.vectorFieldName) - .append(expr, that.expr) - .append(filter, that.filter) - .append(vectors, that.vectors) - .append(params, that.params) - .append(metricType, that.metricType) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(vectorFieldName) - .append(topK) - .append(limit) - .append(expr) - .append(filter) - .append(vectors) - .append(params) - .append(metricType) - .toHashCode(); - } - @Override public String toString() { return "AnnSearchReq{" + @@ -170,7 +137,7 @@ public String toString() { '}'; } - public static class Builder { + public static class AnnSearchReqBuilder { private String vectorFieldName; private int topK = 0; private long limit = 0L; @@ -180,20 +147,20 @@ public static class Builder { private String params; private IndexParam.MetricType metricType = null; - public Builder vectorFieldName(String vectorFieldName) { + public AnnSearchReqBuilder vectorFieldName(String vectorFieldName) { this.vectorFieldName = vectorFieldName; return this; } // topK is deprecated replaced by limit, topK and limit must be the same value @Deprecated - public Builder topK(int val) { + public AnnSearchReqBuilder topK(int val) { this.topK = val; this.limit = val; return this; } - public Builder limit(long val) { + public AnnSearchReqBuilder limit(long val) { this.topK = (int) val; this.limit = val; return this; @@ -201,29 +168,29 @@ public Builder limit(long val) { // expr is deprecated replaced by filter, expr and filter must be the same value @Deprecated - public Builder expr(String val) { + public AnnSearchReqBuilder expr(String val) { this.expr = val; this.filter = val; return this; } - public Builder filter(String val) { + public AnnSearchReqBuilder filter(String val) { this.expr = val; this.filter = val; return this; } - public Builder vectors(List vectors) { + public AnnSearchReqBuilder vectors(List vectors) { this.vectors = vectors; return this; } - public Builder params(String params) { + public AnnSearchReqBuilder params(String params) { this.params = params; return this; } - public Builder metricType(IndexParam.MetricType metricType) { + public AnnSearchReqBuilder metricType(IndexParam.MetricType metricType) { this.metricType = metricType; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/DeleteReq.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/DeleteReq.java index 9fcb80da7..3a70876b2 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/DeleteReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/DeleteReq.java @@ -19,9 +19,6 @@ package io.milvus.v2.service.vector.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.HashMap; import java.util.List; import java.util.Map; @@ -43,7 +40,7 @@ public class DeleteReq { // Boolean, Long, Double, String, List, List, List, List private Map filterTemplateValues; - private DeleteReq(Builder builder) { + private DeleteReq(DeleteReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionName = builder.partitionName; @@ -52,8 +49,8 @@ private DeleteReq(Builder builder) { this.filterTemplateValues = builder.filterTemplateValues; } - public static Builder builder() { - return new Builder(); + public static DeleteReqBuilder builder() { + return new DeleteReqBuilder(); } public String getDatabaseName() { @@ -104,33 +101,6 @@ public void setFilterTemplateValues(Map filterTemplateValues) { this.filterTemplateValues = filterTemplateValues; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DeleteReq that = (DeleteReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(partitionName, that.partitionName) - .append(filter, that.filter) - .append(ids, that.ids) - .append(filterTemplateValues, that.filterTemplateValues) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(partitionName) - .append(filter) - .append(ids) - .append(filterTemplateValues) - .toHashCode(); - } - @Override public String toString() { return "DeleteReq{" + @@ -143,7 +113,7 @@ public String toString() { '}'; } - public static class Builder { + public static class DeleteReqBuilder { private String databaseName = ""; private String collectionName; private String partitionName = ""; @@ -151,32 +121,32 @@ public static class Builder { private List ids; private Map filterTemplateValues = new HashMap<>(); - public Builder databaseName(String databaseName) { + public DeleteReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public DeleteReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionName(String partitionName) { + public DeleteReqBuilder partitionName(String partitionName) { this.partitionName = partitionName; return this; } - public Builder filter(String filter) { + public DeleteReqBuilder filter(String filter) { this.filter = filter; return this; } - public Builder ids(List ids) { + public DeleteReqBuilder ids(List ids) { this.ids = ids; return this; } - public Builder filterTemplateValues(Map filterTemplateValues) { + public DeleteReqBuilder filterTemplateValues(Map filterTemplateValues) { this.filterTemplateValues = filterTemplateValues; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/FunctionScore.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/FunctionScore.java index f63bddc1a..46a983696 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/FunctionScore.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/FunctionScore.java @@ -20,8 +20,6 @@ package io.milvus.v2.service.vector.request; import io.milvus.v2.service.collection.request.CreateCollectionReq; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.ArrayList; import java.util.HashMap; @@ -33,14 +31,14 @@ public class FunctionScore { private Map params; // Private constructor for builder - private FunctionScore(Builder builder) { + private FunctionScore(FunctionScoreBuilder builder) { this.functions = builder.functions != null ? builder.functions : new ArrayList<>(); this.params = builder.params != null ? builder.params : new HashMap<>(); } // Static method to create builder - public static Builder builder() { - return new Builder(); + public static FunctionScoreBuilder builder() { + return new FunctionScoreBuilder(); } // Getter methods @@ -61,27 +59,6 @@ public void setParams(Map params) { this.params = params; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - FunctionScore that = (FunctionScore) o; - - return new EqualsBuilder() - .append(functions, that.functions) - .append(params, that.params) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(functions) - .append(params) - .toHashCode(); - } - @Override public String toString() { return "FunctionScore{" + @@ -91,26 +68,26 @@ public String toString() { } // Builder class - public static class Builder { + public static class FunctionScoreBuilder { private List functions; private Map params; - public Builder() { + public FunctionScoreBuilder() { this.functions = new ArrayList<>(); this.params = new HashMap<>(); } - public Builder functions(List functions) { + public FunctionScoreBuilder functions(List functions) { this.functions = functions; return this; } - public Builder params(Map params) { + public FunctionScoreBuilder params(Map params) { this.params = params; return this; } - public Builder addFunction(CreateCollectionReq.Function func) { + public FunctionScoreBuilder addFunction(CreateCollectionReq.Function func) { if (this.functions == null) { this.functions = new ArrayList<>(); } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/GetReq.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/GetReq.java index fa53d2b39..8657ab630 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/GetReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/GetReq.java @@ -19,9 +19,6 @@ package io.milvus.v2.service.vector.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.List; public class GetReq { @@ -31,7 +28,7 @@ public class GetReq { private List ids; private List outputFields; - private GetReq(Builder builder) { + private GetReq(GetReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionName = builder.partitionName; @@ -39,8 +36,8 @@ private GetReq(Builder builder) { this.outputFields = builder.outputFields; } - public static Builder builder() { - return new Builder(); + public static GetReqBuilder builder() { + return new GetReqBuilder(); } public String getDatabaseName() { @@ -83,31 +80,6 @@ public void setOutputFields(List outputFields) { this.outputFields = outputFields; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GetReq that = (GetReq) obj; - return new EqualsBuilder() - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(partitionName, that.partitionName) - .append(ids, that.ids) - .append(outputFields, that.outputFields) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(partitionName) - .append(ids) - .append(outputFields) - .toHashCode(); - } - @Override public String toString() { return "GetReq{" + @@ -119,34 +91,34 @@ public String toString() { '}'; } - public static class Builder { + public static class GetReqBuilder { private String databaseName; private String collectionName; private String partitionName = ""; private List ids; private List outputFields; - public Builder databaseName(String databaseName) { + public GetReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public GetReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionName(String partitionName) { + public GetReqBuilder partitionName(String partitionName) { this.partitionName = partitionName; return this; } - public Builder ids(List ids) { + public GetReqBuilder ids(List ids) { this.ids = ids; return this; } - public Builder outputFields(List outputFields) { + public GetReqBuilder outputFields(List outputFields) { this.outputFields = outputFields; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/HybridSearchReq.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/HybridSearchReq.java index e931f892a..5d038380b 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/HybridSearchReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/HybridSearchReq.java @@ -21,7 +21,6 @@ import io.milvus.v2.common.ConsistencyLevel; import io.milvus.v2.service.collection.request.CreateCollectionReq; -import org.apache.commons.lang3.builder.EqualsBuilder; import java.util.List; @@ -46,7 +45,7 @@ public class HybridSearchReq { // to use functionScore even you have only one ranker. Not allow to set both. private FunctionScore functionScore; - private HybridSearchReq(Builder builder) { + private HybridSearchReq(HybridSearchReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionNames = builder.partitionNames; @@ -187,50 +186,6 @@ public void setStrictGroupSize(Boolean strictGroupSize) { this.strictGroupSize = strictGroupSize; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - HybridSearchReq that = (HybridSearchReq) obj; - return new EqualsBuilder() - .append(topK, that.topK) - .append(limit, that.limit) - .append(offset, that.offset) - .append(roundDecimal, that.roundDecimal) - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(partitionNames, that.partitionNames) - .append(searchRequests, that.searchRequests) - .append(ranker, that.ranker) - .append(functionScore, that.functionScore) - .append(outFields, that.outFields) - .append(consistencyLevel, that.consistencyLevel) - .append(groupByFieldName, that.groupByFieldName) - .append(groupSize, that.groupSize) - .append(strictGroupSize, that.strictGroupSize) - .isEquals(); - } - - @Override - public int hashCode() { - int result = databaseName != null ? databaseName.hashCode() : 0; - result = 31 * result + (collectionName != null ? collectionName.hashCode() : 0); - result = 31 * result + (partitionNames != null ? partitionNames.hashCode() : 0); - result = 31 * result + (searchRequests != null ? searchRequests.hashCode() : 0); - result = 31 * result + (ranker != null ? ranker.hashCode() : 0); - result = 31 * result + (functionScore != null ? functionScore.hashCode() : 0); - result = 31 * result + topK; - result = 31 * result + (int) (limit ^ (limit >>> 32)); - result = 31 * result + (outFields != null ? outFields.hashCode() : 0); - result = 31 * result + (int) (offset ^ (offset >>> 32)); - result = 31 * result + roundDecimal; - result = 31 * result + (consistencyLevel != null ? consistencyLevel.hashCode() : 0); - result = 31 * result + (groupByFieldName != null ? groupByFieldName.hashCode() : 0); - result = 31 * result + (groupSize != null ? groupSize.hashCode() : 0); - result = 31 * result + (strictGroupSize != null ? strictGroupSize.hashCode() : 0); - return result; - } - @Override public String toString() { return "HybridSearchReq{" + @@ -252,11 +207,11 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static HybridSearchReqBuilder builder() { + return new HybridSearchReqBuilder(); } - public static class Builder { + public static class HybridSearchReqBuilder { private String databaseName; private String collectionName; private List partitionNames; @@ -273,83 +228,84 @@ public static class Builder { private Integer groupSize; private Boolean strictGroupSize; - private Builder() {} + private HybridSearchReqBuilder() { + } - public Builder databaseName(String databaseName) { + public HybridSearchReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public HybridSearchReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionNames(List partitionNames) { + public HybridSearchReqBuilder partitionNames(List partitionNames) { this.partitionNames = partitionNames; return this; } - public Builder searchRequests(List searchRequests) { + public HybridSearchReqBuilder searchRequests(List searchRequests) { this.searchRequests = searchRequests; return this; } - public Builder ranker(CreateCollectionReq.Function ranker) { + public HybridSearchReqBuilder ranker(CreateCollectionReq.Function ranker) { this.ranker = ranker; return this; } - public Builder functionScore(FunctionScore functionScore) { + public HybridSearchReqBuilder functionScore(FunctionScore functionScore) { this.functionScore = functionScore; return this; } // topK is deprecated, topK and limit must be the same value @Deprecated - public Builder topK(int topK) { + public HybridSearchReqBuilder topK(int topK) { this.topK = topK; this.limit = topK; return this; } - public Builder limit(long limit) { + public HybridSearchReqBuilder limit(long limit) { this.topK = (int) limit; this.limit = limit; return this; } - public Builder outFields(List outFields) { + public HybridSearchReqBuilder outFields(List outFields) { this.outFields = outFields; return this; } - public Builder offset(long offset) { + public HybridSearchReqBuilder offset(long offset) { this.offset = offset; return this; } - public Builder roundDecimal(int roundDecimal) { + public HybridSearchReqBuilder roundDecimal(int roundDecimal) { this.roundDecimal = roundDecimal; return this; } - public Builder consistencyLevel(ConsistencyLevel consistencyLevel) { + public HybridSearchReqBuilder consistencyLevel(ConsistencyLevel consistencyLevel) { this.consistencyLevel = consistencyLevel; return this; } - public Builder groupByFieldName(String groupByFieldName) { + public HybridSearchReqBuilder groupByFieldName(String groupByFieldName) { this.groupByFieldName = groupByFieldName; return this; } - public Builder groupSize(Integer groupSize) { + public HybridSearchReqBuilder groupSize(Integer groupSize) { this.groupSize = groupSize; return this; } - public Builder strictGroupSize(Boolean strictGroupSize) { + public HybridSearchReqBuilder strictGroupSize(Boolean strictGroupSize) { this.strictGroupSize = strictGroupSize; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/InsertReq.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/InsertReq.java index 3e0739518..e4c7df1cf 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/InsertReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/InsertReq.java @@ -20,8 +20,6 @@ package io.milvus.v2.service.vector.request; import com.google.gson.JsonObject; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.List; @@ -30,7 +28,7 @@ public class InsertReq { /** * Sets the row data to insert. The rows list cannot be empty. - * + *

* Internal class for insert data. * If dataType is Bool/Int8/Int16/Int32/Int64/Float/Double/Varchar/Geometry/Timestamptz, use JsonObject.addProperty(key, value) to input; * If dataType is FloatVector, use JsonObject.add(key, gson.toJsonTree(List[Float]) to input; @@ -39,17 +37,17 @@ public class InsertReq { * If dataType is Array, use JsonObject.add(key, gson.toJsonTree(List of Boolean/Integer/Short/Long/Float/Double/String)) to input; * If dataType is Array and elementType is Struct, use JsonObject.add(key, JsonArray) to input, ensure the JsonArray is a list of JsonObject; * If dataType is JSON, use JsonObject.add(key, JsonElement) to input; - * + *

* Note: * 1. For scalar numeric values, value will be cut according to the type of the field. * For example: - * An Int8 field named "XX", you set the value to be 128 by JsonObject.add("XX", 128), the value 128 is cut to -128. - * An Int64 field named "XX", you set the value to be 3.9 by JsonObject.add("XX", 3.9), the value 3.9 is cut to 3. - * + * An Int8 field named "XX", you set the value to be 128 by JsonObject.add("XX", 128), the value 128 is cut to -128. + * An Int64 field named "XX", you set the value to be 3.9 by JsonObject.add("XX", 3.9), the value 3.9 is cut to 3. + *

* 2. String value can be parsed to numeric/boolean type if the value is valid. * For example: - * A Bool field named "XX", you set the value to be "TRUE" by JsonObject.add("XX", "TRUE"), the string "TRUE" is parsed as true. - * A Float field named "XX", you set the value to be "3.5" by JsonObject.add("XX", "3.5", the string "3.5" is parsed as 3.5. + * A Bool field named "XX", you set the value to be "TRUE" by JsonObject.add("XX", "TRUE"), the string "TRUE" is parsed as true. + * A Float field named "XX", you set the value to be "3.5" by JsonObject.add("XX", "3.5", the string "3.5" is parsed as 3.5. * */ private List data; @@ -57,15 +55,15 @@ public class InsertReq { private String collectionName; private String partitionName; - private InsertReq(Builder builder) { + private InsertReq(InsertReqBuilder builder) { this.data = builder.data; this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionName = builder.partitionName; } - public static Builder builder() { - return new Builder(); + public static InsertReqBuilder builder() { + return new InsertReqBuilder(); } public List getData() { @@ -100,29 +98,6 @@ public void setPartitionName(String partitionName) { this.partitionName = partitionName; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - InsertReq that = (InsertReq) obj; - return new EqualsBuilder() - .append(data, that.data) - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(partitionName, that.partitionName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(data) - .append(databaseName) - .append(collectionName) - .append(partitionName) - .toHashCode(); - } - @Override public String toString() { return "InsertReq{" + @@ -133,28 +108,28 @@ public String toString() { '}'; } - public static class Builder { + public static class InsertReqBuilder { private List data; private String databaseName = ""; private String collectionName; private String partitionName = ""; - public Builder data(List data) { + public InsertReqBuilder data(List data) { this.data = data; return this; } - public Builder databaseName(String databaseName) { + public InsertReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public InsertReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionName(String partitionName) { + public InsertReqBuilder partitionName(String partitionName) { this.partitionName = partitionName; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/QueryIteratorReq.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/QueryIteratorReq.java index 46117d265..fb57d356f 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/QueryIteratorReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/QueryIteratorReq.java @@ -2,8 +2,6 @@ import com.google.common.collect.Lists; import io.milvus.v2.common.ConsistencyLevel; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.List; @@ -20,7 +18,7 @@ public class QueryIteratorReq { private long batchSize; private boolean reduceStopForBest; - private QueryIteratorReq(Builder builder) { + private QueryIteratorReq(QueryIteratorReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionNames = builder.partitionNames; @@ -34,8 +32,8 @@ private QueryIteratorReq(Builder builder) { this.reduceStopForBest = builder.reduceStopForBest; } - public static Builder builder() { - return new Builder(); + public static QueryIteratorReqBuilder builder() { + return new QueryIteratorReqBuilder(); } public String getDatabaseName() { @@ -126,43 +124,6 @@ public void setReduceStopForBest(boolean reduceStopForBest) { this.reduceStopForBest = reduceStopForBest; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - QueryIteratorReq that = (QueryIteratorReq) obj; - return new EqualsBuilder() - .append(offset, that.offset) - .append(limit, that.limit) - .append(ignoreGrowing, that.ignoreGrowing) - .append(batchSize, that.batchSize) - .append(reduceStopForBest, that.reduceStopForBest) - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(partitionNames, that.partitionNames) - .append(outputFields, that.outputFields) - .append(expr, that.expr) - .append(consistencyLevel, that.consistencyLevel) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(partitionNames) - .append(outputFields) - .append(expr) - .append(consistencyLevel) - .append(offset) - .append(limit) - .append(ignoreGrowing) - .append(batchSize) - .append(reduceStopForBest) - .toHashCode(); - } - @Override public String toString() { return "QueryIteratorReq{" + @@ -180,7 +141,7 @@ public String toString() { '}'; } - public static class Builder { + public static class QueryIteratorReqBuilder { private String databaseName; private String collectionName; private List partitionNames = Lists.newArrayList(); @@ -193,57 +154,57 @@ public static class Builder { private long batchSize = 1000L; private boolean reduceStopForBest = false; - public Builder databaseName(String databaseName) { + public QueryIteratorReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public QueryIteratorReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionNames(List partitionNames) { + public QueryIteratorReqBuilder partitionNames(List partitionNames) { this.partitionNames = partitionNames; return this; } - public Builder outputFields(List outputFields) { + public QueryIteratorReqBuilder outputFields(List outputFields) { this.outputFields = outputFields; return this; } - public Builder expr(String expr) { + public QueryIteratorReqBuilder expr(String expr) { this.expr = expr; return this; } - public Builder consistencyLevel(ConsistencyLevel consistencyLevel) { + public QueryIteratorReqBuilder consistencyLevel(ConsistencyLevel consistencyLevel) { this.consistencyLevel = consistencyLevel; return this; } - public Builder offset(long offset) { + public QueryIteratorReqBuilder offset(long offset) { this.offset = offset; return this; } - public Builder limit(long limit) { + public QueryIteratorReqBuilder limit(long limit) { this.limit = limit; return this; } - public Builder ignoreGrowing(boolean ignoreGrowing) { + public QueryIteratorReqBuilder ignoreGrowing(boolean ignoreGrowing) { this.ignoreGrowing = ignoreGrowing; return this; } - public Builder batchSize(long batchSize) { + public QueryIteratorReqBuilder batchSize(long batchSize) { this.batchSize = batchSize; return this; } - public Builder reduceStopForBest(boolean reduceStopForBest) { + public QueryIteratorReqBuilder reduceStopForBest(boolean reduceStopForBest) { this.reduceStopForBest = reduceStopForBest; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/QueryReq.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/QueryReq.java index 40caad0c7..e33ebd237 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/QueryReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/QueryReq.java @@ -20,8 +20,6 @@ package io.milvus.v2.service.vector.request; import io.milvus.v2.common.ConsistencyLevel; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.*; @@ -52,7 +50,7 @@ public class QueryReq { // Boolean, Long, Double, String, List, List, List, List private Map filterTemplateValues; - private QueryReq(Builder builder) { + private QueryReq(QueryReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionNames = builder.partitionNames; @@ -67,8 +65,8 @@ private QueryReq(Builder builder) { this.filterTemplateValues = builder.filterTemplateValues; } - public static Builder builder() { - return new Builder(); + public static QueryReqBuilder builder() { + return new QueryReqBuilder(); } public String getDatabaseName() { @@ -167,45 +165,6 @@ public void setFilterTemplateValues(Map filterTemplateValues) { this.filterTemplateValues = filterTemplateValues; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - QueryReq that = (QueryReq) obj; - return new EqualsBuilder() - .append(offset, that.offset) - .append(limit, that.limit) - .append(ignoreGrowing, that.ignoreGrowing) - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(partitionNames, that.partitionNames) - .append(outputFields, that.outputFields) - .append(ids, that.ids) - .append(filter, that.filter) - .append(consistencyLevel, that.consistencyLevel) - .append(queryParams, that.queryParams) - .append(filterTemplateValues, that.filterTemplateValues) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(partitionNames) - .append(outputFields) - .append(ids) - .append(filter) - .append(consistencyLevel) - .append(offset) - .append(limit) - .append(ignoreGrowing) - .append(queryParams) - .append(filterTemplateValues) - .toHashCode(); - } - @Override public String toString() { return "QueryReq{" + @@ -224,7 +183,7 @@ public String toString() { '}'; } - public static class Builder { + public static class QueryReqBuilder { private String databaseName; private String collectionName; private List partitionNames = new ArrayList<>(); @@ -238,62 +197,62 @@ public static class Builder { private Map queryParams = new HashMap<>(); private Map filterTemplateValues = new HashMap<>(); - public Builder databaseName(String databaseName) { + public QueryReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public QueryReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionNames(List partitionNames) { + public QueryReqBuilder partitionNames(List partitionNames) { this.partitionNames = partitionNames; return this; } - public Builder outputFields(List outputFields) { + public QueryReqBuilder outputFields(List outputFields) { this.outputFields = outputFields; return this; } - public Builder ids(List ids) { + public QueryReqBuilder ids(List ids) { this.ids = ids; return this; } - public Builder filter(String filter) { + public QueryReqBuilder filter(String filter) { this.filter = filter; return this; } - public Builder consistencyLevel(ConsistencyLevel consistencyLevel) { + public QueryReqBuilder consistencyLevel(ConsistencyLevel consistencyLevel) { this.consistencyLevel = consistencyLevel; return this; } - public Builder offset(long offset) { + public QueryReqBuilder offset(long offset) { this.offset = offset; return this; } - public Builder limit(long limit) { + public QueryReqBuilder limit(long limit) { this.limit = limit; return this; } - public Builder ignoreGrowing(boolean ignoreGrowing) { + public QueryReqBuilder ignoreGrowing(boolean ignoreGrowing) { this.ignoreGrowing = ignoreGrowing; return this; } - public Builder queryParams(Map queryParams) { + public QueryReqBuilder queryParams(Map queryParams) { this.queryParams = queryParams; return this; } - public Builder filterTemplateValues(Map filterTemplateValues) { + public QueryReqBuilder filterTemplateValues(Map filterTemplateValues) { this.filterTemplateValues = filterTemplateValues; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/RunAnalyzerReq.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/RunAnalyzerReq.java index 5d6997efe..987578e22 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/RunAnalyzerReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/RunAnalyzerReq.java @@ -19,10 +19,10 @@ package io.milvus.v2.service.vector.request; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class RunAnalyzerReq { private List texts; @@ -34,7 +34,7 @@ public class RunAnalyzerReq { private String fieldName; private List analyzerNames; - private RunAnalyzerReq(Builder builder) { + private RunAnalyzerReq(RunAnalyzerReqBuilder builder) { this.texts = builder.texts; this.analyzerParams = builder.analyzerParams; this.withDetail = builder.withDetail; @@ -45,8 +45,8 @@ private RunAnalyzerReq(Builder builder) { this.analyzerNames = builder.analyzerNames; } - public static Builder builder() { - return new Builder(); + public static RunAnalyzerReqBuilder builder() { + return new RunAnalyzerReqBuilder(); } public List getTexts() { @@ -113,37 +113,6 @@ public void setAnalyzerNames(List analyzerNames) { this.analyzerNames = analyzerNames; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - RunAnalyzerReq that = (RunAnalyzerReq) obj; - return new EqualsBuilder() - .append(texts, that.texts) - .append(analyzerParams, that.analyzerParams) - .append(withDetail, that.withDetail) - .append(withHash, that.withHash) - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(fieldName, that.fieldName) - .append(analyzerNames, that.analyzerNames) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(texts) - .append(analyzerParams) - .append(withDetail) - .append(withHash) - .append(databaseName) - .append(collectionName) - .append(fieldName) - .append(analyzerNames) - .toHashCode(); - } - @Override public String toString() { return "RunAnalyzerReq{" + @@ -158,7 +127,7 @@ public String toString() { '}'; } - public static class Builder { + public static class RunAnalyzerReqBuilder { private List texts = new ArrayList<>(); private Map analyzerParams = new HashMap<>(); private Boolean withDetail = Boolean.FALSE; @@ -168,42 +137,42 @@ public static class Builder { private String fieldName = ""; private List analyzerNames = new ArrayList<>(); - public Builder texts(List texts) { + public RunAnalyzerReqBuilder texts(List texts) { this.texts = texts; return this; } - public Builder analyzerParams(Map analyzerParams) { + public RunAnalyzerReqBuilder analyzerParams(Map analyzerParams) { this.analyzerParams = analyzerParams; return this; } - public Builder withDetail(Boolean withDetail) { + public RunAnalyzerReqBuilder withDetail(Boolean withDetail) { this.withDetail = withDetail; return this; } - public Builder withHash(Boolean withHash) { + public RunAnalyzerReqBuilder withHash(Boolean withHash) { this.withHash = withHash; return this; } - public Builder databaseName(String databaseName) { + public RunAnalyzerReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public RunAnalyzerReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder fieldName(String fieldName) { + public RunAnalyzerReqBuilder fieldName(String fieldName) { this.fieldName = fieldName; return this; } - public Builder analyzerNames(List analyzerNames) { + public RunAnalyzerReqBuilder analyzerNames(List analyzerNames) { this.analyzerNames = analyzerNames; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchIteratorReq.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchIteratorReq.java index db90a353c..2a1b70ee1 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchIteratorReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchIteratorReq.java @@ -5,8 +5,6 @@ import io.milvus.v2.common.ConsistencyLevel; import io.milvus.v2.common.IndexParam; import io.milvus.v2.service.vector.request.data.BaseVector; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.List; @@ -29,7 +27,7 @@ public class SearchIteratorReq { private String groupByFieldName; private long batchSize; - private SearchIteratorReq(Builder builder) { + private SearchIteratorReq(SearchIteratorReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionNames = builder.partitionNames; @@ -48,8 +46,8 @@ private SearchIteratorReq(Builder builder) { this.batchSize = builder.batchSize; } - public static Builder builder() { - return new Builder(); + public static SearchIteratorReqBuilder builder() { + return new SearchIteratorReqBuilder(); } public String getDatabaseName() { @@ -182,53 +180,6 @@ public void setBatchSize(long batchSize) { this.batchSize = batchSize; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - SearchIteratorReq that = (SearchIteratorReq) obj; - return new EqualsBuilder() - .append(topK, that.topK) - .append(limit, that.limit) - .append(roundDecimal, that.roundDecimal) - .append(ignoreGrowing, that.ignoreGrowing) - .append(batchSize, that.batchSize) - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(partitionNames, that.partitionNames) - .append(metricType, that.metricType) - .append(vectorFieldName, that.vectorFieldName) - .append(expr, that.expr) - .append(outputFields, that.outputFields) - .append(vectors, that.vectors) - .append(params, that.params) - .append(consistencyLevel, that.consistencyLevel) - .append(groupByFieldName, that.groupByFieldName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(partitionNames) - .append(metricType) - .append(vectorFieldName) - .append(topK) - .append(limit) - .append(expr) - .append(outputFields) - .append(vectors) - .append(roundDecimal) - .append(params) - .append(consistencyLevel) - .append(ignoreGrowing) - .append(groupByFieldName) - .append(batchSize) - .toHashCode(); - } - @Override public String toString() { return "SearchIteratorReq{" + @@ -251,7 +202,7 @@ public String toString() { '}'; } - public static class Builder { + public static class SearchIteratorReqBuilder { private String databaseName; private String collectionName; private List partitionNames = Lists.newArrayList(); @@ -269,86 +220,86 @@ public static class Builder { private String groupByFieldName = ""; private long batchSize = 1000L; - public Builder databaseName(String databaseName) { + public SearchIteratorReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public SearchIteratorReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionNames(List partitionNames) { + public SearchIteratorReqBuilder partitionNames(List partitionNames) { this.partitionNames = partitionNames; return this; } - public Builder metricType(IndexParam.MetricType metricType) { + public SearchIteratorReqBuilder metricType(IndexParam.MetricType metricType) { this.metricType = metricType; return this; } - public Builder vectorFieldName(String vectorFieldName) { + public SearchIteratorReqBuilder vectorFieldName(String vectorFieldName) { this.vectorFieldName = vectorFieldName; return this; } // topK is deprecated, topK and limit must be the same value @Deprecated - public Builder topK(int val) { + public SearchIteratorReqBuilder topK(int val) { this.topK = val; this.limit = val; return this; } - public Builder limit(long val) { + public SearchIteratorReqBuilder limit(long val) { this.topK = (int) val; this.limit = val; return this; } - public Builder expr(String expr) { + public SearchIteratorReqBuilder expr(String expr) { this.expr = expr; return this; } - public Builder outputFields(List outputFields) { + public SearchIteratorReqBuilder outputFields(List outputFields) { this.outputFields = outputFields; return this; } - public Builder vectors(List vectors) { + public SearchIteratorReqBuilder vectors(List vectors) { this.vectors = vectors; return this; } - public Builder roundDecimal(int roundDecimal) { + public SearchIteratorReqBuilder roundDecimal(int roundDecimal) { this.roundDecimal = roundDecimal; return this; } - public Builder params(String params) { + public SearchIteratorReqBuilder params(String params) { this.params = params; return this; } - public Builder consistencyLevel(ConsistencyLevel consistencyLevel) { + public SearchIteratorReqBuilder consistencyLevel(ConsistencyLevel consistencyLevel) { this.consistencyLevel = consistencyLevel; return this; } - public Builder ignoreGrowing(boolean ignoreGrowing) { + public SearchIteratorReqBuilder ignoreGrowing(boolean ignoreGrowing) { this.ignoreGrowing = ignoreGrowing; return this; } - public Builder groupByFieldName(String groupByFieldName) { + public SearchIteratorReqBuilder groupByFieldName(String groupByFieldName) { this.groupByFieldName = groupByFieldName; return this; } - public Builder batchSize(long batchSize) { + public SearchIteratorReqBuilder batchSize(long batchSize) { this.batchSize = batchSize; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchIteratorReqV2.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchIteratorReqV2.java index 0c2877914..41b8814d8 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchIteratorReqV2.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchIteratorReqV2.java @@ -6,8 +6,6 @@ import io.milvus.v2.common.IndexParam; import io.milvus.v2.service.vector.request.data.BaseVector; import io.milvus.v2.service.vector.response.SearchResp; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.HashMap; import java.util.List; @@ -34,7 +32,7 @@ public class SearchIteratorReqV2 { private long batchSize; private Function, List> externalFilterFunc; - private SearchIteratorReqV2(Builder builder) { + private SearchIteratorReqV2(SearchIteratorReqV2Builder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionNames = builder.partitionNames; @@ -54,8 +52,8 @@ private SearchIteratorReqV2(Builder builder) { this.externalFilterFunc = builder.externalFilterFunc; } - public static Builder builder() { - return new Builder(); + public static SearchIteratorReqV2Builder builder() { + return new SearchIteratorReqV2Builder(); } public String getDatabaseName() { @@ -196,55 +194,6 @@ public void setExternalFilterFunc(Function, List partitionNames = Lists.newArrayList(); @@ -287,91 +236,91 @@ public static class Builder { private long batchSize = 1000L; private Function, List> externalFilterFunc = null; - public Builder databaseName(String databaseName) { + public SearchIteratorReqV2Builder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public SearchIteratorReqV2Builder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionNames(List partitionNames) { + public SearchIteratorReqV2Builder partitionNames(List partitionNames) { this.partitionNames = partitionNames; return this; } - public Builder metricType(IndexParam.MetricType metricType) { + public SearchIteratorReqV2Builder metricType(IndexParam.MetricType metricType) { this.metricType = metricType; return this; } - public Builder vectorFieldName(String vectorFieldName) { + public SearchIteratorReqV2Builder vectorFieldName(String vectorFieldName) { this.vectorFieldName = vectorFieldName; return this; } // topK is deprecated, topK and limit must be the same value @Deprecated - public Builder topK(int val) { + public SearchIteratorReqV2Builder topK(int val) { this.topK = val; this.limit = val; return this; } - public Builder limit(long val) { + public SearchIteratorReqV2Builder limit(long val) { this.topK = (int) val; this.limit = val; return this; } - public Builder filter(String filter) { + public SearchIteratorReqV2Builder filter(String filter) { this.filter = filter; return this; } - public Builder outputFields(List outputFields) { + public SearchIteratorReqV2Builder outputFields(List outputFields) { this.outputFields = outputFields; return this; } - public Builder vectors(List vectors) { + public SearchIteratorReqV2Builder vectors(List vectors) { this.vectors = vectors; return this; } - public Builder roundDecimal(int roundDecimal) { + public SearchIteratorReqV2Builder roundDecimal(int roundDecimal) { this.roundDecimal = roundDecimal; return this; } - public Builder searchParams(Map searchParams) { + public SearchIteratorReqV2Builder searchParams(Map searchParams) { this.searchParams = searchParams; return this; } - public Builder consistencyLevel(ConsistencyLevel consistencyLevel) { + public SearchIteratorReqV2Builder consistencyLevel(ConsistencyLevel consistencyLevel) { this.consistencyLevel = consistencyLevel; return this; } - public Builder ignoreGrowing(boolean ignoreGrowing) { + public SearchIteratorReqV2Builder ignoreGrowing(boolean ignoreGrowing) { this.ignoreGrowing = ignoreGrowing; return this; } - public Builder groupByFieldName(String groupByFieldName) { + public SearchIteratorReqV2Builder groupByFieldName(String groupByFieldName) { this.groupByFieldName = groupByFieldName; return this; } - public Builder batchSize(long batchSize) { + public SearchIteratorReqV2Builder batchSize(long batchSize) { this.batchSize = batchSize; return this; } - public Builder externalFilterFunc(Function, List> externalFilterFunc) { + public SearchIteratorReqV2Builder externalFilterFunc(Function, List> externalFilterFunc) { this.externalFilterFunc = externalFilterFunc; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchReq.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchReq.java index 9419ac5a2..14d1a1619 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchReq.java @@ -23,8 +23,6 @@ import io.milvus.v2.common.IndexParam; import io.milvus.v2.service.collection.request.CreateCollectionReq; import io.milvus.v2.service.vector.request.data.BaseVector; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.ArrayList; import java.util.HashMap; @@ -70,7 +68,7 @@ public class SearchReq { private Map filterTemplateValues; - private SearchReq(Builder builder) { + private SearchReq(SearchReqBuilder builder) { this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; this.partitionNames = builder.partitionNames; @@ -283,67 +281,6 @@ public void setFilterTemplateValues(Map filterTemplateValues) { this.filterTemplateValues = filterTemplateValues; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - SearchReq searchReq = (SearchReq) obj; - return new EqualsBuilder() - .append(topK, searchReq.topK) - .append(offset, searchReq.offset) - .append(limit, searchReq.limit) - .append(roundDecimal, searchReq.roundDecimal) - .append(guaranteeTimestamp, searchReq.guaranteeTimestamp) - .append(ignoreGrowing, searchReq.ignoreGrowing) - .append(databaseName, searchReq.databaseName) - .append(collectionName, searchReq.collectionName) - .append(partitionNames, searchReq.partitionNames) - .append(annsField, searchReq.annsField) - .append(metricType, searchReq.metricType) - .append(filter, searchReq.filter) - .append(outputFields, searchReq.outputFields) - .append(data, searchReq.data) - .append(searchParams, searchReq.searchParams) - .append(gracefulTime, searchReq.gracefulTime) - .append(consistencyLevel, searchReq.consistencyLevel) - .append(groupByFieldName, searchReq.groupByFieldName) - .append(groupSize, searchReq.groupSize) - .append(strictGroupSize, searchReq.strictGroupSize) - .append(ranker, searchReq.ranker) - .append(functionScore, searchReq.functionScore) - .append(filterTemplateValues, searchReq.filterTemplateValues) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(databaseName) - .append(collectionName) - .append(partitionNames) - .append(annsField) - .append(metricType) - .append(topK) - .append(filter) - .append(outputFields) - .append(data) - .append(offset) - .append(limit) - .append(roundDecimal) - .append(searchParams) - .append(guaranteeTimestamp) - .append(gracefulTime) - .append(consistencyLevel) - .append(ignoreGrowing) - .append(groupByFieldName) - .append(groupSize) - .append(strictGroupSize) - .append(ranker) - .append(functionScore) - .append(filterTemplateValues) - .toHashCode(); - } - @Override public String toString() { return "SearchReq{" + @@ -373,11 +310,11 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static SearchReqBuilder builder() { + return new SearchReqBuilder(); } - public static class Builder { + public static class SearchReqBuilder { private String databaseName; private String collectionName; private List partitionNames = new ArrayList<>(); // default value @@ -402,123 +339,124 @@ public static class Builder { private FunctionScore functionScore; private Map filterTemplateValues = new HashMap<>(); // default value - private Builder() {} + private SearchReqBuilder() { + } - public Builder databaseName(String databaseName) { + public SearchReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public SearchReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionNames(List partitionNames) { + public SearchReqBuilder partitionNames(List partitionNames) { this.partitionNames = partitionNames; return this; } - public Builder annsField(String annsField) { + public SearchReqBuilder annsField(String annsField) { this.annsField = annsField; return this; } - public Builder metricType(IndexParam.MetricType metricType) { + public SearchReqBuilder metricType(IndexParam.MetricType metricType) { this.metricType = metricType; return this; } // topK is deprecated, topK and limit must be the same value @Deprecated - public Builder topK(int topK) { + public SearchReqBuilder topK(int topK) { this.topK = topK; this.limit = topK; return this; } - public Builder filter(String filter) { + public SearchReqBuilder filter(String filter) { this.filter = filter; return this; } - public Builder outputFields(List outputFields) { + public SearchReqBuilder outputFields(List outputFields) { this.outputFields = outputFields; return this; } - public Builder data(List data) { + public SearchReqBuilder data(List data) { this.data = data; return this; } - public Builder offset(long offset) { + public SearchReqBuilder offset(long offset) { this.offset = offset; return this; } - public Builder limit(long limit) { + public SearchReqBuilder limit(long limit) { this.topK = (int) limit; this.limit = limit; return this; } - public Builder roundDecimal(int roundDecimal) { + public SearchReqBuilder roundDecimal(int roundDecimal) { this.roundDecimal = roundDecimal; return this; } - public Builder searchParams(Map searchParams) { + public SearchReqBuilder searchParams(Map searchParams) { this.searchParams = searchParams; return this; } - public Builder guaranteeTimestamp(long guaranteeTimestamp) { + public SearchReqBuilder guaranteeTimestamp(long guaranteeTimestamp) { this.guaranteeTimestamp = guaranteeTimestamp; return this; } - public Builder gracefulTime(Long gracefulTime) { + public SearchReqBuilder gracefulTime(Long gracefulTime) { this.gracefulTime = gracefulTime; return this; } - public Builder consistencyLevel(ConsistencyLevel consistencyLevel) { + public SearchReqBuilder consistencyLevel(ConsistencyLevel consistencyLevel) { this.consistencyLevel = consistencyLevel; return this; } - public Builder ignoreGrowing(boolean ignoreGrowing) { + public SearchReqBuilder ignoreGrowing(boolean ignoreGrowing) { this.ignoreGrowing = ignoreGrowing; return this; } - public Builder groupByFieldName(String groupByFieldName) { + public SearchReqBuilder groupByFieldName(String groupByFieldName) { this.groupByFieldName = groupByFieldName; return this; } - public Builder groupSize(Integer groupSize) { + public SearchReqBuilder groupSize(Integer groupSize) { this.groupSize = groupSize; return this; } - public Builder strictGroupSize(Boolean strictGroupSize) { + public SearchReqBuilder strictGroupSize(Boolean strictGroupSize) { this.strictGroupSize = strictGroupSize; return this; } - public Builder ranker(CreateCollectionReq.Function ranker) { + public SearchReqBuilder ranker(CreateCollectionReq.Function ranker) { this.ranker = ranker; return this; } - public Builder functionScore(FunctionScore functionScore) { + public SearchReqBuilder functionScore(FunctionScore functionScore) { this.functionScore = functionScore; return this; } - public Builder filterTemplateValues(Map filterTemplateValues) { + public SearchReqBuilder filterTemplateValues(Map filterTemplateValues) { this.filterTemplateValues = filterTemplateValues; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/UpsertReq.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/UpsertReq.java index 1dc1872e4..1027dfb8a 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/UpsertReq.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/UpsertReq.java @@ -20,15 +20,13 @@ package io.milvus.v2.service.vector.request; import com.google.gson.JsonObject; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.List; public class UpsertReq { /** * Sets the row data to insert. The rows list cannot be empty. - * + *

* Internal class for insert data. * If dataType is Bool/Int8/Int16/Int32/Int64/Float/Double/Varchar/Geometry/Timestamptz, use JsonObject.addProperty(key, value) to input; * If dataType is FloatVector, use JsonObject.add(key, gson.toJsonTree(List[Float]) to input; @@ -37,17 +35,17 @@ public class UpsertReq { * If dataType is Array, use JsonObject.add(key, gson.toJsonTree(List of Boolean/Integer/Short/Long/Float/Double/String)) to input; * If dataType is Array and elementType is Struct, use JsonObject.add(key, JsonArray) to input, ensure the JsonArray is a list of JsonObject; * If dataType is JSON, use JsonObject.add(key, JsonElement) to input; - * + *

* Note: * 1. For scalar numeric values, value will be cut according to the type of the field. * For example: - * An Int8 field named "XX", you set the value to be 128 by JsonObject.add("XX", 128), the value 128 is cut to -128. - * An Int64 field named "XX", you set the value to be 3.9 by JsonObject.add("XX", 3.9), the value 3.9 is cut to 3. - * + * An Int8 field named "XX", you set the value to be 128 by JsonObject.add("XX", 128), the value 128 is cut to -128. + * An Int64 field named "XX", you set the value to be 3.9 by JsonObject.add("XX", 3.9), the value 3.9 is cut to 3. + *

* 2. String value can be parsed to numeric/boolean type if the value is valid. * For example: - * A Bool field named "XX", you set the value to be "TRUE" by JsonObject.add("XX", "TRUE"), the string "TRUE" is parsed as true. - * A Float field named "XX", you set the value to be "3.5" by JsonObject.add("XX", "3.5", the string "3.5" is parsed as 3.5. + * A Bool field named "XX", you set the value to be "TRUE" by JsonObject.add("XX", "TRUE"), the string "TRUE" is parsed as true. + * A Float field named "XX", you set the value to be "3.5" by JsonObject.add("XX", "3.5", the string "3.5" is parsed as 3.5. * */ private List data; @@ -56,7 +54,7 @@ public class UpsertReq { private String partitionName; private boolean partialUpdate; - private UpsertReq(Builder builder) { + private UpsertReq(UpsertReqBuilder builder) { this.data = builder.data; this.databaseName = builder.databaseName; this.collectionName = builder.collectionName; @@ -64,8 +62,8 @@ private UpsertReq(Builder builder) { this.partialUpdate = builder.partialUpdate; } - public static Builder builder() { - return new Builder(); + public static UpsertReqBuilder builder() { + return new UpsertReqBuilder(); } public List getData() { @@ -108,31 +106,6 @@ public void setPartialUpdate(boolean partialUpdate) { this.partialUpdate = partialUpdate; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - UpsertReq that = (UpsertReq) obj; - return new EqualsBuilder() - .append(partialUpdate, that.partialUpdate) - .append(data, that.data) - .append(databaseName, that.databaseName) - .append(collectionName, that.collectionName) - .append(partitionName, that.partitionName) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(data) - .append(databaseName) - .append(collectionName) - .append(partitionName) - .append(partialUpdate) - .toHashCode(); - } - @Override public String toString() { return "UpsertReq{" + @@ -144,34 +117,34 @@ public String toString() { '}'; } - public static class Builder { + public static class UpsertReqBuilder { private List data; private String databaseName = ""; private String collectionName; private String partitionName = ""; private boolean partialUpdate = false; // default value - public Builder data(List data) { + public UpsertReqBuilder data(List data) { this.data = data; return this; } - public Builder databaseName(String databaseName) { + public UpsertReqBuilder databaseName(String databaseName) { this.databaseName = databaseName; return this; } - public Builder collectionName(String collectionName) { + public UpsertReqBuilder collectionName(String collectionName) { this.collectionName = collectionName; return this; } - public Builder partitionName(String partitionName) { + public UpsertReqBuilder partitionName(String partitionName) { this.partitionName = partitionName; return this; } - public Builder partialUpdate(boolean partialUpdate) { + public UpsertReqBuilder partialUpdate(boolean partialUpdate) { this.partialUpdate = partialUpdate; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/BFloat16Vec.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/BFloat16Vec.java index 80c23b088..15fa1e1ca 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/BFloat16Vec.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/BFloat16Vec.java @@ -31,6 +31,7 @@ public class BFloat16Vec implements BaseVector { public BFloat16Vec(ByteBuffer data) { this.data = data; } + public BFloat16Vec(byte[] data) { this.data = ByteBuffer.wrap(data); } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/BaseVector.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/BaseVector.java index 4c45de7bf..a0574bede 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/BaseVector.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/BaseVector.java @@ -23,5 +23,6 @@ public interface BaseVector { PlaceholderType getPlaceholderType(); + Object getData(); } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/BinaryVec.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/BinaryVec.java index a2d367fd6..89db658b2 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/BinaryVec.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/BinaryVec.java @@ -29,9 +29,11 @@ public class BinaryVec implements BaseVector { public BinaryVec(ByteBuffer data) { this.data = data; } + public BinaryVec(byte[] data) { this.data = ByteBuffer.wrap(data); } + @Override public PlaceholderType getPlaceholderType() { return PlaceholderType.BinaryVector; diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/EmbeddedText.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/EmbeddedText.java index 75edf4555..afa389f8d 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/EmbeddedText.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/EmbeddedText.java @@ -27,6 +27,7 @@ public class EmbeddedText implements BaseVector { public EmbeddedText(String data) { this.data = data; } + @Override public PlaceholderType getPlaceholderType() { return PlaceholderType.VarChar; diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/EmbeddingList.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/EmbeddingList.java index 6cb4d35fe..6c5e23444 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/EmbeddingList.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/EmbeddingList.java @@ -73,7 +73,7 @@ public Object getData() { case FloatVector: List floats = new ArrayList<>(); for (BaseVector vec : data) { - floats.addAll((List)vec.getData()); + floats.addAll((List) vec.getData()); } return floats; default: diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/Float16Vec.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/Float16Vec.java index 086a425b9..361b34a99 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/Float16Vec.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/Float16Vec.java @@ -31,6 +31,7 @@ public class Float16Vec implements BaseVector { public Float16Vec(ByteBuffer data) { this.data = data; } + public Float16Vec(byte[] data) { this.data = ByteBuffer.wrap(data); } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/FloatVec.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/FloatVec.java index 006c6843f..5862334b0 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/FloatVec.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/FloatVec.java @@ -31,6 +31,7 @@ public class FloatVec implements BaseVector { public FloatVec(List data) { this.data = data; } + public FloatVec(float[] data) { this.data = new ArrayList<>(); for (float f : data) { diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/Int8Vec.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/Int8Vec.java index 7e09b7c48..592a838ee 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/Int8Vec.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/data/Int8Vec.java @@ -29,6 +29,7 @@ public class Int8Vec implements BaseVector { public Int8Vec(ByteBuffer data) { this.data = data; } + public Int8Vec(byte[] data) { this.data = ByteBuffer.wrap(data); } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/BoostRanker.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/BoostRanker.java index 8ad5337a1..d278c525f 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/BoostRanker.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/BoostRanker.java @@ -22,6 +22,7 @@ import io.milvus.common.clientenum.FunctionType; import io.milvus.common.utils.JsonUtils; import io.milvus.v2.service.collection.request.CreateCollectionReq; +import io.milvus.v2.service.collection.request.CreateCollectionReq.Function; import org.apache.commons.lang3.StringUtils; import java.util.HashMap; @@ -30,27 +31,27 @@ /** * The Decay reranking strategy, which by adjusting search rankings based on numeric field values. * Read the doc for more info: https://milvus.io/docs/decay-ranker-overview.md - * + *

* Example: * BoostRanker boost = BoostRanker.builder() - * .name("xxx_boost") - * .description("boost on xxx") - * .filter("xxx == 2") - * .weight(0.5) - * .randomScoreSeed(123) - * .randomScoreField("id") - * .build() - * + * .name("xxx_boost") + * .description("boost on xxx") + * .filter("xxx == 2") + * .weight(0.5) + * .randomScoreSeed(123) + * .randomScoreField("id") + * .build() + *

* You also can declare a decay ranker by Function * CreateCollectionReq.Function boost = CreateCollectionReq.Function.builder() - * .functionType(FunctionType.RERANK) - * .name("xxx_boost") - * .description("boost on xxx") - * .param("reranker", "boost") - * .param("filter", "xxx == 2") - * .param("weight", "0.5") - * .param("random_score", "{\"seed\": 123, \"field\": \"id\"}") - * .build(); + * .functionType(FunctionType.RERANK) + * .name("xxx_boost") + * .description("boost on xxx") + * .param("reranker", "boost") + * .param("filter", "xxx == 2") + * .param("weight", "0.5") + * .param("random_score", "{\"seed\": 123, \"field\": \"id\"}") + * .build(); */ public class BoostRanker extends CreateCollectionReq.Function { private String filter; @@ -58,7 +59,7 @@ public class BoostRanker extends CreateCollectionReq.Function { private Long randomScoreSeed; private String randomScoreField; - private BoostRanker(Builder builder) { + private BoostRanker(BoostRankerBuilder builder) { super(builder); this.filter = builder.filter; this.weight = builder.weight; @@ -110,36 +111,36 @@ public String getRandomScoreField() { return randomScoreField; } - public static Builder builder() { - return new Builder(); + public static BoostRankerBuilder builder() { + return new BoostRankerBuilder(); } - public static class Builder extends CreateCollectionReq.Function.FunctionBuilder { + public static class BoostRankerBuilder extends Function.FunctionBuilder { private String filter; private Float weight; private Long randomScoreSeed; private String randomScoreField; - private Builder() { + private BoostRankerBuilder() { super(); } - public Builder filter(String filter) { + public BoostRankerBuilder filter(String filter) { this.filter = filter; return this; } - public Builder weight(Float weight) { + public BoostRankerBuilder weight(Float weight) { this.weight = weight; return this; } - public Builder randomScoreSeed(Long randomScoreSeed) { + public BoostRankerBuilder randomScoreSeed(Long randomScoreSeed) { this.randomScoreSeed = randomScoreSeed; return this; } - public Builder randomScoreField(String randomScoreField) { + public BoostRankerBuilder randomScoreField(String randomScoreField) { this.randomScoreField = randomScoreField; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/DecayRanker.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/DecayRanker.java index 0e863264b..baa33c9a3 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/DecayRanker.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/DecayRanker.java @@ -23,40 +23,37 @@ import io.milvus.v2.service.collection.request.CreateCollectionReq; import io.milvus.v2.service.collection.request.CreateCollectionReq.Function; -import org.apache.commons.lang3.builder.EqualsBuilder; - -import java.util.List; import java.util.Map; /** * The Decay reranking strategy, which by adjusting search rankings based on numeric field values. * Read the doc for more info: https://milvus.io/docs/decay-ranker-overview.md - * + *

* Example: * DecayRanker decay = DecayRanker.builder() - * .name("time_decay") - * .description("time decay") - * .inputFieldNames(Collections.singletonList("timestamp")) - * .function("gauss") - * .origin(100) - * .scale(50) - * .offset(24) - * .decay(0.5) - * .build() - * + * .name("time_decay") + * .description("time decay") + * .inputFieldNames(Collections.singletonList("timestamp")) + * .function("gauss") + * .origin(100) + * .scale(50) + * .offset(24) + * .decay(0.5) + * .build() + *

* You also can declare a decay ranker by Function: * CreateCollectionReq.Function decay = CreateCollectionReq.Function.builder() - * .functionType(FunctionType.RERANK) - * .name("time_decay") - * .description("time decay") - * .inputFieldNames(Collections.singletonList("timestamp")) - * .param("reranker", "decay") - * .param("function", "gauss") - * .param("origin", "100") - * .param("scale", "50") - * .param("offset", "24") - * .param("decay", "0.5") - * .build(); + * .functionType(FunctionType.RERANK) + * .name("time_decay") + * .description("time decay") + * .inputFieldNames(Collections.singletonList("timestamp")) + * .param("reranker", "decay") + * .param("function", "gauss") + * .param("origin", "100") + * .param("scale", "50") + * .param("offset", "24") + * .param("decay", "0.5") + * .build(); */ public class DecayRanker extends CreateCollectionReq.Function { private String function; @@ -65,11 +62,13 @@ public class DecayRanker extends CreateCollectionReq.Function { private Number scale; private Number decay; - private DecayRanker(FunctionBuilder builder) { + private DecayRanker(DecayRankerBuilder builder) { super(builder); this.function = builder.function; this.origin = builder.origin; + this.offset = builder.offset; this.scale = builder.scale; + this.decay = builder.decay; } public String getFunction() { @@ -88,6 +87,14 @@ public void setOrigin(Number origin) { this.origin = origin; } + public Number getOffset() { + return offset; + } + + public void setOffset(Number offset) { + this.offset = offset; + } + public Number getScale() { return scale; } @@ -96,6 +103,14 @@ public void setScale(Number scale) { this.scale = scale; } + public Number getDecay() { + return decay; + } + + public void setDecay(Number decay) { + this.decay = decay; + } + @Override public FunctionType getFunctionType() { return FunctionType.RERANK; @@ -122,34 +137,14 @@ public Map getParams() { return props; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - if (!super.equals(obj)) return false; - DecayRanker that = (DecayRanker) obj; - return new EqualsBuilder() - .append(function, that.function) - .append(origin, that.origin) - .append(scale, that.scale) - .isEquals(); - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (function != null ? function.hashCode() : 0); - result = 31 * result + (origin != null ? origin.hashCode() : 0); - result = 31 * result + (scale != null ? scale.hashCode() : 0); - return result; - } - @Override public String toString() { return "DecayRanker{" + "function='" + function + '\'' + ", origin=" + origin + + ", offset=" + offset + ", scale=" + scale + + ", decay=" + decay + ", name='" + getName() + '\'' + ", description='" + getDescription() + '\'' + ", functionType=" + getFunctionType() + @@ -159,74 +154,46 @@ public String toString() { '}'; } - public static FunctionBuilder builder() { - return new FunctionBuilder(); + public static DecayRankerBuilder builder() { + return new DecayRankerBuilder(); } - public static class FunctionBuilder extends Function.FunctionBuilder { + public static class DecayRankerBuilder extends Function.FunctionBuilder { private String function = "gauss"; private Number origin; + private Number offset; private Number scale; + private Number decay; - private FunctionBuilder() {} + private DecayRankerBuilder() { + } - public FunctionBuilder function(String function) { + public DecayRankerBuilder function(String function) { this.function = function; return this; } - public FunctionBuilder origin(Number origin) { + public DecayRankerBuilder origin(Number origin) { this.origin = origin; return this; } - public FunctionBuilder scale(Number scale) { - this.scale = scale; + public DecayRankerBuilder offset(Number offset) { + this.offset = offset; return this; } - @Override - public FunctionBuilder name(String name) { - super.name(name); - return this; - } - - @Override - public FunctionBuilder description(String description) { - super.description(description); - return this; - } - - @Override - public FunctionBuilder functionType(io.milvus.common.clientenum.FunctionType functionType) { - super.functionType(functionType); - return this; - } - - @Override - public FunctionBuilder inputFieldNames(List inputFieldNames) { - super.inputFieldNames(inputFieldNames); - return this; - } - - @Override - public FunctionBuilder outputFieldNames(List outputFieldNames) { - super.outputFieldNames(outputFieldNames); + public DecayRankerBuilder scale(Number scale) { + this.scale = scale; return this; } - @Override - public FunctionBuilder params(Map params) { - super.params(params); + public DecayRankerBuilder decay(Number decay) { + this.decay = decay; return this; } @Override - public FunctionBuilder param(String key, String value) { - super.param(key, value); - return this; - } - public DecayRanker build() { return new DecayRanker(this); } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/ModelRanker.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/ModelRanker.java index a3d29597b..7d6f7533a 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/ModelRanker.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/ModelRanker.java @@ -24,8 +24,6 @@ import io.milvus.v2.service.collection.request.CreateCollectionReq; import io.milvus.v2.service.collection.request.CreateCollectionReq.Function; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -34,25 +32,25 @@ * The Model reranking strategy, which transforms Milvus search by integrating advanced language models * that understand semantic relationships between queries and documents. * Read the doc for more info: https://milvus.io/docs/model-ranker-overview.md - * + *

* You also can declare a model ranker by Function * CreateCollectionReq.Function rr = CreateCollectionReq.Function.builder() - * .functionType(FunctionType.RERANK) - * .name("semantic_ranker") - * .description("semantic ranker") - * .inputFieldNames(Collections.singletonList("document")) - * .param("reranker", "model") - * .param("provider", "tei") - * .param("queries", "[\"machine learning for time series\"]") - * .param("endpoint", "http://model-service:8080") - * .build(); + * .functionType(FunctionType.RERANK) + * .name("semantic_ranker") + * .description("semantic ranker") + * .inputFieldNames(Collections.singletonList("document")) + * .param("reranker", "model") + * .param("provider", "tei") + * .param("queries", "[\"machine learning for time series\"]") + * .param("endpoint", "http://model-service:8080") + * .build(); */ public class ModelRanker extends CreateCollectionReq.Function { private String provider; private List queries; private String endpoint; - private ModelRanker(FunctionBuilder builder) { + private ModelRanker(ModelRankerBuilder builder) { super(builder); this.provider = builder.provider; this.queries = builder.queries; @@ -103,28 +101,6 @@ public Map getParams() { return props; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - if (!super.equals(obj)) return false; - ModelRanker that = (ModelRanker) obj; - return new EqualsBuilder() - .append(provider, that.provider) - .append(queries, that.queries) - .append(endpoint, that.endpoint) - .isEquals(); - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (provider != null ? provider.hashCode() : 0); - result = 31 * result + (queries != null ? queries.hashCode() : 0); - result = 31 * result + (endpoint != null ? endpoint.hashCode() : 0); - return result; - } - @Override public String toString() { return "ModelRanker{" + @@ -140,74 +116,34 @@ public String toString() { '}'; } - public static FunctionBuilder builder() { - return new FunctionBuilder(); + public static ModelRankerBuilder builder() { + return new ModelRankerBuilder(); } - public static class FunctionBuilder extends Function.FunctionBuilder { + public static class ModelRankerBuilder extends Function.FunctionBuilder { private String provider = "tei"; private List queries = new ArrayList<>(); private String endpoint; - private FunctionBuilder() {} + private ModelRankerBuilder() { + } - public FunctionBuilder provider(String provider) { + public ModelRankerBuilder provider(String provider) { this.provider = provider; return this; } - public FunctionBuilder queries(List queries) { + public ModelRankerBuilder queries(List queries) { this.queries = queries; return this; } - public FunctionBuilder endpoint(String endpoint) { + public ModelRankerBuilder endpoint(String endpoint) { this.endpoint = endpoint; return this; } @Override - public FunctionBuilder name(String name) { - super.name(name); - return this; - } - - @Override - public FunctionBuilder description(String description) { - super.description(description); - return this; - } - - @Override - public FunctionBuilder functionType(io.milvus.common.clientenum.FunctionType functionType) { - super.functionType(functionType); - return this; - } - - @Override - public FunctionBuilder inputFieldNames(java.util.List inputFieldNames) { - super.inputFieldNames(inputFieldNames); - return this; - } - - @Override - public FunctionBuilder outputFieldNames(java.util.List outputFieldNames) { - super.outputFieldNames(outputFieldNames); - return this; - } - - @Override - public FunctionBuilder params(java.util.Map params) { - super.params(params); - return this; - } - - @Override - public FunctionBuilder param(String key, String value) { - super.param(key, value); - return this; - } - public ModelRanker build() { return new ModelRanker(this); } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/RRFRanker.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/RRFRanker.java index 43073c297..61e240990 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/RRFRanker.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/RRFRanker.java @@ -24,31 +24,28 @@ import io.milvus.v2.service.collection.request.CreateCollectionReq; import io.milvus.v2.service.collection.request.CreateCollectionReq.Function; -import org.apache.commons.lang3.builder.EqualsBuilder; - -import java.util.List; import java.util.Map; /** * The RRF reranking strategy, which merges results from multiple searches, favoring items that consistently appear. * Read the doc for more info: https://milvus.io/docs/rrf-ranker.md - * + *

* Note: In v2.6, the Function and Rerank have been unified to support more rerank types: decay and model ranker * https://milvus.io/docs/decay-ranker-overview.md * https://milvus.io/docs/model-ranker-overview.md * So we have to inherit the BaseRanker from Function, this change will lead to uncomfortable issues with * RRFRanker/WeightedRanker in some users client code. We will mention it in release note. - * * In old client code, to declare a WeightedRanker: - * * RRFRanker ranker = new RRFRanker(20) - * * After this change, the client code should be changed accordingly: - * * RRFRanker ranker = RRFRanker.builder().k(20).build() - * + * * In old client code, to declare a WeightedRanker: + * * RRFRanker ranker = new RRFRanker(20) + * * After this change, the client code should be changed accordingly: + * * RRFRanker ranker = RRFRanker.builder().k(20).build() + *

* You also can declare a rrf ranker by Function * CreateCollectionReq.Function rr = CreateCollectionReq.Function.builder() - * .functionType(FunctionType.RERANK) - * .param("strategy", "rrf") - * .param("params", "{\"k\": 60}") - * .build(); + * .functionType(FunctionType.RERANK) + * .param("strategy", "rrf") + * .param("params", "{\"k\": 60}") + * .build(); */ public class RRFRanker extends CreateCollectionReq.Function { private int k; @@ -63,7 +60,7 @@ public RRFRanker(int k) { this.k = k; } - private RRFRanker(FunctionBuilder builder) { + private RRFRanker(RRFRankerBuilder builder) { super(builder); this.k = builder.k; } @@ -92,24 +89,6 @@ public Map getParams() { return props; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - if (!super.equals(obj)) return false; - RRFRanker rrfRanker = (RRFRanker) obj; - return new EqualsBuilder() - .append(k, rrfRanker.k) - .isEquals(); - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + k; - return result; - } - @Override public String toString() { return "RRFRanker{" + @@ -123,62 +102,22 @@ public String toString() { '}'; } - public static FunctionBuilder builder() { - return new FunctionBuilder(); + public static RRFRankerBuilder builder() { + return new RRFRankerBuilder(); } - public static class FunctionBuilder extends Function.FunctionBuilder { + public static class RRFRankerBuilder extends Function.FunctionBuilder { private int k = 60; - private FunctionBuilder() {} - - public FunctionBuilder k(int k) { - this.k = k; - return this; + private RRFRankerBuilder() { } - @Override - public FunctionBuilder name(String name) { - super.name(name); - return this; - } - - @Override - public FunctionBuilder description(String description) { - super.description(description); - return this; - } - - @Override - public FunctionBuilder functionType(FunctionType functionType) { - super.functionType(functionType); - return this; - } - - @Override - public FunctionBuilder inputFieldNames(List inputFieldNames) { - super.inputFieldNames(inputFieldNames); - return this; - } - - @Override - public FunctionBuilder outputFieldNames(List outputFieldNames) { - super.outputFieldNames(outputFieldNames); - return this; - } - - @Override - public FunctionBuilder params(Map params) { - super.params(params); + public RRFRankerBuilder k(int k) { + this.k = k; return this; } @Override - public FunctionBuilder param(String key, String value) { - super.param(key, value); - return this; - } - public RRFRanker build() { return new RRFRanker(this); } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/WeightedRanker.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/WeightedRanker.java index 38c8efb1e..5731b12ad 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/WeightedRanker.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/WeightedRanker.java @@ -25,8 +25,6 @@ import io.milvus.v2.service.collection.request.CreateCollectionReq; import io.milvus.v2.service.collection.request.CreateCollectionReq.Function; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -35,23 +33,23 @@ * The Average Weighted Scoring reranking strategy, which prioritizes vectors based on relevance, * averaging their significance. * Read the doc for more info: https://milvus.io/docs/weighted-ranker.md - * + *

* Note: In v2.6, the Function and Rerank have been unified to support more rerank types: decay and model ranker * https://milvus.io/docs/decay-ranker-overview.md * https://milvus.io/docs/model-ranker-overview.md * So we have to inherit the BaseRanker from Function, this change will lead to uncomfortable issues with * RRFRanker/WeightedRanker in some users client code. We will mention it in release note. * In old client code, to declare a WeightedRanker: - * WeightedRanker ranker = new WeightedRanker(Arrays.asList(0.2f, 0.5f, 0.6f)) + * WeightedRanker ranker = new WeightedRanker(Arrays.asList(0.2f, 0.5f, 0.6f)) * After this change, the client code should be changed accordingly: - * WeightedRanker ranker = WeightedRanker.builder().weights(Arrays.asList(0.2f, 0.5f, 0.6f)).build() - * + * WeightedRanker ranker = WeightedRanker.builder().weights(Arrays.asList(0.2f, 0.5f, 0.6f)).build() + *

* You also can declare a weighter ranker by Function * CreateCollectionReq.Function rr = CreateCollectionReq.Function.builder() - * .functionType(FunctionType.RERANK) - * .param("strategy", "weighted") - * .param("params", "{\"weights\": [0.4, 0.6]}") - * .build(); + * .functionType(FunctionType.RERANK) + * .param("strategy", "weighted") + * .param("params", "{\"weights\": [0.4, 0.6]}") + * .build(); */ public class WeightedRanker extends CreateCollectionReq.Function { private List weights; @@ -66,7 +64,7 @@ public WeightedRanker(List weights) { this.weights = weights; } - private WeightedRanker(FunctionBuilder builder) { + private WeightedRanker(WeightedRankerBuilder builder) { super(builder); this.weights = builder.weights; } @@ -95,24 +93,6 @@ public Map getParams() { return props; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - if (!super.equals(obj)) return false; - WeightedRanker that = (WeightedRanker) obj; - return new EqualsBuilder() - .append(weights, that.weights) - .isEquals(); - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (weights != null ? weights.hashCode() : 0); - return result; - } - @Override public String toString() { return "WeightedRanker{" + @@ -126,62 +106,22 @@ public String toString() { '}'; } - public static FunctionBuilder builder() { - return new FunctionBuilder(); + public static WeightedRankerBuilder builder() { + return new WeightedRankerBuilder(); } - public static class FunctionBuilder extends Function.FunctionBuilder { + public static class WeightedRankerBuilder extends Function.FunctionBuilder { private List weights = new ArrayList<>(); - private FunctionBuilder() {} - - public FunctionBuilder weights(List weights) { - this.weights = weights; - return this; + private WeightedRankerBuilder() { } - @Override - public FunctionBuilder name(String name) { - super.name(name); - return this; - } - - @Override - public FunctionBuilder description(String description) { - super.description(description); - return this; - } - - @Override - public FunctionBuilder functionType(io.milvus.common.clientenum.FunctionType functionType) { - super.functionType(functionType); - return this; - } - - @Override - public FunctionBuilder inputFieldNames(java.util.List inputFieldNames) { - super.inputFieldNames(inputFieldNames); - return this; - } - - @Override - public FunctionBuilder outputFieldNames(java.util.List outputFieldNames) { - super.outputFieldNames(outputFieldNames); - return this; - } - - @Override - public FunctionBuilder params(java.util.Map params) { - super.params(params); + public WeightedRankerBuilder weights(List weights) { + this.weights = weights; return this; } @Override - public FunctionBuilder param(String key, String value) { - super.param(key, value); - return this; - } - public WeightedRanker build() { return new WeightedRanker(this); } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/response/DeleteResp.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/response/DeleteResp.java index d3374b411..c8f6592b4 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/response/DeleteResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/response/DeleteResp.java @@ -19,18 +19,15 @@ package io.milvus.v2.service.vector.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - public class DeleteResp { private long deleteCnt; - private DeleteResp(Builder builder) { + private DeleteResp(DeleteRespBuilder builder) { this.deleteCnt = builder.deleteCnt; } - public static Builder builder() { - return new Builder(); + public static DeleteRespBuilder builder() { + return new DeleteRespBuilder(); } public long getDeleteCnt() { @@ -41,23 +38,6 @@ public void setDeleteCnt(long deleteCnt) { this.deleteCnt = deleteCnt; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - DeleteResp that = (DeleteResp) obj; - return new EqualsBuilder() - .append(deleteCnt, that.deleteCnt) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(deleteCnt) - .toHashCode(); - } - @Override public String toString() { return "DeleteResp{" + @@ -65,10 +45,10 @@ public String toString() { '}'; } - public static class Builder { + public static class DeleteRespBuilder { private long deleteCnt; - public Builder deleteCnt(long deleteCnt) { + public DeleteRespBuilder deleteCnt(long deleteCnt) { this.deleteCnt = deleteCnt; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/response/GetResp.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/response/GetResp.java index 2099b6982..2fae0fafb 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/response/GetResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/response/GetResp.java @@ -19,20 +19,17 @@ package io.milvus.v2.service.vector.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.List; public class GetResp { private List getResults; - private GetResp(Builder builder) { + private GetResp(GetRespBuilder builder) { this.getResults = builder.getResults; } - public static Builder builder() { - return new Builder(); + public static GetRespBuilder builder() { + return new GetRespBuilder(); } public List getGetResults() { @@ -43,23 +40,6 @@ public void setGetResults(List getResults) { this.getResults = getResults; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - GetResp that = (GetResp) obj; - return new EqualsBuilder() - .append(getResults, that.getResults) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(getResults) - .toHashCode(); - } - @Override public String toString() { return "GetResp{" + @@ -67,10 +47,10 @@ public String toString() { '}'; } - public static class Builder { + public static class GetRespBuilder { private List getResults; - public Builder getResults(List getResults) { + public GetRespBuilder getResults(List getResults) { this.getResults = getResults; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/response/InsertResp.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/response/InsertResp.java index 6d86ca40d..a929b66fb 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/response/InsertResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/response/InsertResp.java @@ -19,9 +19,6 @@ package io.milvus.v2.service.vector.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.ArrayList; import java.util.List; @@ -30,13 +27,13 @@ public class InsertResp { private long InsertCnt; private List primaryKeys; - private InsertResp(Builder builder) { + private InsertResp(InsertRespBuilder builder) { this.InsertCnt = builder.InsertCnt; this.primaryKeys = builder.primaryKeys; } - public static Builder builder() { - return new Builder(); + public static InsertRespBuilder builder() { + return new InsertRespBuilder(); } public long getInsertCnt() { @@ -55,25 +52,6 @@ public void setPrimaryKeys(List primaryKeys) { this.primaryKeys = primaryKeys; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - InsertResp that = (InsertResp) obj; - return new EqualsBuilder() - .append(InsertCnt, that.InsertCnt) - .append(primaryKeys, that.primaryKeys) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(InsertCnt) - .append(primaryKeys) - .toHashCode(); - } - @Override public String toString() { return "InsertResp{" + @@ -82,16 +60,16 @@ public String toString() { '}'; } - public static class Builder { + public static class InsertRespBuilder { private long InsertCnt; private List primaryKeys = new ArrayList<>(); - public Builder InsertCnt(long insertCnt) { + public InsertRespBuilder InsertCnt(long insertCnt) { InsertCnt = insertCnt; return this; } - public Builder primaryKeys(List primaryKeys) { + public InsertRespBuilder primaryKeys(List primaryKeys) { this.primaryKeys = primaryKeys; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/response/QueryResp.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/response/QueryResp.java index 8d7a2e2d5..a9b782532 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/response/QueryResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/response/QueryResp.java @@ -19,9 +19,6 @@ package io.milvus.v2.service.vector.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -31,13 +28,13 @@ public class QueryResp { private List queryResults; private long sessionTs; // default eventually ts - private QueryResp(Builder builder) { + private QueryResp(QueryRespBuilder builder) { this.queryResults = builder.queryResults; this.sessionTs = builder.sessionTs; } - public static Builder builder() { - return new Builder(); + public static QueryRespBuilder builder() { + return new QueryRespBuilder(); } public List getQueryResults() { @@ -56,25 +53,6 @@ public void setSessionTs(long sessionTs) { this.sessionTs = sessionTs; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - QueryResp that = (QueryResp) obj; - return new EqualsBuilder() - .append(sessionTs, that.sessionTs) - .append(queryResults, that.queryResults) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(queryResults) - .append(sessionTs) - .toHashCode(); - } - @Override public String toString() { return "QueryResp{" + @@ -83,16 +61,16 @@ public String toString() { '}'; } - public static class Builder { + public static class QueryRespBuilder { private List queryResults = new ArrayList<>(); private long sessionTs = 1L; // default eventually ts - public Builder queryResults(List queryResults) { + public QueryRespBuilder queryResults(List queryResults) { this.queryResults = queryResults; return this; } - public Builder sessionTs(long sessionTs) { + public QueryRespBuilder sessionTs(long sessionTs) { this.sessionTs = sessionTs; return this; } @@ -105,12 +83,12 @@ public QueryResp build() { public static class QueryResult { private Map entity; - private QueryResult(Builder builder) { + private QueryResult(QueryResultBuilder builder) { this.entity = builder.entity; } - public static Builder builder() { - return new Builder(); + public static QueryResultBuilder builder() { + return new QueryResultBuilder(); } public Map getEntity() { @@ -121,23 +99,6 @@ public void setEntity(Map entity) { this.entity = entity; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - QueryResult that = (QueryResult) obj; - return new EqualsBuilder() - .append(entity, that.entity) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(entity) - .toHashCode(); - } - @Override public String toString() { return "QueryResult{" + @@ -145,10 +106,10 @@ public String toString() { '}'; } - public static class Builder { + public static class QueryResultBuilder { private Map entity = new HashMap<>(); - public Builder entity(Map entity) { + public QueryResultBuilder entity(Map entity) { this.entity = entity; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/response/RunAnalyzerResp.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/response/RunAnalyzerResp.java index 078b29f5c..afd9267ee 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/response/RunAnalyzerResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/response/RunAnalyzerResp.java @@ -19,21 +19,18 @@ package io.milvus.v2.service.vector.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.ArrayList; import java.util.List; public class RunAnalyzerResp { private List results; - private RunAnalyzerResp(Builder builder) { + private RunAnalyzerResp(RunAnalyzerRespBuilder builder) { this.results = builder.results; } - public static Builder builder() { - return new Builder(); + public static RunAnalyzerRespBuilder builder() { + return new RunAnalyzerRespBuilder(); } public List getResults() { @@ -44,23 +41,6 @@ public void setResults(List results) { this.results = results; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - RunAnalyzerResp that = (RunAnalyzerResp) obj; - return new EqualsBuilder() - .append(results, that.results) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(results) - .toHashCode(); - } - @Override public String toString() { return "RunAnalyzerResp{" + @@ -68,10 +48,10 @@ public String toString() { '}'; } - public static class Builder { + public static class RunAnalyzerRespBuilder { private List results = new ArrayList<>(); - public Builder results(List results) { + public RunAnalyzerRespBuilder results(List results) { this.results = results; return this; } @@ -84,12 +64,12 @@ public RunAnalyzerResp build() { public static final class AnalyzerResult { private List tokens; - private AnalyzerResult(Builder builder) { + private AnalyzerResult(AnalyzerResultBuilder builder) { this.tokens = builder.tokens; } - public static Builder builder() { - return new Builder(); + public static AnalyzerResultBuilder builder() { + return new AnalyzerResultBuilder(); } public List getTokens() { @@ -100,23 +80,6 @@ public void setTokens(List tokens) { this.tokens = tokens; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AnalyzerResult that = (AnalyzerResult) obj; - return new EqualsBuilder() - .append(tokens, that.tokens) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(tokens) - .toHashCode(); - } - @Override public String toString() { return "AnalyzerResult{" + @@ -124,10 +87,10 @@ public String toString() { '}'; } - public static class Builder { + public static class AnalyzerResultBuilder { private List tokens = new ArrayList<>(); - public Builder tokens(List tokens) { + public AnalyzerResultBuilder tokens(List tokens) { this.tokens = tokens; return this; } @@ -146,7 +109,7 @@ public static final class AnalyzerToken { private Long positionLength; private Long hash; - private AnalyzerToken(Builder builder) { + private AnalyzerToken(AnalyzerTokenBuilder builder) { this.token = builder.token; this.startOffset = builder.startOffset; this.endOffset = builder.endOffset; @@ -155,8 +118,8 @@ private AnalyzerToken(Builder builder) { this.hash = builder.hash; } - public static Builder builder() { - return new Builder(); + public static AnalyzerTokenBuilder builder() { + return new AnalyzerTokenBuilder(); } public String getToken() { @@ -207,33 +170,6 @@ public void setHash(Long hash) { this.hash = hash; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AnalyzerToken that = (AnalyzerToken) obj; - return new EqualsBuilder() - .append(token, that.token) - .append(startOffset, that.startOffset) - .append(endOffset, that.endOffset) - .append(position, that.position) - .append(positionLength, that.positionLength) - .append(hash, that.hash) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(token) - .append(startOffset) - .append(endOffset) - .append(position) - .append(positionLength) - .append(hash) - .toHashCode(); - } - @Override public String toString() { return "AnalyzerToken{" + @@ -246,7 +182,7 @@ public String toString() { '}'; } - public static class Builder { + public static class AnalyzerTokenBuilder { private String token; private Long startOffset; private Long endOffset; @@ -254,32 +190,32 @@ public static class Builder { private Long positionLength; private Long hash; - public Builder token(String token) { + public AnalyzerTokenBuilder token(String token) { this.token = token; return this; } - public Builder startOffset(Long startOffset) { + public AnalyzerTokenBuilder startOffset(Long startOffset) { this.startOffset = startOffset; return this; } - public Builder endOffset(Long endOffset) { + public AnalyzerTokenBuilder endOffset(Long endOffset) { this.endOffset = endOffset; return this; } - public Builder position(Long position) { + public AnalyzerTokenBuilder position(Long position) { this.position = position; return this; } - public Builder positionLength(Long positionLength) { + public AnalyzerTokenBuilder positionLength(Long positionLength) { this.positionLength = positionLength; return this; } - public Builder hash(Long hash) { + public AnalyzerTokenBuilder hash(Long hash) { this.hash = hash; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/response/SearchResp.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/response/SearchResp.java index 5b3f751b8..d8bf776bd 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/response/SearchResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/response/SearchResp.java @@ -19,9 +19,6 @@ package io.milvus.v2.service.vector.response; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -32,14 +29,14 @@ public class SearchResp { private long sessionTs; // default eventually ts private List recalls; - private SearchResp(Builder builder) { + private SearchResp(SearchRespBuilder builder) { this.searchResults = builder.searchResults; this.sessionTs = builder.sessionTs; this.recalls = builder.recalls; } - public static Builder builder() { - return new Builder(); + public static SearchRespBuilder builder() { + return new SearchRespBuilder(); } public List> getSearchResults() { @@ -66,27 +63,6 @@ public void setRecalls(List recalls) { this.recalls = recalls; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - SearchResp that = (SearchResp) obj; - return new EqualsBuilder() - .append(sessionTs, that.sessionTs) - .append(searchResults, that.searchResults) - .append(recalls, that.recalls) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(searchResults) - .append(sessionTs) - .append(recalls) - .toHashCode(); - } - @Override public String toString() { return "SearchResp{" + @@ -96,22 +72,22 @@ public String toString() { '}'; } - public static class Builder { + public static class SearchRespBuilder { private List> searchResults = new ArrayList<>(); private long sessionTs = 1L; // default eventually ts private List recalls = new ArrayList<>(); - public Builder searchResults(List> searchResults) { + public SearchRespBuilder searchResults(List> searchResults) { this.searchResults = searchResults; return this; } - public Builder sessionTs(long sessionTs) { + public SearchRespBuilder sessionTs(long sessionTs) { this.sessionTs = sessionTs; return this; } - public Builder recalls(List recalls) { + public SearchRespBuilder recalls(List recalls) { this.recalls = recalls; return this; } @@ -127,15 +103,15 @@ public static class SearchResult { private Object id; private String primaryKey; - private SearchResult(Builder builder) { + private SearchResult(SearchResultBuilder builder) { this.entity = builder.entity; this.score = builder.score; this.id = builder.id; this.primaryKey = builder.primaryKey; } - public static Builder builder() { - return new Builder(); + public static SearchResultBuilder builder() { + return new SearchResultBuilder(); } public Map getEntity() { @@ -170,56 +146,33 @@ public void setPrimaryKey(String primaryKey) { this.primaryKey = primaryKey; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - SearchResult that = (SearchResult) obj; - return new EqualsBuilder() - .append(entity, that.entity) - .append(score, that.score) - .append(id, that.id) - .append(primaryKey, that.primaryKey) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(entity) - .append(score) - .append(id) - .append(primaryKey) - .toHashCode(); - } - @Override public String toString() { return "{" + getPrimaryKey() + ": " + getId() + ", Score: " + getScore() + ", OutputFields: " + entity + "}"; } - public static class Builder { + public static class SearchResultBuilder { private Map entity = new HashMap<>(); private Float score; private Object id; private String primaryKey = "id"; - public Builder entity(Map entity) { + public SearchResultBuilder entity(Map entity) { this.entity = entity; return this; } - public Builder score(Float score) { + public SearchResultBuilder score(Float score) { this.score = score; return this; } - public Builder id(Object id) { + public SearchResultBuilder id(Object id) { this.id = id; return this; } - public Builder primaryKey(String primaryKey) { + public SearchResultBuilder primaryKey(String primaryKey) { this.primaryKey = primaryKey; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/service/vector/response/UpsertResp.java b/sdk-core/src/main/java/io/milvus/v2/service/vector/response/UpsertResp.java index 95dbae8b9..087cace17 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/vector/response/UpsertResp.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/vector/response/UpsertResp.java @@ -19,8 +19,6 @@ package io.milvus.v2.service.vector.response; -import org.apache.commons.lang3.builder.EqualsBuilder; - import java.util.ArrayList; import java.util.List; @@ -32,7 +30,7 @@ public class UpsertResp { // is created with this new pk. Here we return this new pk to user. private List primaryKeys; - private UpsertResp(Builder builder) { + private UpsertResp(UpsertRespBuilder builder) { this.upsertCnt = builder.upsertCnt; this.primaryKeys = builder.primaryKeys; } @@ -54,24 +52,6 @@ public void setPrimaryKeys(List primaryKeys) { this.primaryKeys = primaryKeys; } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - UpsertResp that = (UpsertResp) obj; - return new EqualsBuilder() - .append(upsertCnt, that.upsertCnt) - .append(primaryKeys, that.primaryKeys) - .isEquals(); - } - - @Override - public int hashCode() { - int result = (int) (upsertCnt ^ (upsertCnt >>> 32)); - result = 31 * result + (primaryKeys != null ? primaryKeys.hashCode() : 0); - return result; - } - @Override public String toString() { return "UpsertResp{" + @@ -80,22 +60,23 @@ public String toString() { '}'; } - public static Builder builder() { - return new Builder(); + public static UpsertRespBuilder builder() { + return new UpsertRespBuilder(); } - public static class Builder { + public static class UpsertRespBuilder { private long upsertCnt; private List primaryKeys = new ArrayList<>(); // default value - private Builder() {} + private UpsertRespBuilder() { + } - public Builder upsertCnt(long upsertCnt) { + public UpsertRespBuilder upsertCnt(long upsertCnt) { this.upsertCnt = upsertCnt; return this; } - public Builder primaryKeys(List primaryKeys) { + public UpsertRespBuilder primaryKeys(List primaryKeys) { this.primaryKeys = primaryKeys; return this; } diff --git a/sdk-core/src/main/java/io/milvus/v2/utils/ClientUtils.java b/sdk-core/src/main/java/io/milvus/v2/utils/ClientUtils.java index 9aee732f6..fcefac16d 100644 --- a/sdk-core/src/main/java/io/milvus/v2/utils/ClientUtils.java +++ b/sdk-core/src/main/java/io/milvus/v2/utils/ClientUtils.java @@ -22,11 +22,7 @@ import io.grpc.*; import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts; import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder; -import io.grpc.netty.shaded.io.netty.handler.ssl.ApplicationProtocolConfig; -import io.grpc.netty.shaded.io.netty.handler.ssl.ClientAuth; -import io.grpc.netty.shaded.io.netty.handler.ssl.IdentityCipherSuiteFilter; -import io.grpc.netty.shaded.io.netty.handler.ssl.JdkSslContext; -import io.grpc.netty.shaded.io.netty.handler.ssl.SslContext; +import io.grpc.netty.shaded.io.netty.handler.ssl.*; import io.grpc.stub.MetadataUtils; import io.milvus.client.MilvusServiceClient; import io.milvus.grpc.*; @@ -38,6 +34,8 @@ import java.io.File; import java.io.IOException; import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.SocketAddress; import java.net.UnknownHostException; import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; @@ -45,13 +43,12 @@ import java.util.Base64; import java.util.List; import java.util.concurrent.TimeUnit; -import java.net.InetSocketAddress; -import java.net.SocketAddress; public class ClientUtils { Logger logger = LoggerFactory.getLogger(ClientUtils.class); RpcUtils rpcUtils = new RpcUtils(); - public ManagedChannel getChannel(ConnectConfig connectConfig){ + + public ManagedChannel getChannel(ConnectConfig connectConfig) { ManagedChannel channel = null; Metadata metadata = new Metadata(); @@ -74,7 +71,7 @@ public ClientCall interceptCall(MethodDescriptor responseListener, Metadata headers) { String currentMs = String.valueOf(System.currentTimeMillis()); headers.put(Metadata.Key.of("client-request-unixmsec", Metadata.ASCII_STRING_MARSHALLER), currentMs); - if(connectConfig.getClientRequestId() != null) { + if (connectConfig.getClientRequestId() != null) { String clientID = connectConfig.getClientRequestId().get(); if (!StringUtils.isEmpty(clientID)) { headers.put(Metadata.Key.of("client_request_id", Metadata.ASCII_STRING_MARSHALLER), clientID); @@ -98,12 +95,12 @@ public void start(ClientCall.Listener responseListener, Metadata headers) .keepAliveWithoutCalls(connectConfig.isKeepAliveWithoutCalls()) .idleTimeout(connectConfig.getIdleTimeoutMs(), TimeUnit.MILLISECONDS) .intercept(clientInterceptors); - + if (StringUtils.isNotEmpty(connectConfig.getProxyAddress())) { configureProxy(builder, connectConfig.getProxyAddress()); } - - if(connectConfig.isSecure()) { + + if (connectConfig.isSecure()) { builder.useTransportSecurity(); } if (StringUtils.isNotEmpty(connectConfig.getServerName())) { @@ -130,7 +127,7 @@ public void start(ClientCall.Listener responseListener, Metadata headers) configureProxy(builder, connectConfig.getProxyAddress()); } - if(connectConfig.isSecure()){ + if (connectConfig.isSecure()) { builder.useTransportSecurity(); } channel = builder.build(); @@ -151,11 +148,11 @@ public void start(ClientCall.Listener responseListener, Metadata headers) .keepAliveWithoutCalls(connectConfig.isKeepAliveWithoutCalls()) .idleTimeout(connectConfig.getIdleTimeoutMs(), TimeUnit.MILLISECONDS) .intercept(clientInterceptors); - + if (StringUtils.isNotEmpty(connectConfig.getProxyAddress())) { configureProxy(builder, connectConfig.getProxyAddress()); } - + if (connectConfig.getSecure()) { builder.useTransportSecurity(); } @@ -176,7 +173,7 @@ public void start(ClientCall.Listener responseListener, Metadata headers) if (StringUtils.isNotEmpty(connectConfig.getProxyAddress())) { configureProxy(builder, connectConfig.getProxyAddress()); } - if(connectConfig.isSecure()){ + if (connectConfig.isSecure()) { builder.useTransportSecurity(); } channel = builder.build(); @@ -190,8 +187,8 @@ public void start(ClientCall.Listener responseListener, Metadata headers) /** * Configures the proxy settings for a NettyChannelBuilder if proxy address is specified - * - * @param builder NettyChannelBuilder to configure + * + * @param builder NettyChannelBuilder to configure * @param connectConfig Connection configuration containing proxy settings */ public static void configureProxy(ManagedChannelBuilder builder, String proxyAddress) { @@ -228,6 +225,7 @@ public void checkDatabaseExist(MilvusServiceGrpc.MilvusServiceBlockingStub block throw new IllegalArgumentException("Database " + dbName + " not exist"); } } + public String getServerVersion(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub) { GetVersionResponse response = blockingStub.getVersion(GetVersionRequest.newBuilder().build()); rpcUtils.handleResponse("Get server version", response.getStatus()); diff --git a/sdk-core/src/main/java/io/milvus/v2/utils/ConvertUtils.java b/sdk-core/src/main/java/io/milvus/v2/utils/ConvertUtils.java index 0016c0663..2e63ed629 100644 --- a/sdk-core/src/main/java/io/milvus/v2/utils/ConvertUtils.java +++ b/sdk-core/src/main/java/io/milvus/v2/utils/ConvertUtils.java @@ -67,7 +67,7 @@ public static io.milvus.v2.common.DataType toSdkDataType(DataType dt) { public List getEntities(QueryResults response) { List entities = new ArrayList<>(); // count(*) ? - if(response.getFieldsDataList().stream().anyMatch(fieldData -> fieldData.getFieldName().equals("count(*)"))){ + if (response.getFieldsDataList().stream().anyMatch(fieldData -> fieldData.getFieldName().equals("count(*)"))) { Map countField = new HashMap<>(); long numOfEntities = response.getFieldsDataList().stream().filter(fieldData -> fieldData.getFieldName().equals("count(*)")).map(FieldData::getScalars).collect(Collectors.toList()).get(0).getLongData().getData(0); countField.put("count(*)", numOfEntities); @@ -114,7 +114,7 @@ public DescribeIndexResp convertToDescribeIndexResp(List respo IndexParam.IndexType indexType = IndexParam.IndexType.None; IndexParam.MetricType metricType = IndexParam.MetricType.INVALID; Map properties = new HashMap<>(); - for(KeyValuePair param : params) { + for (KeyValuePair param : params) { if (param.getKey().equals(Constant.INDEX_TYPE)) { try { indexType = IndexParam.IndexType.valueOf(param.getValue().toUpperCase()); @@ -136,7 +136,8 @@ public DescribeIndexResp convertToDescribeIndexResp(List respo properties.put(param.getKey(), param.getValue()); // just for compatible with old versions extraParams.put(param.getKey(), param.getValue()); } else if (param.getKey().equals(Constant.PARAMS)) { - Map tempParams = JsonUtils.fromJson(param.getValue(), new TypeToken>() {}.getType()); + Map tempParams = JsonUtils.fromJson(param.getValue(), new TypeToken>() { + }.getType()); tempParams.remove(Constant.MMAP_ENABLED); // "mmap.enabled" in "params" is not processed by server extraParams.putAll(tempParams); } else { @@ -176,7 +177,7 @@ public List convertDescCollectionsResp(BatchDescribeColl public DescribeCollectionResp convertDescCollectionResp(DescribeCollectionResponse response) { Map properties = new HashMap<>(); - response.getPropertiesList().forEach(prop->properties.put(prop.getKey(), prop.getValue())); + response.getPropertiesList().forEach(prop -> properties.put(prop.getKey(), prop.getValue())); DescribeCollectionResp describeCollectionResp = DescribeCollectionResp.builder() .collectionName(response.getCollectionName()) diff --git a/sdk-core/src/main/java/io/milvus/v2/utils/DataUtils.java b/sdk-core/src/main/java/io/milvus/v2/utils/DataUtils.java index 3b808c293..71438e78f 100644 --- a/sdk-core/src/main/java/io/milvus/v2/utils/DataUtils.java +++ b/sdk-core/src/main/java/io/milvus/v2/utils/DataUtils.java @@ -19,7 +19,10 @@ package io.milvus.v2.utils; -import com.google.gson.*; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +import com.google.gson.JsonObject; import io.milvus.grpc.*; import io.milvus.param.Constant; import io.milvus.param.ParamUtils; @@ -149,8 +152,8 @@ private void checkAndSetRowData(DescribeCollectionResp descColl, List normalFields = collectionSchema.getFieldSchemaList(); List structFields = collectionSchema.getStructFields(); List allFieldNames = new ArrayList<>(); - normalFields.forEach((schema)-> allFieldNames.add(schema.getName())); - structFields.forEach((schema)-> allFieldNames.add(schema.getName())); + normalFields.forEach((schema) -> allFieldNames.add(schema.getName())); + structFields.forEach((schema) -> allFieldNames.add(schema.getName())); // 1. for normal fields, InsertDataInfo is a list of object or list of list, for example: // Int64Field, InsertDataInfo is a List @@ -299,7 +302,7 @@ private void processStructFieldValues(JsonObject row, CreateCollectionReq.Struct String subFieldName = field.getName(); InsertDataInfo insertDataInfo = nameInsertInfo.get(subFieldName); List columnData = new ArrayList<>(); - structs.forEach((element)->{ + structs.forEach((element) -> { if (!element.isJsonObject()) { String msg = String.format("The element of struct field: %s is not a JSON dict.", structName); throw new MilvusClientException(ErrorCode.INVALID_PARAMS, msg); @@ -420,7 +423,7 @@ public DeleteRequest ConvertToGrpcDeleteRequest(DeleteReq request) { .setExpr(request.getFilter()); if (request.getFilter() != null && !request.getFilter().isEmpty()) { Map filterTemplateValues = request.getFilterTemplateValues(); - filterTemplateValues.forEach((key, value)->{ + filterTemplateValues.forEach((key, value) -> { builder.putExprTemplateValues(key, VectorUtils.deduceAndCreateTemplateValue(value)); }); } diff --git a/sdk-core/src/main/java/io/milvus/v2/utils/RpcUtils.java b/sdk-core/src/main/java/io/milvus/v2/utils/RpcUtils.java index a17e3a292..041bf30e4 100644 --- a/sdk-core/src/main/java/io/milvus/v2/utils/RpcUtils.java +++ b/sdk-core/src/main/java/io/milvus/v2/utils/RpcUtils.java @@ -86,7 +86,7 @@ public T retry(Callable callable) { // method to check timeout long begin = System.currentTimeMillis(); long maxRetryTimeoutMs = retryConfig.getMaxRetryTimeoutMs(); - Callable timeoutChecker = ()->{ + Callable timeoutChecker = () -> { long current = System.currentTimeMillis(); long cost = (current - begin); if (maxRetryTimeoutMs > 0 && cost >= maxRetryTimeoutMs) { @@ -163,7 +163,7 @@ public T retry(Callable callable) { } // reset the next interval value - retryIntervalMs = retryIntervalMs*retryConfig.getBackOffMultiplier(); + retryIntervalMs = retryIntervalMs * retryConfig.getBackOffMultiplier(); if (retryIntervalMs > retryConfig.getMaxBackOffMs()) { retryIntervalMs = retryConfig.getMaxBackOffMs(); } diff --git a/sdk-core/src/main/java/io/milvus/v2/utils/SchemaUtils.java b/sdk-core/src/main/java/io/milvus/v2/utils/SchemaUtils.java index c39663772..e9a9f57c2 100644 --- a/sdk-core/src/main/java/io/milvus/v2/utils/SchemaUtils.java +++ b/sdk-core/src/main/java/io/milvus/v2/utils/SchemaUtils.java @@ -22,14 +22,7 @@ import com.google.gson.reflect.TypeToken; import io.milvus.common.utils.JsonUtils; import io.milvus.exception.ParamException; -import io.milvus.grpc.CollectionSchema; -import io.milvus.grpc.DataType; -import io.milvus.grpc.FieldSchema; -import io.milvus.grpc.FunctionSchema; -import io.milvus.grpc.FunctionType; -import io.milvus.grpc.KeyValuePair; -import io.milvus.grpc.ValueField; -import io.milvus.grpc.StructArrayFieldSchema; +import io.milvus.grpc.*; import io.milvus.param.ParamUtils; import io.milvus.v2.exception.ErrorCode; import io.milvus.v2.exception.MilvusClientException; @@ -83,13 +76,13 @@ public static FieldSchema convertToGrpcFieldSchema(CreateCollectionReq.FieldSche // assemble typeParams for FieldSchema Map typeParams = fieldSchema.getTypeParams() == null ? new HashMap<>() : fieldSchema.getTypeParams(); - if(fieldSchema.getDimension() != null){ + if (fieldSchema.getDimension() != null) { typeParams.put("dim", String.valueOf(fieldSchema.getDimension())); } // if (Objects.equals(fieldSchema.getName(), partitionKeyField)) { // schema = schema.toBuilder().setIsPartitionKey(Boolean.TRUE).build(); // } - if(fieldSchema.getDataType() == io.milvus.v2.common.DataType.VarChar && fieldSchema.getMaxLength() != null){ + if (fieldSchema.getDataType() == io.milvus.v2.common.DataType.VarChar && fieldSchema.getMaxLength() != null) { typeParams.put("max_length", String.valueOf(fieldSchema.getMaxLength())); } if (fieldSchema.getDataType() == io.milvus.v2.common.DataType.Array) { @@ -233,21 +226,23 @@ public static CreateCollectionReq.FieldSchema convertFromGrpcFieldSchema(FieldSc Map typeParams = new HashMap<>(); for (KeyValuePair keyValuePair : fieldSchema.getTypeParamsList()) { try { - if(keyValuePair.getKey().equals(VECTOR_DIM)){ + if (keyValuePair.getKey().equals(VECTOR_DIM)) { schema.setDimension(Integer.parseInt(keyValuePair.getValue())); - } else if(keyValuePair.getKey().equals(VARCHAR_MAX_LENGTH)){ + } else if (keyValuePair.getKey().equals(VARCHAR_MAX_LENGTH)) { schema.setMaxLength(Integer.parseInt(keyValuePair.getValue())); - } else if(keyValuePair.getKey().equals(ARRAY_MAX_CAPACITY)){ + } else if (keyValuePair.getKey().equals(ARRAY_MAX_CAPACITY)) { schema.setMaxCapacity(Integer.parseInt(keyValuePair.getValue())); - } else if(keyValuePair.getKey().equals("enable_analyzer")){ + } else if (keyValuePair.getKey().equals("enable_analyzer")) { schema.setEnableAnalyzer(Boolean.parseBoolean(keyValuePair.getValue())); - } else if(keyValuePair.getKey().equals("enable_match")){ + } else if (keyValuePair.getKey().equals("enable_match")) { schema.setEnableMatch(Boolean.parseBoolean(keyValuePair.getValue())); - } else if(keyValuePair.getKey().equals("analyzer_params")){ - Map params = JsonUtils.fromJson(keyValuePair.getValue(), new TypeToken>() {}.getType()); + } else if (keyValuePair.getKey().equals("analyzer_params")) { + Map params = JsonUtils.fromJson(keyValuePair.getValue(), new TypeToken>() { + }.getType()); schema.setAnalyzerParams(params); - } else if(keyValuePair.getKey().equals("multi_analyzer_params")){ - Map params = JsonUtils.fromJson(keyValuePair.getValue(), new TypeToken>() {}.getType()); + } else if (keyValuePair.getKey().equals("multi_analyzer_params")) { + Map params = JsonUtils.fromJson(keyValuePair.getValue(), new TypeToken>() { + }.getType()); schema.setMultiAnalyzerParams(params); } } catch (Exception e) { @@ -265,7 +260,7 @@ public static CreateCollectionReq.FieldSchema convertFromGrpcFieldSchema(FieldSc } public static CreateCollectionReq.StructFieldSchema convertFromGrpcStructFieldSchema(StructArrayFieldSchema structSchema) { - CreateCollectionReq.StructFieldSchema.Builder builder = + CreateCollectionReq.StructFieldSchema.StructFieldSchemaBuilder builder = CreateCollectionReq.StructFieldSchema.builder() .name(structSchema.getName()) .description(structSchema.getDescription()); @@ -296,7 +291,7 @@ public static CreateCollectionReq.Function convertFromGrpcFunction(FunctionSchem .inputFieldNames(functionSchema.getInputFieldNamesList().stream().collect(Collectors.toList())) .outputFieldNames(functionSchema.getOutputFieldNamesList().stream().collect(Collectors.toList())); List pairs = functionSchema.getParamsList(); - pairs.forEach((kv)->builder.param(kv.getKey(), kv.getValue())); + pairs.forEach((kv) -> builder.param(kv.getKey(), kv.getValue())); return builder.build(); } diff --git a/sdk-core/src/main/java/io/milvus/v2/utils/VectorUtils.java b/sdk-core/src/main/java/io/milvus/v2/utils/VectorUtils.java index 8e3019cfa..0cad8284f 100644 --- a/sdk-core/src/main/java/io/milvus/v2/utils/VectorUtils.java +++ b/sdk-core/src/main/java/io/milvus/v2/utils/VectorUtils.java @@ -26,27 +26,30 @@ import com.google.protobuf.ByteString; import io.milvus.common.utils.GTsDict; import io.milvus.common.utils.JsonUtils; -import io.milvus.v2.common.ConsistencyLevel; import io.milvus.exception.ParamException; import io.milvus.grpc.*; import io.milvus.param.Constant; import io.milvus.param.ParamUtils; +import io.milvus.v2.common.ConsistencyLevel; import io.milvus.v2.exception.ErrorCode; import io.milvus.v2.exception.MilvusClientException; import io.milvus.v2.service.collection.request.CreateCollectionReq; import io.milvus.v2.service.vector.request.*; import io.milvus.v2.service.vector.request.FunctionScore; -import io.milvus.v2.service.vector.request.data.*; +import io.milvus.v2.service.vector.request.data.BaseVector; import io.milvus.v2.service.vector.request.ranker.RRFRanker; import io.milvus.v2.service.vector.request.ranker.WeightedRanker; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class VectorUtils { - public QueryRequest ConvertToGrpcQueryRequest(QueryReq request){ + public QueryRequest ConvertToGrpcQueryRequest(QueryReq request) { if (request == null) { throw new NullPointerException("request cannot be null"); } @@ -65,7 +68,7 @@ public QueryRequest ConvertToGrpcQueryRequest(QueryReq request){ if (StringUtils.isNotEmpty(request.getFilter())) { Map filterTemplateValues = request.getFilterTemplateValues(); - filterTemplateValues.forEach((key, value)->{ + filterTemplateValues.forEach((key, value) -> { builder.putExprTemplateValues(key, deduceAndCreateTemplateValue(value)); }); } @@ -115,13 +118,13 @@ public QueryRequest ConvertToGrpcQueryRequest(QueryReq request){ } - private static long getGuaranteeTimestamp(ConsistencyLevel consistencyLevel, String dbName, String collectionName){ - if(consistencyLevel == null){ + private static long getGuaranteeTimestamp(ConsistencyLevel consistencyLevel, String dbName, String collectionName) { + if (consistencyLevel == null) { String key = GTsDict.CombineCollectionName(dbName, collectionName); Long ts = GTsDict.getInstance().getCollectionTs(key); - return (ts == null) ? 1L : ts; + return (ts == null) ? 1L : ts; } - switch (consistencyLevel){ + switch (consistencyLevel) { case STRONG: return 0L; case SESSION: { @@ -140,7 +143,7 @@ private static ByteString convertPlaceholder(List data, PlaceholderType if (placeType == PlaceholderType.VarChar) { List byteStrings = new ArrayList<>(); for (Object obj : data) { - byteStrings.add(ByteString.copyFrom(((String)obj).getBytes())); + byteStrings.add(ByteString.copyFrom(((String) obj).getBytes())); } PlaceholderValue.Builder pldBuilder = PlaceholderValue.newBuilder() .setTag(Constant.VECTOR_TAG) @@ -228,9 +231,9 @@ public SearchRequest ConvertToGrpcSearchRequest(SearchReq request) { .build()) .addSearchParams( KeyValuePair.newBuilder() - .setKey(Constant.OFFSET) - .setValue(String.valueOf(request.getOffset())) - .build()); + .setKey(Constant.OFFSET) + .setValue(String.valueOf(request.getOffset())) + .build()); if (null != request.getMetricType()) { builder.addSearchParams( @@ -272,7 +275,7 @@ public SearchRequest ConvertToGrpcSearchRequest(SearchReq request) { if (request.getFilter() != null && !request.getFilter().isEmpty()) { builder.setDsl(request.getFilter()); Map filterTemplateValues = request.getFilterTemplateValues(); - filterTemplateValues.forEach((key, value)->{ + filterTemplateValues.forEach((key, value) -> { builder.putExprTemplateValues(key, deduceAndCreateTemplateValue(value)); }); } @@ -281,7 +284,7 @@ public SearchRequest ConvertToGrpcSearchRequest(SearchReq request) { if (request.getSearchParams().containsKey("iterator")) { long guaranteeTimestamp = 0; if (request.getSearchParams().containsKey("guarantee_timestamp")) { - guaranteeTimestamp = (long)request.getSearchParams().get("guarantee_timestamp"); + guaranteeTimestamp = (long) request.getSearchParams().get("guarantee_timestamp"); } builder.setGuaranteeTimestamp(guaranteeTimestamp); } else { @@ -319,63 +322,63 @@ private static TemplateArrayValue deduceTemplateArray(List array) { Object firstObj = array.get(0); if (firstObj instanceof Boolean) { BoolArray.Builder builder = BoolArray.newBuilder(); - array.forEach(val->{ + array.forEach(val -> { if (!(val instanceof Boolean)) { throw new MilvusClientException(ErrorCode.INVALID_PARAMS, "Filter expression template is a list, the first value is Boolean, but some elements are not Boolean"); } - builder.addData((Boolean)val); + builder.addData((Boolean) val); }); return TemplateArrayValue.newBuilder().setBoolData(builder.build()).build(); } else if (firstObj instanceof Integer || firstObj instanceof Long) { LongArray.Builder builder = LongArray.newBuilder(); - array.forEach(val->{ + array.forEach(val -> { if (!(val instanceof Integer) && !(val instanceof Long)) { throw new MilvusClientException(ErrorCode.INVALID_PARAMS, "Filter expression template is a list, the first value is Integer/Long, but some elements are not Integer/Long"); } - builder.addData((val instanceof Integer) ? (Integer)val : (Long)val); + builder.addData((val instanceof Integer) ? (Integer) val : (Long) val); }); return TemplateArrayValue.newBuilder().setLongData(builder.build()).build(); } else if (firstObj instanceof Double) { DoubleArray.Builder builder = DoubleArray.newBuilder(); - array.forEach(val->{ + array.forEach(val -> { if (!(val instanceof Double)) { throw new MilvusClientException(ErrorCode.INVALID_PARAMS, "Filter expression template is a list, the first value is Double, but some elements are not Double"); } - builder.addData((Double)val); + builder.addData((Double) val); }); return TemplateArrayValue.newBuilder().setDoubleData(builder.build()).build(); } else if (firstObj instanceof String) { StringArray.Builder builder = StringArray.newBuilder(); - array.forEach(val->{ + array.forEach(val -> { if (!(val instanceof String)) { throw new MilvusClientException(ErrorCode.INVALID_PARAMS, "Filter expression template is a list, the first value is String, but some elements are not String"); } - builder.addData((String)val); + builder.addData((String) val); }); return TemplateArrayValue.newBuilder().setStringData(builder.build()).build(); } else if (firstObj instanceof JsonElement) { JSONArray.Builder builder = JSONArray.newBuilder(); - array.forEach(val->{ + array.forEach(val -> { if (!(val instanceof JsonElement)) { throw new MilvusClientException(ErrorCode.INVALID_PARAMS, "Filter expression template is a list, the first value is JsonElement, but some elements are not JsonElement"); } - String str = JsonUtils.toJson((JsonElement)val); + String str = JsonUtils.toJson((JsonElement) val); builder.addData(ByteString.copyFromUtf8(str)); }); return TemplateArrayValue.newBuilder().setJsonData(builder.build()).build(); } else if (firstObj instanceof List) { TemplateArrayValueArray.Builder builder = TemplateArrayValueArray.newBuilder(); - array.forEach(val->{ + array.forEach(val -> { if (!(val instanceof List)) { throw new MilvusClientException(ErrorCode.INVALID_PARAMS, "Filter expression template is a list, the first value is List, but some elements are not List"); } - List subArrary = (List)val; + List subArrary = (List) val; builder.addData(deduceTemplateArray(subArrary)); }); @@ -389,22 +392,22 @@ private static TemplateArrayValue deduceTemplateArray(List array) { public static TemplateValue deduceAndCreateTemplateValue(Object value) { if (value instanceof Boolean) { return TemplateValue.newBuilder() - .setBoolVal((Boolean)value) + .setBoolVal((Boolean) value) .build(); } else if (value instanceof Integer || value instanceof Long) { - return TemplateValue.newBuilder() - .setInt64Val((value instanceof Integer) ? (Integer)value : (Long)value) - .build(); + return TemplateValue.newBuilder() + .setInt64Val((value instanceof Integer) ? (Integer) value : (Long) value) + .build(); } else if (value instanceof Double) { return TemplateValue.newBuilder() - .setFloatVal((Double)value) + .setFloatVal((Double) value) .build(); } else if (value instanceof String) { return TemplateValue.newBuilder() - .setStringVal((String)value) + .setStringVal((String) value) .build(); } else if (value instanceof List) { - List array = (List)value; + List array = (List) value; TemplateArrayValue tav = deduceTemplateArray(array); return TemplateValue.newBuilder() .setArrayVal(tav) @@ -445,7 +448,8 @@ public static SearchRequest convertAnnSearchParam(AnnSearchReq annSearchReq, // tries to fit the compatibility between v2.5.1 and older versions Map paramMap = new HashMap<>(); if (null != annSearchReq.getParams() && !annSearchReq.getParams().isEmpty()) { - paramMap = JsonUtils.fromJson(annSearchReq.getParams(), new TypeToken>() {}.getType()); + paramMap = JsonUtils.fromJson(annSearchReq.getParams(), new TypeToken>() { + }.getType()); } ParamUtils.compatibleSearchParams(paramMap, builder); diff --git a/sdk-core/src/test/java/io/milvus/TestUtils.java b/sdk-core/src/test/java/io/milvus/TestUtils.java index 710417078..699e071dd 100644 --- a/sdk-core/src/test/java/io/milvus/TestUtils.java +++ b/sdk-core/src/test/java/io/milvus/TestUtils.java @@ -108,7 +108,7 @@ public List generateRandomArray(DataType eleType, int maxCapacity) { case Bool: { List values = new ArrayList<>(); for (int i = 0; i < maxCapacity; i++) { - values.add(i%10 == 0); + values.add(i % 10 == 0); } return values; } @@ -116,7 +116,7 @@ public List generateRandomArray(DataType eleType, int maxCapacity) { case Int16: { List values = new ArrayList<>(); for (int i = 0; i < maxCapacity; i++) { - values.add((short)RANDOM.nextInt(256)); + values.add((short) RANDOM.nextInt(256)); } return values; } diff --git a/sdk-core/src/test/java/io/milvus/client/MilvusClientDockerTest.java b/sdk-core/src/test/java/io/milvus/client/MilvusClientDockerTest.java index 2f8bf3d30..82737206f 100644 --- a/sdk-core/src/test/java/io/milvus/client/MilvusClientDockerTest.java +++ b/sdk-core/src/test/java/io/milvus/client/MilvusClientDockerTest.java @@ -19,9 +19,11 @@ package io.milvus.client; -import com.google.gson.*; import com.google.common.collect.Lists; import com.google.common.util.concurrent.ListenableFuture; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +import com.google.gson.JsonObject; import io.milvus.TestUtils; import io.milvus.common.clientenum.ConsistencyLevelEnum; import io.milvus.common.utils.Float16Utils; @@ -49,12 +51,10 @@ import io.milvus.pool.MilvusClientV1Pool; import io.milvus.pool.PoolConfig; import io.milvus.response.*; - import org.apache.commons.text.RandomStringGenerator; - +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; @@ -197,7 +197,7 @@ private List generateColumnsData(CollectionSchemaParam schema case Bool: { List data = new ArrayList<>(); for (int i = idStart; i < idStart + count; ++i) { - data.add(i%3==0 ? true : false); + data.add(i % 3 == 0); } columns.add(new InsertParam.Field(fieldType.getName(), data)); break; @@ -206,7 +206,7 @@ private List generateColumnsData(CollectionSchemaParam schema case Int16: { List data = new ArrayList<>(); for (int i = idStart; i < idStart + count; ++i) { - data.add((short) (i%128)); + data.add((short) (i % 128)); } columns.add(new InsertParam.Field(fieldType.getName(), data)); break; @@ -222,7 +222,7 @@ private List generateColumnsData(CollectionSchemaParam schema case Int64: { List data = new ArrayList<>(); for (int i = idStart; i < idStart + count; ++i) { - data.add((long)i); + data.add((long) i); } columns.add(new InsertParam.Field(fieldType.getName(), data)); break; @@ -230,7 +230,7 @@ private List generateColumnsData(CollectionSchemaParam schema case Float: { List data = new ArrayList<>(); for (int i = idStart; i < idStart + count; ++i) { - data.add((float)i/3); + data.add((float) i / 3); } columns.add(new InsertParam.Field(fieldType.getName(), data)); break; @@ -238,7 +238,7 @@ private List generateColumnsData(CollectionSchemaParam schema case Double: { List data = new ArrayList<>(); for (int i = idStart; i < idStart + count; ++i) { - data.add((double)i/7); + data.add((double) i / 7); } columns.add(new InsertParam.Field(fieldType.getName(), data)); break; @@ -326,19 +326,19 @@ private List generateRowsData(CollectionSchemaParam schema, int coun break; case Int8: case Int16: - row.addProperty(fieldType.getName(), (short)(i%128)); + row.addProperty(fieldType.getName(), (short) (i % 128)); break; case Int32: row.addProperty(fieldType.getName(), i); break; case Int64: - row.addProperty(fieldType.getName(), (long)i); + row.addProperty(fieldType.getName(), (long) i); break; case Float: - row.addProperty(fieldType.getName(), (float)i/3); + row.addProperty(fieldType.getName(), (float) i / 3); break; case Double: - row.addProperty(fieldType.getName(), (float)i/7); + row.addProperty(fieldType.getName(), (float) i / 7); break; case VarChar: row.addProperty(fieldType.getName(), String.format("varchar_%d", i)); @@ -425,7 +425,7 @@ void testFloatVectors() { ShowPartResponseWrapper wra = new ShowPartResponseWrapper(spResp.getData()); List parts = wra.getPartitionsInfo(); - System.out.println("Partition num: "+parts.size()); + System.out.println("Partition num: " + parts.size()); // insert data int rowCount = 10000; @@ -514,7 +514,7 @@ void testFloatVectors() { Assertions.assertTrue(indexDesc.getIndexFailedReason().isEmpty()); String extraParams = indexDesc.getExtraParam(); Assertions.assertEquals(params.replace("\"", ""), extraParams.replace("\"", "")); - System.out.println("Index description: " + indexDesc.toString()); + System.out.println("Index description: " + indexDesc); R alterR = client.alterIndex(AlterIndexParam.newBuilder() .withCollectionName(randomCollectionName) @@ -542,7 +542,7 @@ void testFloatVectors() { .build()); Assertions.assertEquals(R.Status.Success.getCode(), showR.getStatus().intValue()); ShowCollResponseWrapper info = new ShowCollResponseWrapper(showR.getData()); - System.out.println("Collection info: " + info.toString()); + System.out.println("Collection info: " + info); // show partitions R showPartR = client.showPartitions(ShowPartitionsParam.newBuilder() @@ -551,11 +551,11 @@ void testFloatVectors() { .build()); Assertions.assertEquals(R.Status.Success.getCode(), showPartR.getStatus().intValue()); ShowPartResponseWrapper infoPart = new ShowPartResponseWrapper(showPartR.getData()); - System.out.println("Partition info: " + infoPart.toString()); + System.out.println("Partition info: " + infoPart); // query Long fetchID = 100L; - List fetchVector = (List)columnsData.get(1).getValues().get(fetchID.intValue()); + List fetchVector = (List) columnsData.get(1).getValues().get(fetchID.intValue()); R fetchR = client.query(QueryParam.newBuilder() .withCollectionName(randomCollectionName) .withExpr(String.format("id == %d", fetchID)) @@ -582,7 +582,7 @@ void testFloatVectors() { int randomIndex = ran.nextInt(rowCount - nq); for (int i = randomIndex; i < randomIndex + nq; ++i) { Assertions.assertInstanceOf(Long.class, columnsData.get(0).getValues().get(i)); - queryIDs.add((Long)columnsData.get(0).getValues().get(i)); + queryIDs.add((Long) columnsData.get(0).getValues().get(i)); Assertions.assertInstanceOf(Double.class, columnsData.get(3).getValues().get(i)); compareWeights.add((Double) columnsData.get(3).getValues().get(i)); } @@ -660,15 +660,15 @@ void testFloatVectors() { List targetVectorIDs = new ArrayList<>(); List> targetVectors = new ArrayList<>(); for (int i = randomIndex; i < randomIndex + nq; ++i) { - targetVectorIDs.add((Long)columnsData.get(0).getValues().get(i)); - targetVectors.add((List)columnsData.get(1).getValues().get(i)); + targetVectorIDs.add((Long) columnsData.get(0).getValues().get(i)); + targetVectors.add((List) columnsData.get(1).getValues().get(i)); } int topK = 5; SearchParam searchParam = SearchParam.newBuilder() .withCollectionName(randomCollectionName) .withMetricType(MetricType.L2) - .withLimit((long)topK) + .withLimit((long) topK) .withFloatVectors(targetVectors) .withVectorFieldName(DataType.FloatVector.name()) .withParams("{\"ef\":64}") @@ -690,7 +690,7 @@ void testFloatVectors() { Object obj = scores.get(0).get(DataType.FloatVector.name()); Assertions.assertInstanceOf(List.class, obj); - List outputVec = (List)obj; + List outputVec = (List) obj; Assertions.assertEquals(targetVectors.get(i).size(), outputVec.size()); for (int k = 0; k < outputVec.size(); k++) { Assertions.assertEquals(targetVectors.get(i).get(k), outputVec.get(k)); @@ -699,12 +699,12 @@ void testFloatVectors() { // verify the old way List records = results.getRowRecords(i); obj = records.get(0).get(DataType.FloatVector.name()); - outputVec = (List)obj; + outputVec = (List) obj; Assertions.assertEquals(targetVectors.get(i).size(), outputVec.size()); for (int k = 0; k < outputVec.size(); k++) { Assertions.assertEquals(targetVectors.get(i).get(k), outputVec.get(k)); } - double d = (double)records.get(0).get(DataType.Double.name()); + double d = (double) records.get(0).get(DataType.Double.name()); Assertions.assertEquals(d, compareWeights.get(i)); } @@ -797,9 +797,9 @@ void testBinaryVectors() throws InterruptedException { Assertions.assertEquals(rowCount, ids2.size()); // insert test vector, position() is zero with ByteBuffer.wrap() - byte[] byteArray = new byte[DIMENSION/8]; + byte[] byteArray = new byte[DIMENSION / 8]; for (int i = 0; i < byteArray.length; i++) { - byteArray[i] = (byte) ((i%3 == 0) ? 255 : 0); + byteArray[i] = (byte) ((i % 3 == 0) ? 255 : 0); } ByteBuffer testBuffer = ByteBuffer.wrap(byteArray); List testData = @@ -821,10 +821,10 @@ void testBinaryVectors() throws InterruptedException { GetCollStatResponseWrapper stat = new GetCollStatResponseWrapper(statR.getData()); System.out.println("Collection row count: " + stat.getRowCount()); - Assertions.assertEquals(2*rowCount+1, stat.getRowCount()); + Assertions.assertEquals(2 * rowCount + 1, stat.getRowCount()); // check index - while(true) { + while (true) { DescribeIndexParam descIndexParam = DescribeIndexParam.newBuilder() .withCollectionName(randomCollectionName) .withFieldName(DataType.BinaryVector.name()) @@ -843,8 +843,8 @@ void testBinaryVectors() throws InterruptedException { Assertions.assertEquals(DataType.BinaryVector.name(), indexDesc.getFieldName()); Assertions.assertEquals(IndexType.BIN_IVF_FLAT, indexDesc.getIndexType()); Assertions.assertEquals(MetricType.JACCARD, indexDesc.getMetricType()); - Assertions.assertEquals(2*rowCount+1, indexDesc.getTotalRows()); - Assertions.assertEquals(2*rowCount+1, indexDesc.getIndexedRows()); + Assertions.assertEquals(2 * rowCount + 1, indexDesc.getTotalRows()); + Assertions.assertEquals(2 * rowCount + 1, indexDesc.getIndexedRows()); Assertions.assertEquals(0L, indexDesc.getPendingIndexRows()); Assertions.assertTrue(indexDesc.getIndexFailedReason().isEmpty()); System.out.println("Index description: " + indexDesc); @@ -859,7 +859,7 @@ void testBinaryVectors() throws InterruptedException { // query Long fetchID = ids1.get(0); - ByteBuffer fetchVector = (ByteBuffer)columnsData.get(0).getValues().get(0); + ByteBuffer fetchVector = (ByteBuffer) columnsData.get(0).getValues().get(0); R fetchR = client.query(QueryParam.newBuilder() .withCollectionName(randomCollectionName) .withExpr(String.format("id == %d", fetchID)) @@ -877,7 +877,7 @@ void testBinaryVectors() throws InterruptedException { // search with BIN_FLAT index int searchTarget = 99; - ByteBuffer targetVector = (ByteBuffer)columnsData.get(0).getValues().get(searchTarget); + ByteBuffer targetVector = (ByteBuffer) columnsData.get(0).getValues().get(searchTarget); SearchParam searchOneParam = SearchParam.newBuilder() .withCollectionName(randomCollectionName) @@ -949,7 +949,7 @@ void testBinaryVectors() throws InterruptedException { SearchParam searchParam = SearchParam.newBuilder() .withCollectionName(randomCollectionName) .withMetricType(MetricType.HAMMING) - .withLimit((long)topK) + .withLimit((long) topK) .withBinaryVectors(targetVectors) .withVectorFieldName(DataType.BinaryVector.name()) .withParams("{\"nprobe\":8}") @@ -1026,8 +1026,8 @@ void testSparseVector() { Assertions.assertEquals(R.Status.Success.getCode(), loadR.getStatus().intValue()); // query - Long fetchID = (Long)columnsData.get(0).getValues().get(0); - SortedMap fetchVector = (SortedMap)columnsData.get(1).getValues().get(0); + Long fetchID = (Long) columnsData.get(0).getValues().get(0); + SortedMap fetchVector = (SortedMap) columnsData.get(1).getValues().get(0); R fetchR = client.query(QueryParam.newBuilder() .withCollectionName(randomCollectionName) .withExpr(String.format("id == %d", fetchID)) @@ -1055,8 +1055,8 @@ void testSparseVector() { Random ran = new Random(); int randomIndex = ran.nextInt(rowCount); for (int i = randomIndex; i < randomIndex + nq; ++i) { - targetVectorIDs.add((Long)columnsData.get(0).getValues().get(i)); - targetVectors.add((SortedMap)columnsData.get(1).getValues().get(i)); + targetVectorIDs.add((Long) columnsData.get(0).getValues().get(i)); + targetVectors.add((SortedMap) columnsData.get(1).getValues().get(i)); } System.out.println("Search target IDs:" + targetVectorIDs); @@ -1066,7 +1066,7 @@ void testSparseVector() { SearchParam searchParam = SearchParam.newBuilder() .withCollectionName(randomCollectionName) .withMetricType(MetricType.IP) - .withLimit((long)topK) + .withLimit((long) topK) .withSparseFloatVectors(targetVectors) .withVectorFieldName(DataType.SparseFloatVector.name()) .addOutField(DataType.SparseFloatVector.name()) @@ -1089,7 +1089,7 @@ void testSparseVector() { Assertions.assertEquals(targetVectorIDs.get(i), scores.get(0).getLongID()); Object v = scores.get(0).get(DataType.SparseFloatVector.name()); - SortedMap sparse = (SortedMap)v; + SortedMap sparse = (SortedMap) v; Assertions.assertEquals(sparse, targetVectors.get(i)); Assertions.assertEquals(targetVectors.get(i).size(), sparse.size()); for (Long key : sparse.keySet()) { @@ -1181,7 +1181,7 @@ void testFloat16Vector() { List bf16Vectors = new ArrayList<>(); List ids = new ArrayList<>(); for (int i = 0; i < 5000; i++) { - ids.add((long)i); + ids.add((long) i); List vector = vectors.get(i); ByteBuffer fp16Vector = Float16Utils.f32VectorToFp16Buffer(vector); fp16Vectors.add(fp16Vector); @@ -1269,7 +1269,7 @@ void testFloat16Vector() { R searchR = client.search(SearchParam.newBuilder() .withCollectionName(randomCollectionName) .withMetricType(MetricType.COSINE) - .withLimit((long)topK) + .withLimit((long) topK) .withFloat16Vectors(Collections.singletonList(fp16Vector)) .withVectorFieldName(DataType.Float16Vector.name()) .addOutField(DataType.Float16Vector.name()) @@ -1286,7 +1286,7 @@ void testFloat16Vector() { Object v = scores.get(0).get(DataType.Float16Vector.name()); Assertions.assertInstanceOf(ByteBuffer.class, v); - List fp16Vec = Float16Utils.fp16BufferToVector((ByteBuffer)v); + List fp16Vec = Float16Utils.fp16BufferToVector((ByteBuffer) v); Assertions.assertEquals(fp16Vec.size(), originVector.size()); for (int k = 0; k < fp16Vec.size(); k++) { Assertions.assertTrue(Math.abs(fp16Vec.get(k) - originVector.get(k)) <= FLOAT16_PRECISION); @@ -1297,7 +1297,7 @@ void testFloat16Vector() { searchR = client.search(SearchParam.newBuilder() .withCollectionName(randomCollectionName) .withMetricType(MetricType.COSINE) - .withLimit((long)topK) + .withLimit((long) topK) .withParams("{\"nprobe\": 16}") .withBFloat16Vectors(Collections.singletonList(bf16Vector)) .withVectorFieldName(DataType.BFloat16Vector.name()) @@ -1315,7 +1315,7 @@ void testFloat16Vector() { v = scores.get(0).get(DataType.BFloat16Vector.name()); Assertions.assertInstanceOf(ByteBuffer.class, v); - List bf16Vec = Float16Utils.bf16BufferToVector((ByteBuffer)v); + List bf16Vec = Float16Utils.bf16BufferToVector((ByteBuffer) v); Assertions.assertEquals(bf16Vec.size(), originVector.size()); for (int k = 0; k < bf16Vec.size(); k++) { Assertions.assertTrue(Math.abs(bf16Vec.get(k) - originVector.get(k)) <= BFLOAT16_PRECISION); @@ -1435,10 +1435,10 @@ void testMultipleVectorFields() { }; // search with an empty nq, return error - Assertions.assertThrows(ParamException.class, ()->genRequestFunc.apply(0)); + Assertions.assertThrows(ParamException.class, () -> genRequestFunc.apply(0)); // unequal nq, return error - Assertions.assertThrows(ParamException.class, ()->genRequestFunc.apply(1)); + Assertions.assertThrows(ParamException.class, () -> genRequestFunc.apply(1)); // search on empty collection, no result returned R searchR = client.hybridSearch(genRequestFunc.apply(nq)); @@ -1471,12 +1471,12 @@ void testMultipleVectorFields() { Assertions.assertInstanceOf(Long.class, id); Object fv = score.get(DataType.FloatVector.name()); Assertions.assertInstanceOf(List.class, fv); - List fvec = (List)fv; + List fvec = (List) fv; Assertions.assertEquals(DIMENSION, fvec.size()); Object bv = score.get(DataType.BinaryVector.name()); Assertions.assertInstanceOf(ByteBuffer.class, bv); - ByteBuffer bvec = (ByteBuffer)bv; - Assertions.assertEquals(DIMENSION, bvec.limit()*8); + ByteBuffer bvec = (ByteBuffer) bv; + Assertions.assertEquals(DIMENSION, bvec.limit() * 8); Object sv = score.get(DataType.SparseFloatVector.name()); Assertions.assertInstanceOf(SortedMap.class, sv); } @@ -1581,7 +1581,7 @@ void testAsyncMethods() { SearchParam searchParam = SearchParam.newBuilder() .withCollectionName(randomCollectionName) .withMetricType(MetricType.IP) - .withLimit((long)topK) + .withLimit((long) topK) .withVectors(targetVectors) .withVectorFieldName(DataType.FloatVector.name()) .build(); @@ -1710,7 +1710,7 @@ void testStringField() { .build()); DescCollResponseWrapper desc = new DescCollResponseWrapper(response.getData()); - System.out.println(desc.toString()); + System.out.println(desc); // insert data int rowCount = 10000; @@ -1786,8 +1786,8 @@ void testStringField() { Random ran = new Random(); int randomIndex = ran.nextInt(rowCount - nq); for (int i = randomIndex; i < randomIndex + nq; ++i) { - queryIds.add((String)columnsData.get(0).getValues().get(i)); - queryItems.add((Long)columnsData.get(3).getValues().get(i)); + queryIds.add((String) columnsData.get(0).getValues().get(i)); + queryItems.add((Long) columnsData.get(3).getValues().get(i)); } String expr = DataType.Int64.name() + " in " + queryItems; List outputFields = Arrays.asList("id", DataType.VarChar.name()); @@ -1823,12 +1823,12 @@ void testStringField() { int topK = 5; List> targetVectors = new ArrayList<>(); for (Long seq : queryItems) { - targetVectors.add((List)columnsData.get(1).getValues().get(seq.intValue())); + targetVectors.add((List) columnsData.get(1).getValues().get(seq.intValue())); } SearchParam searchParam = SearchParam.newBuilder() .withCollectionName(randomCollectionName) .withMetricType(MetricType.IP) - .withLimit((long)topK) + .withLimit((long) topK) .withFloatVectors(targetVectors) .withVectorFieldName(DataType.FloatVector.name()) .addOutField(DataType.Int64.name()) @@ -1977,7 +1977,7 @@ void testDynamicField() { .build()); DescCollResponseWrapper desc = new DescCollResponseWrapper(response.getData()); - System.out.println(desc.toString()); + System.out.println(desc); // create index CreateIndexParam indexParam = CreateIndexParam.newBuilder() @@ -2048,7 +2048,7 @@ void testDynamicField() { QueryResultsWrapper queryResultsWrapper = new QueryResultsWrapper(queryR.getData()); List records = queryResultsWrapper.getRowRecords(); System.out.println("Query results with expr: " + expr); - for (QueryResultsWrapper.RowRecord record:records) { + for (QueryResultsWrapper.RowRecord record : records) { System.out.println(record); Object extraMeta = record.get("dynamic"); Assertions.assertInstanceOf(Long.class, extraMeta); @@ -2059,13 +2059,13 @@ void testDynamicField() { // search the No.11 and No.15 target = Arrays.asList(1L, 5L); List> targetVectors = new ArrayList<>(); - targetVectors.add((List)columnsData.get(1).getValues().get(target.get(0).intValue())); - targetVectors.add((List)columnsData.get(1).getValues().get(target.get(1).intValue())); + targetVectors.add((List) columnsData.get(1).getValues().get(target.get(0).intValue())); + targetVectors.add((List) columnsData.get(1).getValues().get(target.get(1).intValue())); int topK = 5; SearchParam searchParam = SearchParam.newBuilder() .withCollectionName(randomCollectionName) .withMetricType(MetricType.COSINE) - .withLimit((long)topK) + .withLimit((long) topK) .withFloatVectors(targetVectors) .withVectorFieldName(DataType.FloatVector.name()) .withParams("{}") @@ -2085,7 +2085,7 @@ void testDynamicField() { System.out.println(score); Object extraMeta = score.get("dynamic"); Assertions.assertInstanceOf(Long.class, extraMeta); - Long k = (Long)extraMeta - rowCount; + Long k = (Long) extraMeta - rowCount; Assertions.assertTrue(target.contains(k)); System.out.println("'dynamic' is from dynamic field, value: " + extraMeta); } @@ -2105,17 +2105,17 @@ void testDynamicField() { queryResultsWrapper = new QueryResultsWrapper(queryR.getData()); records = queryResultsWrapper.getRowRecords(); System.out.println("Query results with expr: " + expr); - for (QueryResultsWrapper.RowRecord record:records) { + for (QueryResultsWrapper.RowRecord record : records) { System.out.println(record); - long id = (long)record.get("id"); + long id = (long) record.get("id"); Assertions.assertEquals(18L, id); Object vec = record.get(DataType.FloatVector.name()); Assertions.assertInstanceOf(List.class, vec); - List vector = (List)vec; + List vector = (List) vec; Assertions.assertEquals(DIMENSION, vector.size()); Object j = record.get(DataType.JSON.name()); Assertions.assertInstanceOf(JsonObject.class, j); - JsonObject jon = (JsonObject)j; + JsonObject jon = (JsonObject) j; Assertions.assertTrue(jon.has("json")); } @@ -2172,14 +2172,14 @@ void testArrayField() { List> intArrArray = new ArrayList<>(); List> floatArrArray = new ArrayList<>(); for (int i = 0; i < rowCount; i++) { - ids.add((long)i); + ids.add((long) i); List strArray = new ArrayList<>(); List intArray = new ArrayList<>(); List floatArray = new ArrayList<>(); for (int k = 0; k < i; k++) { strArray.add(String.format("C_StringArray_%d_%d", i, k)); - intArray.add(i*10000 + k); - floatArray.add((float)k/1000 + i); + intArray.add(i * 10000 + k); + floatArray.add((float) k / 1000 + i); } strArrArray.add(strArray); intArrArray.add(intArray); @@ -2207,7 +2207,7 @@ void testArrayField() { List rows = new ArrayList<>(); for (int i = 0; i < rowCount; ++i) { JsonObject row = new JsonObject(); - row.addProperty("id", 10000L + (long)i); + row.addProperty("id", 10000L + (long) i); List vector = utils.generateFloatVectors(1).get(0); row.add(DataType.FloatVector.name(), JsonUtils.toJsonTree(vector)); @@ -2216,8 +2216,8 @@ void testArrayField() { List floatArray = new ArrayList<>(); for (int k = 0; k < i; k++) { strArray.add(String.format("R_StringArray_%d_%d", i, k)); - intArray.add(i*10000 + k); - floatArray.add((float)k/1000 + i); + intArray.add(i * 10000 + k); + floatArray.add((float) k / 1000 + i); } row.add(varcharArrayName, JsonUtils.toJsonTree(strArray)); row.add(intArrayName, JsonUtils.toJsonTree(intArray)); @@ -2259,12 +2259,12 @@ void testArrayField() { for (SearchResultsWrapper.IDScore score : scores) { // System.out.println(score); long id = score.getLongID(); - List strArray = (List)score.get(varcharArrayName); - Assertions.assertEquals(id%10000, (long)strArray.size()); - List intArray = (List)score.get(intArrayName); - Assertions.assertEquals(id%10000, (long)intArray.size()); - List floatArray = (List)score.get(floatArrayName); - Assertions.assertEquals(id%10000, (long)floatArray.size()); + List strArray = (List) score.get(varcharArrayName); + Assertions.assertEquals(id % 10000, strArray.size()); + List intArray = (List) score.get(intArrayName); + Assertions.assertEquals(id % 10000, intArray.size()); + List floatArray = (List) score.get(floatArrayName); + Assertions.assertEquals(id % 10000, floatArray.size()); } // search with array_contains @@ -2383,7 +2383,7 @@ void testUpsert() throws InterruptedException { QueryResultsWrapper queryResultsWrapper = new QueryResultsWrapper(queryR.getData()); List records = queryResultsWrapper.getRowRecords(); System.out.println("Query results in sealed segment:"); - for (QueryResultsWrapper.RowRecord record:records) { + for (QueryResultsWrapper.RowRecord record : records) { System.out.println(record); Object name = record.get(DataType.VarChar.name()); Assertions.assertNotNull(name); @@ -2426,7 +2426,7 @@ void testUpsert() throws InterruptedException { queryResultsWrapper = new QueryResultsWrapper(queryR.getData()); records = queryResultsWrapper.getRowRecords(); System.out.println("Query results in growing segment:"); - for (QueryResultsWrapper.RowRecord record:records) { + for (QueryResultsWrapper.RowRecord record : records) { System.out.println(record); Object name = record.get(DataType.VarChar.name()); Assertions.assertNotNull(name); @@ -2766,7 +2766,7 @@ public void testIterator() { row.addProperty("id", Long.toString(i)); row.add(DataType.FloatVector.name(), JsonUtils.toJsonTree(utils.generateFloatVectors(1).get(0))); JsonObject json = new JsonObject(); - if (i%2 == 0) { + if (i % 2 == 0) { json.addProperty("even", true); } row.add(DataType.JSON.name(), json); @@ -2825,7 +2825,7 @@ public void testIterator() { Assertions.assertInstanceOf(String.class, record.get("id")); Object vec = record.get(DataType.FloatVector.name()); Assertions.assertInstanceOf(List.class, vec); - List vector = (List)vec; + List vector = (List) vec; Assertions.assertEquals(DIMENSION, vector.size()); Assertions.assertInstanceOf(JsonElement.class, record.get(DataType.JSON.name())); // System.out.println(record); @@ -2863,7 +2863,7 @@ public void testIterator() { Assertions.assertInstanceOf(String.class, record.get("id")); Object vec = record.get(DataType.FloatVector.name()); Assertions.assertInstanceOf(List.class, vec); - List vector = (List)vec; + List vector = (List) vec; Assertions.assertEquals(DIMENSION, vector.size()); Assertions.assertInstanceOf(JsonElement.class, record.get(DataType.JSON.name())); // System.out.println(record); @@ -2879,7 +2879,7 @@ void testDatabase() { CreateDatabaseParam createDatabaseParam = CreateDatabaseParam.newBuilder() .withDatabaseName(dbName) .withReplicaNumber(1) - .withResourceGroups(Arrays.asList("rg1")) + .withResourceGroups(Collections.singletonList("rg1")) .build(); R createResponse = client.createDatabase(createDatabaseParam); Assertions.assertEquals(R.Status.Success.getCode(), createResponse.getStatus().intValue()); @@ -3155,7 +3155,7 @@ void testClientPool() { System.out.printf("idle %d, active %d%n", pool.getIdleClientNumber(key), pool.getActiveClientNumber(key)); pool.returnClient(key, client); } - System.out.println(String.format("Thread %s finished", Thread.currentThread().getName())); + System.out.printf("Thread %s finished%n", Thread.currentThread().getName()); }); t.start(); threadList.add(t); @@ -3165,7 +3165,7 @@ void testClientPool() { t.join(); } - System.out.println(String.format("idle %d, active %d", pool.getIdleClientNumber(key), pool.getActiveClientNumber(key))); + System.out.printf("idle %d, active %d%n", pool.getIdleClientNumber(key), pool.getActiveClientNumber(key)); pool.close(); } catch (Exception e) { System.out.println(e.getMessage()); @@ -3229,7 +3229,7 @@ void testNullableAndDefaultValue() { List vector = utils.generateFloatVector(); row.addProperty("id", i); row.add("vector", JsonUtils.toJsonTree(vector)); - if (i%2 == 0) { + if (i % 2 == 0) { row.addProperty("flag", i); row.add("desc", JsonNull.INSTANCE); } else { @@ -3250,8 +3250,8 @@ void testNullableAndDefaultValue() { List flags = new ArrayList<>(); List descs = new ArrayList<>(); for (int i = 10; i < 20; i++) { - ids.add((long)i); - if (i%2 == 0) { + ids.add((long) i); + if (i % 2 == 0) { flags.add(i); descs.add(null); } else { @@ -3290,10 +3290,10 @@ void testNullableAndDefaultValue() { QueryResultsWrapper queryResultsWrapper = new QueryResultsWrapper(queryR.getData()); List records = queryResultsWrapper.getRowRecords(); System.out.println("Query results:"); - for (QueryResultsWrapper.RowRecord record:records) { - long id = (long)record.get("id"); - if (id%2 == 0) { - Assertions.assertEquals((int)id, record.get("flag")); + for (QueryResultsWrapper.RowRecord record : records) { + long id = (long) record.get("id"); + if (id % 2 == 0) { + Assertions.assertEquals((int) id, record.get("flag")); Assertions.assertNull(record.get("desc")); } else { Assertions.assertEquals(10, record.get("flag")); @@ -3327,8 +3327,8 @@ void testNullableAndDefaultValue() { for (SearchResultsWrapper.IDScore score : scores) { long id = score.getLongID(); Map fieldValues = score.getFieldValues(); - if (id%2 == 0) { - Assertions.assertEquals((int)id, fieldValues.get("flag")); + if (id % 2 == 0) { + Assertions.assertEquals((int) id, fieldValues.get("flag")); Assertions.assertNull(fieldValues.get("desc")); } else { Assertions.assertEquals(10, fieldValues.get("flag")); @@ -3374,7 +3374,7 @@ void testConsistencyLevel() { // query/search/hybridSearch immediately after insert, data must be visible String expr = String.format("%s == %d", pkName, i); - if (i%3 == 0) { + if (i % 3 == 0) { R fetchR = tempClient.query(QueryParam.newBuilder() .withDatabaseName(dbName) .withCollectionName(randomCollectionName) @@ -3386,7 +3386,7 @@ void testConsistencyLevel() { QueryResultsWrapper oneResult = new QueryResultsWrapper(fetchR.getData()); List records = oneResult.getRowRecords(); Assertions.assertEquals(1L, records.size()); - } else if (i%2 == 0) { + } else if (i % 2 == 0) { R searchOne = tempClient.search(SearchParam.newBuilder() .withDatabaseName(dbName) .withCollectionName(randomCollectionName) @@ -3425,8 +3425,8 @@ void testConsistencyLevel() { Assertions.assertEquals(1, scores.size()); } } - return null; - }; + return null; + }; // test SESSION level createSimpleCollection(client, "", randomCollectionName, pkName, false, dim, ConsistencyLevelEnum.SESSION); diff --git a/sdk-core/src/test/java/io/milvus/client/MilvusMultiClientDockerTest.java b/sdk-core/src/test/java/io/milvus/client/MilvusMultiClientDockerTest.java index ed60e1c22..d2b4afdeb 100644 --- a/sdk-core/src/test/java/io/milvus/client/MilvusMultiClientDockerTest.java +++ b/sdk-core/src/test/java/io/milvus/client/MilvusMultiClientDockerTest.java @@ -33,16 +33,18 @@ import io.milvus.param.partition.ShowPartitionsParam; import io.milvus.response.*; import org.apache.commons.text.RandomStringGenerator; - -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.ByteBuffer; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Random; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -73,11 +75,11 @@ private static void waitMilvusServerReady(String host, int port) { break; } - try{ + try { MilvusServiceClient tempClient = new MilvusServiceClient(connectParam); R resp = tempClient.checkHealth(); if (resp.getData().getIsHealthy()) { - System.out.println(String.format("Milvus service is ready after %d seconds", waitTime)); + System.out.printf("Milvus service is ready after %d seconds%n", waitTime); break; } System.out.println("Milvus service is not ready, waiting..."); @@ -87,7 +89,7 @@ private static void waitMilvusServerReady(String host, int port) { waitTime += checkInterval; if (waitTime > 120) { - System.out.println(String.format("Milvus service failed to start within %d seconds", waitTime)); + System.out.printf("Milvus service failed to start within %d seconds%n", waitTime); break; } } @@ -232,7 +234,7 @@ void testFloatVectors() { .build()); DescCollResponseWrapper desc = new DescCollResponseWrapper(response.getData()); - System.out.println(desc.toString()); + System.out.println(desc); // insert data int rowCount = 10000; @@ -313,7 +315,7 @@ void testFloatVectors() { assertEquals(R.Status.Success.getCode(), descIndexR.getStatus().intValue()); DescIndexResponseWrapper indexDesc = new DescIndexResponseWrapper(descIndexR.getData()); - System.out.println("Index description: " + indexDesc.toString()); + System.out.println("Index description: " + indexDesc); // load collection R loadR = client.loadCollection(LoadCollectionParam.newBuilder() @@ -327,7 +329,7 @@ void testFloatVectors() { .build()); assertEquals(R.Status.Success.getCode(), showR.getStatus().intValue()); ShowCollResponseWrapper info = new ShowCollResponseWrapper(showR.getData()); - System.out.println("Collection info: " + info.toString()); + System.out.println("Collection info: " + info); // show partitions R showPartR = client.showPartitions(ShowPartitionsParam.newBuilder() @@ -336,7 +338,7 @@ void testFloatVectors() { .build()); assertEquals(R.Status.Success.getCode(), showPartR.getStatus().intValue()); ShowPartResponseWrapper infoPart = new ShowPartResponseWrapper(showPartR.getData()); - System.out.println("Partition info: " + infoPart.toString()); + System.out.println("Partition info: " + infoPart); // query vectors to verify List queryIDs = new ArrayList<>(); @@ -348,7 +350,7 @@ void testFloatVectors() { queryIDs.add(ids.get(i)); compareWeights.add(weights.get(i)); } - String expr = field1Name + " in " + queryIDs.toString(); + String expr = field1Name + " in " + queryIDs; List outputFields = Arrays.asList(field1Name, field2Name, field3Name, field4Name, field4Name); QueryParam queryParam = QueryParam.newBuilder() .withCollectionName(randomCollectionName) @@ -685,7 +687,7 @@ void testAsyncMethods() { ListenableFuture> searchFuture = client.searchAsync(searchParam); // query async - String expr = field1Name + " in " + queryIDs.toString(); + String expr = field1Name + " in " + queryIDs; List outputFields = Arrays.asList(field1Name, field2Name); QueryParam queryParam = QueryParam.newBuilder() .withCollectionName(randomCollectionName) diff --git a/sdk-core/src/test/java/io/milvus/client/MilvusServiceClientTest.java b/sdk-core/src/test/java/io/milvus/client/MilvusServiceClientTest.java index 2b45c8dbe..cf262bf23 100644 --- a/sdk-core/src/test/java/io/milvus/client/MilvusServiceClientTest.java +++ b/sdk-core/src/test/java/io/milvus/client/MilvusServiceClientTest.java @@ -33,7 +33,10 @@ import io.milvus.param.alias.ListAliasesParam; import io.milvus.param.collection.*; import io.milvus.param.control.*; -import io.milvus.param.credential.*; +import io.milvus.param.credential.CreateCredentialParam; +import io.milvus.param.credential.DeleteCredentialParam; +import io.milvus.param.credential.ListCredUsersParam; +import io.milvus.param.credential.UpdateCredentialParam; import io.milvus.param.dml.*; import io.milvus.param.dml.ranker.RRFRanker; import io.milvus.param.index.*; @@ -138,7 +141,7 @@ private void testAsyncFuncByName(String funcName, T param) { R

response = respFuture.get(); assertEquals(R.Status.Success.getCode(), response.getStatus()); } catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException | - InterruptedException | ExecutionException e) { + InterruptedException | ExecutionException e) { e.printStackTrace(); System.out.println(e.getMessage()); fail(); @@ -161,7 +164,7 @@ private void testAsyncFuncByName(String funcName, T param) { R

response = respFuture.get(); assertEquals(R.Status.ClientNotConnected.getCode(), response.getStatus()); } catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException | - InterruptedException | ExecutionException e) { + InterruptedException | ExecutionException e) { e.printStackTrace(); System.out.println(e.getMessage()); fail(); @@ -182,11 +185,11 @@ void r() { R r = R.failed(ErrorCode.UnexpectedError, msg); Exception e = r.getException(); assertEquals(0, msg.compareTo(e.getMessage())); - System.out.println(r.toString()); + System.out.println(r); r = R.success(); assertEquals(R.Status.Success.getCode(), r.getStatus()); - System.out.println(r.toString()); + System.out.println(r); } @Test @@ -315,24 +318,24 @@ void testConnectWithClientRequestId() { ThreadLocal clientRequestId = new ThreadLocal<>(); clientRequestId.set("req1"); ConnectParam connectParam = ConnectParam.newBuilder() - .withHost("localhost") - .withPort(testPort) - .withConnectTimeout(10000, TimeUnit.MILLISECONDS) - .withClientRequestId(clientRequestId) - .build(); + .withHost("localhost") + .withPort(testPort) + .withConnectTimeout(10000, TimeUnit.MILLISECONDS) + .withClientRequestId(clientRequestId) + .build(); RetryParam retryParam = RetryParam.newBuilder() - .withMaxRetryTimes(2) - .build(); + .withMaxRetryTimes(2) + .build(); MockMilvusServer server = startServer(); MilvusServiceClient client = new MilvusServiceClient(connectParam); client.withRetry(retryParam); DescribeCollectionParam param = DescribeCollectionParam.newBuilder() - .withCollectionName("collection1") - .build(); + .withCollectionName("collection1") + .build(); R response = client.describeCollection(param); - assertTrue(response.getStatus() == 0); + assertEquals(0, (int) response.getStatus()); server.stop(); } @@ -585,7 +588,7 @@ void getCollectionStatistics() { try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException e) { - System.out.println(e.toString()); + System.out.println(e); } mockServerImpl.setGetFlushStateResponse(GetFlushStateResponse.newBuilder() .setFlushed(true) @@ -2151,7 +2154,7 @@ void searchParam() { .withExpr("dummy") .build() ); - + // succeed float vector case List> vectors2 = Collections.singletonList(vector2); assertDoesNotThrow(() -> SearchParam.newBuilder() @@ -2621,7 +2624,7 @@ void getLoadState() { ); } - //////////////////////////////////////////////////////////////////////////////////// + /// ///////////////////////////////////////////////////////////////////////////////// // Response wrapper test private void testScalarField(ScalarField field, DataType type, long rowCount) { FieldData fieldData = FieldData.newBuilder() @@ -2775,7 +2778,7 @@ void testFieldDataWrapper() { // for binary vector dim = 16; - int bytesPerVec = (int) (dim/8); + int bytesPerVec = (int) (dim / 8); int count = 2; byte[] binary = new byte[bytesPerVec * count]; for (int i = 0; i < binary.length; ++i) { @@ -2797,12 +2800,12 @@ void testFieldDataWrapper() { List binaryData = wrapper.getFieldData(); assertEquals(count, binaryData.size()); - for(int i = 0; i < binaryData.size(); i++) { + for (int i = 0; i < binaryData.size(); i++) { ByteBuffer vec = (ByteBuffer) binaryData.get(i); assertEquals(bytesPerVec, vec.limit()); - for(int j = 0; j < bytesPerVec; j++) { - assertEquals(binary[i*bytesPerVec + j], vec.get(j)); + for (int j = 0; j < bytesPerVec; j++) { + assertEquals(binary[i * bytesPerVec + j], vec.get(j)); } } diff --git a/sdk-core/src/test/java/io/milvus/server/MockMilvusServerImpl.java b/sdk-core/src/test/java/io/milvus/server/MockMilvusServerImpl.java index 8dc6e1ba7..7a88bd1f2 100644 --- a/sdk-core/src/test/java/io/milvus/server/MockMilvusServerImpl.java +++ b/sdk-core/src/test/java/io/milvus/server/MockMilvusServerImpl.java @@ -60,7 +60,7 @@ public class MockMilvusServerImpl extends MilvusServiceGrpc.MilvusServiceImplBas private io.milvus.grpc.SearchResults respSearch; private io.milvus.grpc.FlushResponse respFlush; private io.milvus.grpc.QueryResults respQuery; -// private io.milvus.grpc.CalcDistanceResults respCalcDistance; + // private io.milvus.grpc.CalcDistanceResults respCalcDistance; private io.milvus.grpc.GetFlushStateResponse respGetFlushState; private io.milvus.grpc.GetPersistentSegmentInfoResponse respGetPersistentSegmentInfo; private io.milvus.grpc.GetQuerySegmentInfoResponse respGetQuerySegmentInfo; @@ -341,7 +341,7 @@ public void setAlterAliasResponse(io.milvus.grpc.Status resp) { @Override public void listAliases(io.milvus.grpc.ListAliasesRequest request, - io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.StreamObserver responseObserver) { logger.info("MockServer receive listAliases() call"); responseObserver.onNext(respListAliases); @@ -441,7 +441,7 @@ public void delete(io.milvus.grpc.DeleteRequest request, @Override public void import_(io.milvus.grpc.ImportRequest request, - io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.StreamObserver responseObserver) { logger.info("MockServer receive import() call"); responseObserver.onNext(respImport); @@ -450,7 +450,7 @@ public void import_(io.milvus.grpc.ImportRequest request, @Override public void getImportState(io.milvus.grpc.GetImportStateRequest request, - io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.StreamObserver responseObserver) { logger.info("MockServer receive getImportState() call"); responseObserver.onNext(respImportState); @@ -459,7 +459,7 @@ public void getImportState(io.milvus.grpc.GetImportStateRequest request, @Override public void listImportTasks(io.milvus.grpc.ListImportTasksRequest request, - io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.StreamObserver responseObserver) { logger.info("MockServer receive listImportTasks() call"); responseObserver.onNext(respListImportTasks); @@ -533,7 +533,7 @@ public void setQueryResponse(io.milvus.grpc.QueryResults resp) { @Override public void getFlushState(io.milvus.grpc.GetFlushStateRequest request, - io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.StreamObserver responseObserver) { logger.info("MockServer receive getFlushState() call"); responseObserver.onNext(respGetFlushState); @@ -572,7 +572,7 @@ public void setGetQuerySegmentInfoResponse(io.milvus.grpc.GetQuerySegmentInfoRes @Override public void getReplicas(io.milvus.grpc.GetReplicasRequest request, - io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.StreamObserver responseObserver) { logger.info("MockServer receive getReplicas() call"); responseObserver.onNext(respGetReplicas); diff --git a/sdk-core/src/test/java/io/milvus/v2/BaseTest.java b/sdk-core/src/test/java/io/milvus/v2/BaseTest.java index 2263422b8..fb2e16f19 100644 --- a/sdk-core/src/test/java/io/milvus/v2/BaseTest.java +++ b/sdk-core/src/test/java/io/milvus/v2/BaseTest.java @@ -39,7 +39,7 @@ @MockitoSettings(strictness = Strictness.LENIENT) public class BaseTest { @InjectMocks - public MilvusClientV2 client_v2 = new MilvusClientV2(null);; + public MilvusClientV2 client_v2 = new MilvusClientV2(null); @Mock protected MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub; @@ -165,6 +165,7 @@ public void setUp() { when(blockingStub.listAliases(any())).thenReturn(ListAliasesResponse.newBuilder().setStatus(successStatus).addAliases("test").build()); when(blockingStub.allocTimestamp(any())).thenReturn(AllocTimestampResponse.newBuilder().setStatus(successStatus).setTimestamp(1L).build()); } + @AfterEach public void tearDown() throws InterruptedException { client_v2.close(3); diff --git a/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java b/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java index 0f62f5304..eb7b060c5 100644 --- a/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java +++ b/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java @@ -20,12 +20,17 @@ package io.milvus.v2.client; import com.google.common.collect.Lists; -import com.google.gson.*; - +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonNull; +import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; import io.milvus.TestUtils; import io.milvus.common.clientenum.FunctionType; -import io.milvus.common.resourcegroup.*; +import io.milvus.common.resourcegroup.NodeInfo; +import io.milvus.common.resourcegroup.ResourceGroupConfig; +import io.milvus.common.resourcegroup.ResourceGroupLimit; +import io.milvus.common.resourcegroup.ResourceGroupTransfer; import io.milvus.common.utils.Float16Utils; import io.milvus.common.utils.GTsDict; import io.milvus.common.utils.JsonUtils; @@ -41,29 +46,39 @@ import io.milvus.v2.common.IndexParam; import io.milvus.v2.exception.MilvusClientException; import io.milvus.v2.service.collection.request.*; -import io.milvus.v2.service.collection.response.*; +import io.milvus.v2.service.collection.response.DescribeCollectionResp; +import io.milvus.v2.service.collection.response.DescribeReplicasResp; +import io.milvus.v2.service.collection.response.ListCollectionsResp; import io.milvus.v2.service.database.request.*; -import io.milvus.v2.service.database.response.*; +import io.milvus.v2.service.database.response.DescribeDatabaseResp; +import io.milvus.v2.service.database.response.ListDatabasesResp; import io.milvus.v2.service.index.request.*; -import io.milvus.v2.service.index.response.*; +import io.milvus.v2.service.index.response.DescribeIndexResp; import io.milvus.v2.service.partition.request.*; import io.milvus.v2.service.rbac.PrivilegeGroup; -import io.milvus.v2.service.rbac.request.*; -import io.milvus.v2.service.rbac.response.*; +import io.milvus.v2.service.rbac.request.AddPrivilegesToGroupReq; +import io.milvus.v2.service.rbac.request.CreatePrivilegeGroupReq; +import io.milvus.v2.service.rbac.request.ListPrivilegeGroupsReq; +import io.milvus.v2.service.rbac.response.ListPrivilegeGroupsResp; import io.milvus.v2.service.resourcegroup.request.*; -import io.milvus.v2.service.resourcegroup.response.*; +import io.milvus.v2.service.resourcegroup.response.DescribeResourceGroupResp; +import io.milvus.v2.service.resourcegroup.response.ListResourceGroupsResp; import io.milvus.v2.service.utility.request.*; -import io.milvus.v2.service.utility.response.*; +import io.milvus.v2.service.utility.response.CheckHealthResp; +import io.milvus.v2.service.utility.response.CompactResp; +import io.milvus.v2.service.utility.response.GetPersistentSegmentInfoResp; +import io.milvus.v2.service.utility.response.GetQuerySegmentInfoResp; import io.milvus.v2.service.vector.request.*; import io.milvus.v2.service.vector.request.data.*; -import io.milvus.v2.service.vector.request.ranker.*; +import io.milvus.v2.service.vector.request.ranker.BoostRanker; +import io.milvus.v2.service.vector.request.ranker.RRFRanker; +import io.milvus.v2.service.vector.request.ranker.WeightedRanker; import io.milvus.v2.service.vector.response.*; import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.RandomStringGenerator; - +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; @@ -181,25 +196,25 @@ private List generateRandomData(CreateCollectionReq.CollectionSchema DataType dataType = field.getDataType(); switch (dataType) { case Bool: - row.addProperty(field.getName(), i%3==0); + row.addProperty(field.getName(), i % 3 == 0); break; case Int8: - row.addProperty(field.getName(), i%128); + row.addProperty(field.getName(), i % 128); break; case Int16: - row.addProperty(field.getName(), i%32768); + row.addProperty(field.getName(), i % 32768); break; case Int32: - row.addProperty(field.getName(), i%65536); + row.addProperty(field.getName(), i % 65536); break; case Int64: row.addProperty(field.getName(), i); break; case Float: - row.addProperty(field.getName(), i/8); + row.addProperty(field.getName(), i / 8); break; case Double: - row.addProperty(field.getName(), i/3); + row.addProperty(field.getName(), i / 3); break; case VarChar: row.addProperty(field.getName(), String.format("varchar_%d", i)); @@ -207,7 +222,7 @@ private List generateRandomData(CreateCollectionReq.CollectionSchema case JSON: { JsonObject jsonObj = new JsonObject(); jsonObj.addProperty(String.format("JSON_%d", i), i); - jsonObj.add("flags", JsonUtils.toJsonTree(new long[]{i, i+1, i + 2})); + jsonObj.add("flags", JsonUtils.toJsonTree(new long[]{i, i + 1, i + 2})); row.add(field.getName(), jsonObj); break; } @@ -273,13 +288,16 @@ private void verifyOutput(JsonObject row, Map entity) { Assertions.assertEquals(row.get("json_field").toString(), jsn.toString()); List arrInt = (List) entity.get("arr_int_field"); - List arrIntOri = JsonUtils.fromJson(row.get("arr_int_field"), new TypeToken>() {}.getType()); + List arrIntOri = JsonUtils.fromJson(row.get("arr_int_field"), new TypeToken>() { + }.getType()); Assertions.assertEquals(arrIntOri, arrInt); List arrFloat = (List) entity.get("arr_float_field"); - List arrFloatOri = JsonUtils.fromJson(row.get("arr_float_field"), new TypeToken>() {}.getType()); + List arrFloatOri = JsonUtils.fromJson(row.get("arr_float_field"), new TypeToken>() { + }.getType()); Assertions.assertEquals(arrFloatOri, arrFloat); List arrStr = (List) entity.get("arr_varchar_field"); - List arrStrOri = JsonUtils.fromJson(row.get("arr_varchar_field"), new TypeToken>() {}.getType()); + List arrStrOri = JsonUtils.fromJson(row.get("arr_varchar_field"), new TypeToken>() { + }.getType()); Assertions.assertEquals(arrStrOri, arrStr); } @@ -292,7 +310,18 @@ private long getRowCount(String dbName, String collectionName) { .build()); List queryResults = queryResp.getQueryResults(); Assertions.assertEquals(1, queryResults.size()); - return (long)queryResults.get(0).getEntity().get("count(*)"); + return (long) queryResults.get(0).getEntity().get("count(*)"); + } + + @Test + void testAAAA() { + CreateCollectionReq.Function func = CreateCollectionReq.Function.builder() + .name("XXX") + .build(); + BoostRanker ranker = BoostRanker.builder() + .name("AAA") + .weight(2.5f) + .build(); } @@ -333,7 +362,7 @@ void testFloatVectors() { .build()); // master branch, getPersistentSegmentInfo cannot ensure the segment is returned after flush() - while(true) { + while (true) { // get persistent segment info GetPersistentSegmentInfoResp pSegInfo = client.getPersistentSegmentInfo(GetPersistentSegmentInfoReq.builder() .collectionName(randomCollectionName) @@ -361,7 +390,7 @@ void testFloatVectors() { Assertions.assertTrue(compactResp.getCompactionID() == -1L || compactResp.getCompactionID() > 0L); // create index - Map extraParams = new HashMap<>(); + Map extraParams = new HashMap<>(); extraParams.put("M", 64); extraParams.put("efConstruction", 200); IndexParam indexParam = IndexParam.builder() @@ -470,9 +499,10 @@ void testFloatVectors() { List targetIDs = new ArrayList<>(); List targetVectors = new ArrayList<>(); for (int i = 0; i < nq; i++) { - JsonObject row = data.get(RANDOM.nextInt((int)count)); + JsonObject row = data.get(RANDOM.nextInt((int) count)); targetIDs.add(row.get("id").getAsLong()); - List vector = JsonUtils.fromJson(row.get(vectorFieldName), new TypeToken>() {}.getType()); + List vector = JsonUtils.fromJson(row.get(vectorFieldName), new TypeToken>() { + }.getType()); targetVectors.add(new FloatVec(vector)); } @@ -521,7 +551,7 @@ void testFloatVectors() { { // query with template - Map template = new HashMap<>(); + Map template = new HashMap<>(); template.put("id_arr", Arrays.asList(5, 6, 7)); QueryResp queryResp = client.query(QueryReq.builder() .collectionName(randomCollectionName) @@ -613,8 +643,8 @@ void testBinaryVectors() throws InterruptedException { .dimension(DIMENSION) .build()); - Map extraParams = new HashMap<>(); - extraParams.put("nlist",64); + Map extraParams = new HashMap<>(); + extraParams.put("nlist", 64); IndexParam indexParam = IndexParam.builder() .fieldName(vectorFieldName) .indexType(IndexParam.IndexType.BIN_IVF_FLAT) @@ -649,9 +679,10 @@ void testBinaryVectors() throws InterruptedException { List targetVectors = new ArrayList<>(); List targetOriginVectors = new ArrayList<>(); for (int i = 0; i < nq; i++) { - JsonObject row = data.get(RANDOM.nextInt((int)count)); + JsonObject row = data.get(RANDOM.nextInt((int) count)); targetIDs.add(row.get("id").getAsLong()); - byte[] vector = JsonUtils.fromJson(row.get(vectorFieldName), new TypeToken() {}.getType()); + byte[] vector = JsonUtils.fromJson(row.get(vectorFieldName), new TypeToken() { + }.getType()); targetOriginVectors.add(ByteBuffer.wrap(vector)); targetVectors.add(new BinaryVec(vector)); } @@ -696,8 +727,8 @@ void testFloat16Vectors() { .build()); List indexes = new ArrayList<>(); - Map extraParams = new HashMap<>(); - extraParams.put("nlist",64); + Map extraParams = new HashMap<>(); + extraParams.put("nlist", 64); indexes.add(IndexParam.builder() .fieldName(float16Field) .indexType(IndexParam.IndexType.IVF_FLAT) @@ -739,10 +770,10 @@ void testFloat16Vectors() { // update one row long targetID = 99; - JsonObject row = data.get((int)targetID); + JsonObject row = data.get((int) targetID); List originVector = new ArrayList<>(); for (int i = 0; i < DIMENSION; ++i) { - originVector.add((float)1/(i+1)); + originVector.add((float) 1 / (i + 1)); } // System.out.println("Original float32 vector: " + originVector); row.add(float16Field, JsonUtils.toJsonTree(Float16Utils.f32VectorToFp16Buffer(originVector).array())); @@ -826,8 +857,8 @@ void testSparseVectors() { .dimension(DIMENSION) .build()); - Map extraParams = new HashMap<>(); - extraParams.put("drop_ratio_build",0.2); + Map extraParams = new HashMap<>(); + extraParams.put("drop_ratio_build", 0.2); IndexParam indexParam = IndexParam.builder() .fieldName(vectorFieldName) .indexType(IndexParam.IndexType.SPARSE_INVERTED_INDEX) @@ -861,9 +892,10 @@ void testSparseVectors() { List targetIDs = new ArrayList<>(); List targetVectors = new ArrayList<>(); for (int i = 0; i < nq; i++) { - JsonObject row = data.get(RANDOM.nextInt((int)count)); + JsonObject row = data.get(RANDOM.nextInt((int) count)); targetIDs.add(row.get("id").getAsLong()); - SortedMap vector = JsonUtils.fromJson(row.get(vectorFieldName), new TypeToken>() {}.getType()); + SortedMap vector = JsonUtils.fromJson(row.get(vectorFieldName), new TypeToken>() { + }.getType()); targetVectors.add(new SparseFloatVec(vector)); } SearchResp searchResp = client.search(SearchReq.builder() @@ -940,7 +972,7 @@ void testInt8Vectors() { .build()); // create index - Map extraParams = new HashMap<>(); + Map extraParams = new HashMap<>(); extraParams.put("M", 64); extraParams.put("efConstruction", 200); IndexParam indexParam = IndexParam.builder() @@ -1014,7 +1046,7 @@ void testInt8Vectors() { QueryResp.QueryResult result = queryResults.get(0); Map entity = result.getEntity(); ByteBuffer originVec = vectors.get(5); - ByteBuffer getVec = (ByteBuffer)entity.get(vectorFieldName); + ByteBuffer getVec = (ByteBuffer) entity.get(vectorFieldName); Assertions.assertEquals(originVec, getVec); } } @@ -1210,13 +1242,13 @@ void testStruct() { EmbeddingList embList0 = new EmbeddingList(); EmbeddingList embList1 = new EmbeddingList(); - List> structs0 = (List>)queryResults.get(0).getEntity().get(structField); + List> structs0 = (List>) queryResults.get(0).getEntity().get(structField); for (Map struct : structs0) { - embList0.add(new FloatVec((List)struct.get(structVectorField))); + embList0.add(new FloatVec((List) struct.get(structVectorField))); } - List> structs1 = (List>)queryResults.get(1).getEntity().get(structField); + List> structs1 = (List>) queryResults.get(1).getEntity().get(structField); for (Map struct : structs1) { - embList1.add(new FloatVec((List)struct.get(structVectorField))); + embList1.add(new FloatVec((List) struct.get(structVectorField))); } int topK = 5; @@ -1232,8 +1264,8 @@ void testStruct() { for (List oneResults : searchResults) { Assertions.assertEquals(topK, oneResults.size()); } - Assertions.assertEquals(6L, (long)searchResults.get(0).get(0).getId()); - Assertions.assertEquals(9L, (long)searchResults.get(1).get(0).getId()); + Assertions.assertEquals(6L, (long) searchResults.get(0).get(0).getId()); + Assertions.assertEquals(9L, (long) searchResults.get(1).get(0).getId()); } @Test @@ -1503,7 +1535,9 @@ void testHybridSearch() { .fieldName("float_vector") .indexType(IndexParam.IndexType.IVF_FLAT) .metricType(IndexParam.MetricType.L2) - .extraParams(new HashMap(){{put("nlist", 64);}}) + .extraParams(new HashMap() {{ + put("nlist", 64); + }}) .build()); indexParams.add(IndexParam.builder() .fieldName("binary_vector") @@ -1514,7 +1548,9 @@ void testHybridSearch() { .fieldName("sparse_vector") .indexType(IndexParam.IndexType.SPARSE_INVERTED_INDEX) .metricType(IndexParam.MetricType.IP) - .extraParams(new HashMap(){{put("drop_ratio_build", 0.1);}}) + .extraParams(new HashMap() {{ + put("drop_ratio_build", 0.1); + }}) .build()); CreateCollectionReq requestCreate = CreateCollectionReq.builder() @@ -1542,7 +1578,7 @@ void testHybridSearch() { floatVectors.add(new FloatVec(utils.generateFloatVector())); binaryVectors.add(new BinaryVec(utils.generateBinaryVector())); } - int sparseCount = (Integer)config.get("sparseCount"); + int sparseCount = (Integer) config.get("sparseCount"); for (int i = 0; i < sparseCount; i++) { sparseVectors.add(new SparseFloatVec(utils.generateSparseVector())); } @@ -1566,7 +1602,7 @@ void testHybridSearch() { .build()); CreateCollectionReq.Function ranker = WeightedRanker.builder().weights(Arrays.asList(0.2f, 0.5f, 0.6f)).build(); - boolean useFunctionScore = (Boolean)config.get("useFunctionScore"); + boolean useFunctionScore = (Boolean) config.get("useFunctionScore"); if (useFunctionScore) { return HybridSearchReq.builder() .collectionName(randomCollectionName) @@ -1584,17 +1620,17 @@ void testHybridSearch() { .consistencyLevel(ConsistencyLevel.BOUNDED) .build(); } - }; + }; Map config = new HashMap<>(); config.put("sparseCount", 0); config.put("useFunctionScore", false); // search with an empty nq, return error - Assertions.assertThrows(MilvusClientException.class, ()->client.hybridSearch(genRequestFunc.apply(config))); + Assertions.assertThrows(MilvusClientException.class, () -> client.hybridSearch(genRequestFunc.apply(config))); // unequal nq, return error config.put("sparseCount", 1); - Assertions.assertThrows(MilvusClientException.class, ()->client.hybridSearch(genRequestFunc.apply(config))); + Assertions.assertThrows(MilvusClientException.class, () -> client.hybridSearch(genRequestFunc.apply(config))); // search on empty collection, no result returned config.put("sparseCount", nq); @@ -1664,7 +1700,9 @@ void testDeleteUpsert() { .fieldName("float_vector") .indexType(IndexParam.IndexType.IVF_FLAT) .metricType(IndexParam.MetricType.L2) - .extraParams(new HashMap(){{put("nlist", 64);}}) + .extraParams(new HashMap() {{ + put("nlist", 64); + }}) .build()); // create collection in the test db CreateCollectionReq requestCreate = CreateCollectionReq.builder() @@ -1681,7 +1719,7 @@ void testDeleteUpsert() { JsonObject row = new JsonObject(); row.addProperty("pk", "pk_" + i); row.addProperty("text", "desc_" + i); - row.add("float_vector", JsonUtils.toJsonTree(new float[]{(float)i, (float)(i + 1), (float)(i + 2), (float)(i + 3)})); + row.add("float_vector", JsonUtils.toJsonTree(new float[]{(float) i, (float) (i + 1), (float) (i + 2), (float) (i + 3)})); data.add(row); } @@ -1762,7 +1800,7 @@ void testDeleteUpsert() { Assertions.assertEquals("pk_2", entity.get("pk")); Assertions.assertEquals("desc_2", entity.get("text")); Assertions.assertTrue(entity.containsKey("float_vector")); - Assertions.assertTrue(entity.get("float_vector") instanceof List); + Assertions.assertInstanceOf(List.class, entity.get("float_vector")); List vector1 = (List) entity.get("float_vector"); for (Float f : vector1) { Assertions.assertEquals(5.0f, f); @@ -1776,7 +1814,7 @@ void testDeleteUpsert() { Assertions.assertEquals("pk_5", entity.get("pk")); Assertions.assertEquals("updated_5", entity.get("text")); Assertions.assertTrue(entity.containsKey("float_vector")); - Assertions.assertTrue(entity.get("float_vector") instanceof List); + Assertions.assertInstanceOf(List.class, entity.get("float_vector")); List vector2 = (List) entity.get("float_vector"); for (Float f : vector2) { Assertions.assertEquals(5.0f, f); @@ -1832,7 +1870,7 @@ void testAlias() { .alias("CCC") .build()); - Assertions.assertThrows(MilvusClientException.class, ()->client.describeCollection(DescribeCollectionReq.builder() + Assertions.assertThrows(MilvusClientException.class, () -> client.describeCollection(DescribeCollectionReq.builder() .collectionName("CCC") .build())); } @@ -1915,9 +1953,9 @@ void testIndex() { .build()); List indexes = new ArrayList<>(); - Map extra = new HashMap<>(); - extra.put("M",8); - extra.put("efConstruction",64); + Map extra = new HashMap<>(); + extra.put("M", 8); + extra.put("efConstruction", 64); indexes.add(IndexParam.builder() .fieldName("vector") .indexName("abc") @@ -2149,82 +2187,82 @@ void testCacheCollectionSchema() throws InterruptedException { .data(Collections.singletonList(row)).build()); Assertions.assertEquals(1L, insertResp.getInsertCnt()); - // check the timestamp of this collection, must be positive - String key1 = GTsDict.CombineCollectionName("default", randomCollectionName); - Long ts11 = GTsDict.getInstance().getCollectionTs(key1); - Assertions.assertNotNull(ts11); - Assertions.assertTrue(ts11 > 0L); + // check the timestamp of this collection, must be positive + String key1 = GTsDict.CombineCollectionName("default", randomCollectionName); + Long ts11 = GTsDict.getInstance().getCollectionTs(key1); + Assertions.assertNotNull(ts11); + Assertions.assertTrue(ts11 > 0L); - // insert wrong data, the schema cache will be removed - row.add("vector", JsonUtils.toJsonTree(utils.generateFloatVector(7))); - Assertions.assertThrows(MilvusClientException.class, ()->client.insert(InsertReq.builder() - .databaseName("default") - .collectionName(randomCollectionName) - .data(Collections.singletonList(row)) - .build())); + // insert wrong data, the schema cache will be removed + row.add("vector", JsonUtils.toJsonTree(utils.generateFloatVector(7))); + Assertions.assertThrows(MilvusClientException.class, () -> client.insert(InsertReq.builder() + .databaseName("default") + .collectionName(randomCollectionName) + .data(Collections.singletonList(row)) + .build())); - // use the default client to do upsert correct data - TimeUnit.MILLISECONDS.sleep(100); - row.addProperty("pk", 999); - row.add("vector", JsonUtils.toJsonTree(utils.generateFloatVector(DIMENSION))); - UpsertResp upsertResp = client.upsert(UpsertReq.builder() - .collectionName(randomCollectionName) - .data(Collections.singletonList(row)) - .build()); - Assertions.assertEquals(1L, upsertResp.getUpsertCnt()); + // use the default client to do upsert correct data + TimeUnit.MILLISECONDS.sleep(100); + row.addProperty("pk", 999); + row.add("vector", JsonUtils.toJsonTree(utils.generateFloatVector(DIMENSION))); + UpsertResp upsertResp = client.upsert(UpsertReq.builder() + .collectionName(randomCollectionName) + .data(Collections.singletonList(row)) + .build()); + Assertions.assertEquals(1L, upsertResp.getUpsertCnt()); - // check the timestamp of this collection, must be a new positive - Long ts12 = GTsDict.getInstance().getCollectionTs(key1); - Assertions.assertNotNull(ts12); - Assertions.assertTrue(ts12 > ts11); + // check the timestamp of this collection, must be a new positive + Long ts12 = GTsDict.getInstance().getCollectionTs(key1); + Assertions.assertNotNull(ts12); + Assertions.assertTrue(ts12 > ts11); - // create a new collection with the same name, different schema, in the test db - createSimpleCollection(tempClient, "", randomCollectionName, "aaa", false, 4, ConsistencyLevel.BOUNDED); + // create a new collection with the same name, different schema, in the test db + createSimpleCollection(tempClient, "", randomCollectionName, "aaa", false, 4, ConsistencyLevel.BOUNDED); - // use the temp client to insert wrong data, wrong dimension - row.addProperty("aaa", 22); - row.add("vector", JsonUtils.toJsonTree(utils.generateFloatVector(7))); + // use the temp client to insert wrong data, wrong dimension + row.addProperty("aaa", 22); + row.add("vector", JsonUtils.toJsonTree(utils.generateFloatVector(7))); MilvusClientV2 finalTempClient = tempClient; - Assertions.assertThrows(MilvusClientException.class, ()-> finalTempClient.insert(InsertReq.builder() - .collectionName(randomCollectionName) - .data(Collections.singletonList(row)) - .build())); + Assertions.assertThrows(MilvusClientException.class, () -> finalTempClient.insert(InsertReq.builder() + .collectionName(randomCollectionName) + .data(Collections.singletonList(row)) + .build())); - // check the timestamp of this collection, must be null - String key2 = GTsDict.CombineCollectionName(testDbName, randomCollectionName); - Long ts21 = GTsDict.getInstance().getCollectionTs(key2); - Assertions.assertNull(ts21); + // check the timestamp of this collection, must be null + String key2 = GTsDict.CombineCollectionName(testDbName, randomCollectionName); + Long ts21 = GTsDict.getInstance().getCollectionTs(key2); + Assertions.assertNull(ts21); - // use the temp client to do upsert correct data - TimeUnit.MILLISECONDS.sleep(100); - row.add("vector", JsonUtils.toJsonTree(utils.generateFloatVector(4))); - upsertResp = tempClient.upsert(UpsertReq.builder() - .collectionName(randomCollectionName) - .data(Collections.singletonList(row)) - .build()); - Assertions.assertEquals(1L, upsertResp.getUpsertCnt()); + // use the temp client to do upsert correct data + TimeUnit.MILLISECONDS.sleep(100); + row.add("vector", JsonUtils.toJsonTree(utils.generateFloatVector(4))); + upsertResp = tempClient.upsert(UpsertReq.builder() + .collectionName(randomCollectionName) + .data(Collections.singletonList(row)) + .build()); + Assertions.assertEquals(1L, upsertResp.getUpsertCnt()); - // check the timestamp of this collection, must be positive - Long ts22 = GTsDict.getInstance().getCollectionTs(key2); - Assertions.assertNotNull(ts22); - Assertions.assertTrue(ts22 > 0L); + // check the timestamp of this collection, must be positive + Long ts22 = GTsDict.getInstance().getCollectionTs(key2); + Assertions.assertNotNull(ts22); + Assertions.assertTrue(ts22 > 0L); - // tempClient delete data - tempClient.delete(DeleteReq.builder() - .collectionName(randomCollectionName) - .ids(Collections.singletonList(22L)) - .build()); + // tempClient delete data + tempClient.delete(DeleteReq.builder() + .collectionName(randomCollectionName) + .ids(Collections.singletonList(22L)) + .build()); - // check the timestamp of this collection, must be greater than previous - Long ts23 = GTsDict.getInstance().getCollectionTs(key2); - Assertions.assertNotNull(ts23); - Assertions.assertTrue(ts23 > ts22); + // check the timestamp of this collection, must be greater than previous + Long ts23 = GTsDict.getInstance().getCollectionTs(key2); + Assertions.assertNotNull(ts23); + Assertions.assertTrue(ts23 > ts22); - // use the default client to drop the collection in the new db - client.dropCollection(DropCollectionReq.builder() - .databaseName(testDbName) - .collectionName(randomCollectionName) - .build()); + // use the default client to drop the collection in the new db + client.dropCollection(DropCollectionReq.builder() + .databaseName(testDbName) + .collectionName(randomCollectionName) + .build()); // check the timestamp of this collection, must be deleted Long ts31 = GTsDict.getInstance().getCollectionTs(key2); @@ -2276,7 +2314,9 @@ public void testIterator() { .fieldName("sparse_vector") .indexType(IndexParam.IndexType.SPARSE_INVERTED_INDEX) .metricType(IndexParam.MetricType.IP) - .extraParams(new HashMap(){{put("drop_ratio_build", 0.1);}}) + .extraParams(new HashMap() {{ + put("drop_ratio_build", 0.1); + }}) .build()); indexParams.add(IndexParam.builder() .fieldName("bfloat16_vector") @@ -2329,8 +2369,8 @@ public void testIterator() { for (QueryResultsWrapper.RowRecord record : res) { Assertions.assertInstanceOf(Float.class, record.get("score")); - Assertions.assertTrue((float)record.get("score") >= 5.0); - Assertions.assertTrue((float)record.get("score") <= 50.0); + Assertions.assertTrue((float) record.get("score") >= 5.0); + Assertions.assertTrue((float) record.get("score") <= 50.0); Assertions.assertInstanceOf(Boolean.class, record.get("bool_field")); Assertions.assertInstanceOf(Integer.class, record.get("int8_field")); @@ -2347,34 +2387,34 @@ public void testIterator() { Assertions.assertInstanceOf(ByteBuffer.class, record.get("bfloat16_vector")); Assertions.assertInstanceOf(SortedMap.class, record.get("sparse_vector")); - long int64Val = (long)record.get("int64_field"); + long int64Val = (long) record.get("int64_field"); Assertions.assertTrue(int64Val > 500L && int64Val < 1000L); - String varcharVal = (String)record.get("varchar_field"); + String varcharVal = (String) record.get("varchar_field"); Assertions.assertTrue(varcharVal.startsWith("varchar_")); - JsonObject jsonObj = (JsonObject)record.get("json_field"); + JsonObject jsonObj = (JsonObject) record.get("json_field"); Assertions.assertTrue(jsonObj.has(String.format("JSON_%d", int64Val))); - List intArr = (List)record.get("arr_int_field"); + List intArr = (List) record.get("arr_int_field"); Assertions.assertTrue(intArr.size() <= 50); // max capacity 50 is defined in the baseSchema() - List floatVector = (List)record.get("float_vector"); + List floatVector = (List) record.get("float_vector"); Assertions.assertEquals(DIMENSION, floatVector.size()); - ByteBuffer binaryVector = (ByteBuffer)record.get("binary_vector"); - Assertions.assertEquals(DIMENSION, binaryVector.limit()*8); + ByteBuffer binaryVector = (ByteBuffer) record.get("binary_vector"); + Assertions.assertEquals(DIMENSION, binaryVector.limit() * 8); - ByteBuffer bfloat16Vector = (ByteBuffer)record.get("bfloat16_vector"); - Assertions.assertEquals(DIMENSION*2, bfloat16Vector.limit()); + ByteBuffer bfloat16Vector = (ByteBuffer) record.get("bfloat16_vector"); + Assertions.assertEquals(DIMENSION * 2, bfloat16Vector.limit()); - SortedMap sparseVector = (SortedMap)record.get("sparse_vector"); + SortedMap sparseVector = (SortedMap) record.get("sparse_vector"); Assertions.assertTrue(sparseVector.size() >= 10 && sparseVector.size() < 20); // defined in generateSparseVector() counter++; } } - System.out.println(String.format("There are %d items match score between [5.0, 50.0]", counter)); + System.out.printf("There are %d items match score between [5.0, 50.0]%n", counter); Assertions.assertTrue(counter > 0); // query iterator @@ -2382,7 +2422,7 @@ public void testIterator() { long to = 18000; QueryIterator queryIterator = client.queryIterator(QueryIteratorReq.builder() .collectionName(randomCollectionName) - .expr("int64_field < " + String.valueOf(to)) + .expr("int64_field < " + to) .outputFields(Lists.newArrayList("*")) .batchSize(50L) .offset(from) @@ -2416,29 +2456,29 @@ public void testIterator() { Assertions.assertInstanceOf(ByteBuffer.class, record.get("bfloat16_vector")); Assertions.assertInstanceOf(SortedMap.class, record.get("sparse_vector")); - long int64Val = (long)record.get("id"); + long int64Val = (long) record.get("id"); Assertions.assertTrue(int64Val >= from); Assertions.assertTrue(int64Val < to); - String varcharVal = (String)record.get("varchar_field"); + String varcharVal = (String) record.get("varchar_field"); Assertions.assertTrue(varcharVal.startsWith("varchar_")); - JsonObject jsonObj = (JsonObject)record.get("json_field"); + JsonObject jsonObj = (JsonObject) record.get("json_field"); Assertions.assertTrue(jsonObj.has(String.format("JSON_%d", int64Val))); - List intArr = (List)record.get("arr_int_field"); + List intArr = (List) record.get("arr_int_field"); Assertions.assertTrue(intArr.size() <= 50); // max capacity 50 is defined in the baseSchema() - List floatVector = (List)record.get("float_vector"); + List floatVector = (List) record.get("float_vector"); Assertions.assertEquals(DIMENSION, floatVector.size()); - ByteBuffer binaryVector = (ByteBuffer)record.get("binary_vector"); - Assertions.assertEquals(DIMENSION, binaryVector.limit()*8); + ByteBuffer binaryVector = (ByteBuffer) record.get("binary_vector"); + Assertions.assertEquals(DIMENSION, binaryVector.limit() * 8); - ByteBuffer bfloat16Vector = (ByteBuffer)record.get("bfloat16_vector"); - Assertions.assertEquals(DIMENSION*2, bfloat16Vector.limit()); + ByteBuffer bfloat16Vector = (ByteBuffer) record.get("bfloat16_vector"); + Assertions.assertEquals(DIMENSION * 2, bfloat16Vector.limit()); - SortedMap sparseVector = (SortedMap)record.get("sparse_vector"); + SortedMap sparseVector = (SortedMap) record.get("sparse_vector"); Assertions.assertTrue(sparseVector.size() >= 10 && sparseVector.size() < 20); // defined in generateSparseVector() counter++; @@ -2483,27 +2523,27 @@ public void testIterator() { Assertions.assertInstanceOf(ByteBuffer.class, entity.get("bfloat16_vector")); Assertions.assertInstanceOf(SortedMap.class, entity.get("sparse_vector")); - String varcharVal = (String)entity.get("varchar_field"); + String varcharVal = (String) entity.get("varchar_field"); Assertions.assertTrue(varcharVal.startsWith("varchar_")); - long int64Val = (long)entity.get("int64_field"); - Assertions.assertEquals(int64Val, (long)record.getId()); - JsonObject jsonObj = (JsonObject)entity.get("json_field"); + long int64Val = (long) entity.get("int64_field"); + Assertions.assertEquals(int64Val, (long) record.getId()); + JsonObject jsonObj = (JsonObject) entity.get("json_field"); Assertions.assertTrue(jsonObj.has(String.format("JSON_%d", int64Val))); - List intArr = (List)entity.get("arr_int_field"); + List intArr = (List) entity.get("arr_int_field"); Assertions.assertTrue(intArr.size() <= 50); // max capacity 50 is defined in the baseSchema() - List floatVector = (List)entity.get("float_vector"); + List floatVector = (List) entity.get("float_vector"); Assertions.assertEquals(DIMENSION, floatVector.size()); - ByteBuffer binaryVector = (ByteBuffer)entity.get("binary_vector"); - Assertions.assertEquals(DIMENSION, binaryVector.limit()*8); + ByteBuffer binaryVector = (ByteBuffer) entity.get("binary_vector"); + Assertions.assertEquals(DIMENSION, binaryVector.limit() * 8); - ByteBuffer bfloat16Vector = (ByteBuffer)entity.get("bfloat16_vector"); - Assertions.assertEquals(DIMENSION*2, bfloat16Vector.limit()); + ByteBuffer bfloat16Vector = (ByteBuffer) entity.get("bfloat16_vector"); + Assertions.assertEquals(DIMENSION * 2, bfloat16Vector.limit()); - SortedMap sparseVector = (SortedMap)entity.get("sparse_vector"); + SortedMap sparseVector = (SortedMap) entity.get("sparse_vector"); Assertions.assertTrue(sparseVector.size() >= 10 && sparseVector.size() < 20); // defined in generateSparseVector() counter++; @@ -2511,7 +2551,7 @@ public void testIterator() { } // search iterator could not ensure that all the entities can be retrieved // expect count is 9950, but sometimes it returns 9949 or 9948 - Assertions.assertTrue(counter > ((int)count - 55) && counter <= ((int)count - 50)); + Assertions.assertTrue(counter > ((int) count - 55) && counter <= ((int) count - 50)); client.dropCollection(DropCollectionReq.builder().collectionName(randomCollectionName).build()); } @@ -2541,7 +2581,7 @@ void testDatabase() { DescribeDatabaseResp descDBResp = client.describeDatabase(DescribeDatabaseReq.builder() .databaseName(tempDatabaseName) .build()); - Map propertiesResp = descDBResp.getProperties(); + Map propertiesResp = descDBResp.getProperties(); Assertions.assertTrue(propertiesResp.containsKey(Constant.DATABASE_REPLICA_NUMBER)); Assertions.assertEquals("5", propertiesResp.get(Constant.DATABASE_REPLICA_NUMBER)); @@ -2573,7 +2613,7 @@ void testDatabase() { Assertions.assertFalse(propertiesResp.containsKey("prop")); // switch to the temp database - Assertions.assertDoesNotThrow(()->client.useDatabase(tempDatabaseName)); + Assertions.assertDoesNotThrow(() -> client.useDatabase(tempDatabaseName)); // create a collection in the temp database String randomCollectionName = generator.generate(10); @@ -2599,7 +2639,7 @@ void testDatabase() { client.createCollection(requestCreate); // switch to the default database - Assertions.assertDoesNotThrow(()->client.useDatabase(currentDbName)); + Assertions.assertDoesNotThrow(() -> client.useDatabase(currentDbName)); // list collections in the temp database ListCollectionsResp listCollectionsResp = client.listCollectionsV2(ListCollectionsReq.builder() @@ -2852,7 +2892,7 @@ void testClientPool() { System.out.printf("idle %d, active %d%n", pool.getIdleClientNumber(key), pool.getActiveClientNumber(key)); pool.returnClient(key, client); } - System.out.println(String.format("Thread %s finished", Thread.currentThread().getName())); + System.out.printf("Thread %s finished%n", Thread.currentThread().getName()); }); t.start(); threadList.add(t); @@ -2862,8 +2902,8 @@ void testClientPool() { t.join(); } - System.out.println(String.format("idle %d, active %d", pool.getIdleClientNumber(key), pool.getActiveClientNumber(key))); - System.out.println(String.format("total idle %d, total active %d", pool.getTotalIdleClientNumber(), pool.getTotalActiveClientNumber())); + System.out.printf("idle %d, active %d%n", pool.getIdleClientNumber(key), pool.getActiveClientNumber(key)); + System.out.printf("total idle %d, total active %d%n", pool.getTotalIdleClientNumber(), pool.getTotalActiveClientNumber()); // get client connect to the dummy db MilvusClientV2 dummyClient = pool.getClient(dummyDb); @@ -2924,7 +2964,7 @@ void testMultiThreadsInsert() { int cnt = rand.nextInt(100) + 100; for (int j = 0; j < cnt; j++) { JsonObject obj = new JsonObject(); - obj.addProperty("id", String.format("%d", i*cnt + j)); + obj.addProperty("id", String.format("%d", i * cnt + j)); List vector = utils.generateFloatVector(dim); obj.add("vector", JsonUtils.toJsonTree(vector)); obj.addProperty("dataTime", System.currentTimeMillis()); @@ -2968,7 +3008,7 @@ void testMultiThreadsInsert() { int cnt = rand.nextInt(100) + 100; for (int j = 0; j < cnt; j++) { JsonObject obj = new JsonObject(); - obj.addProperty("id", String.format("%d", i*cnt + j)); + obj.addProperty("id", String.format("%d", i * cnt + j)); List vector = utils.generateFloatVector(dim); obj.add("vector", JsonUtils.toJsonTree(vector)); obj.addProperty("dataTime", System.currentTimeMillis()); @@ -3026,7 +3066,7 @@ void testNullableAndDefaultValue() { .fieldName("flag") .dataType(DataType.Int32) .isNullable(true) - .defaultValue((int)10) + .defaultValue(10) .build()); collectionSchema.addField(AddFieldReq.builder() .fieldName("desc") @@ -3072,7 +3112,7 @@ void testNullableAndDefaultValue() { List vector = utils.generateFloatVector(dim); row.addProperty("id", i); row.add("vector", JsonUtils.toJsonTree(vector)); - if (i%2 == 0) { + if (i % 2 == 0) { row.addProperty("flag", i); row.add("desc", JsonNull.INSTANCE); } else { @@ -3096,9 +3136,9 @@ void testNullableAndDefaultValue() { Function, Void> checkFunc = entity -> { - long id = (long)entity.get("id"); - if (id%2 == 0) { - Assertions.assertEquals((int)id, entity.get("flag")); + long id = (long) entity.get("id"); + if (id % 2 == 0) { + Assertions.assertEquals((int) id, entity.get("flag")); Assertions.assertNull(entity.get("desc")); Assertions.assertNull(entity.get("arr")); } else { @@ -3106,7 +3146,7 @@ void testNullableAndDefaultValue() { Assertions.assertEquals("AAA", entity.get("desc")); Object obj = entity.get("arr"); Assertions.assertInstanceOf(List.class, obj); - List arr = (List)obj; + List arr = (List) obj; Assertions.assertEquals(2, arr.size()); Assertions.assertEquals(5, arr.get(0)); Assertions.assertEquals(6, arr.get(1)); @@ -3144,7 +3184,7 @@ void testNullableAndDefaultValue() { Assertions.assertEquals(10, firstResults.size()); // System.out.println("Search results:"); for (SearchResp.SearchResult result : firstResults) { - long id = (long)result.getId(); + long id = (long) result.getId(); Map entity = result.getEntity(); checkFunc.apply(entity); // System.out.println(result); @@ -3201,7 +3241,9 @@ void testDocInOut() { .fieldName("sparse") .indexType(IndexParam.IndexType.SPARSE_INVERTED_INDEX) .metricType(IndexParam.MetricType.BM25) - .extraParams(new HashMap(){{put("drop_ratio_build", 0.1);}}) + .extraParams(new HashMap() {{ + put("drop_ratio_build", 0.1); + }}) .build()); CreateCollectionReq requestCreate = CreateCollectionReq.builder() .collectionName(randomCollectionName) @@ -3312,7 +3354,7 @@ void testDynamicField() { .outputFields(Collections.singletonList("count(*)")) .consistencyLevel(ConsistencyLevel.STRONG) .build()); - Assertions.assertEquals(100L, (long)countR.getQueryResults().get(0).getEntity().get("count(*)")); + Assertions.assertEquals(100L, (long) countR.getQueryResults().get(0).getEntity().get("count(*)")); GetResp getR = client.get(GetReq.builder() .collectionName(collectionName) @@ -3661,8 +3703,8 @@ void testConsistencyLevel() throws InterruptedException { tempClient.close(); } } - return null; - }; + return null; + }; // test SESSION level createSimpleCollection(client, "", randomCollectionName, pkName, false, dim, ConsistencyLevel.SESSION); diff --git a/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2Test.java b/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2Test.java index b7d409a12..aab19ee0c 100644 --- a/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2Test.java +++ b/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2Test.java @@ -28,11 +28,12 @@ public class MilvusClientV2Test extends BaseTest { @Test void testMilvusClientV2() { } + @Test void testUseDatabase() { try { client_v2.useDatabase("test"); - }catch (Exception e) { + } catch (Exception e) { Assertions.assertEquals("Database test not exist", e.getMessage()); } diff --git a/sdk-core/src/test/java/io/milvus/v2/service/collection/CollectionTest.java b/sdk-core/src/test/java/io/milvus/v2/service/collection/CollectionTest.java index 63fddc198..c832ca60d 100644 --- a/sdk-core/src/test/java/io/milvus/v2/service/collection/CollectionTest.java +++ b/sdk-core/src/test/java/io/milvus/v2/service/collection/CollectionTest.java @@ -77,14 +77,14 @@ void testEnableDynamicSchema() { Assertions.assertTrue(req.getEnableDynamicField()); Assertions.assertTrue(req.getCollectionSchema().isEnableDynamicField()); - assertThrows(MilvusClientException.class, () ->CreateCollectionReq.builder() + assertThrows(MilvusClientException.class, () -> CreateCollectionReq.builder() .collectionName("test") .enableDynamicField(false) .collectionSchema(collectionSchema) .build() ); - assertThrows(MilvusClientException.class, () ->CreateCollectionReq.builder() + assertThrows(MilvusClientException.class, () -> CreateCollectionReq.builder() .collectionName("test") .collectionSchema(collectionSchema) .enableDynamicField(false) @@ -147,6 +147,7 @@ void testHasCollection() { .build(); Boolean resp = client_v2.hasCollection(req); } + @Test void testDescribeCollection() { DescribeCollectionReq req = DescribeCollectionReq.builder() diff --git a/sdk-core/src/test/java/io/milvus/v2/service/index/IndexTest.java b/sdk-core/src/test/java/io/milvus/v2/service/index/IndexTest.java index e65b2a774..3a10c15df 100644 --- a/sdk-core/src/test/java/io/milvus/v2/service/index/IndexTest.java +++ b/sdk-core/src/test/java/io/milvus/v2/service/index/IndexTest.java @@ -58,6 +58,7 @@ void testCreateIndex() { .build(); client_v2.createIndex(createIndexReq); } + @Test void testDescribeIndex() { DescribeIndexReq describeIndexReq = DescribeIndexReq.builder() @@ -67,6 +68,7 @@ void testDescribeIndex() { DescribeIndexResp responseR = client_v2.describeIndex(describeIndexReq); logger.info(responseR.toString()); } + @Test void testDropIndex() { DropIndexReq dropIndexReq = DropIndexReq.builder() diff --git a/sdk-core/src/test/java/io/milvus/v2/service/utility/UtilityTest.java b/sdk-core/src/test/java/io/milvus/v2/service/utility/UtilityTest.java index 23ff3da2b..5d3653339 100644 --- a/sdk-core/src/test/java/io/milvus/v2/service/utility/UtilityTest.java +++ b/sdk-core/src/test/java/io/milvus/v2/service/utility/UtilityTest.java @@ -46,6 +46,7 @@ void testDropAlias() { .build(); client_v2.dropAlias(req); } + @Test void testAlterAlias() { AlterAliasReq req = AlterAliasReq.builder() @@ -62,6 +63,7 @@ void describeAlias() { .build(); DescribeAliasResp statusR = client_v2.describeAlias(req); } + @Test void listAliases() { ListAliasesReq req = ListAliasesReq.builder() diff --git a/sdk-core/src/test/java/io/milvus/v2/service/vector/VectorTest.java b/sdk-core/src/test/java/io/milvus/v2/service/vector/VectorTest.java index 3683901c3..fb1bdd241 100644 --- a/sdk-core/src/test/java/io/milvus/v2/service/vector/VectorTest.java +++ b/sdk-core/src/test/java/io/milvus/v2/service/vector/VectorTest.java @@ -19,7 +19,7 @@ package io.milvus.v2.service.vector; -import com.google.gson.*; +import com.google.gson.JsonObject; import io.milvus.common.utils.JsonUtils; import io.milvus.v2.BaseTest; import io.milvus.v2.service.vector.request.*; @@ -130,7 +130,7 @@ void testSearchWithTemplateExpression() { .build(); SearchResp statusR = client_v2.search(request); logger.info(statusR.toString()); - System.out.println(statusR.toString()); + System.out.println(statusR); }); } @@ -145,7 +145,7 @@ void testDelete() { } @Test - void testDeleteById(){ + void testDeleteById() { DeleteReq request = DeleteReq.builder() .collectionName("test") .ids(Collections.singletonList("0")) diff --git a/sdk-core/src/test/java/io/milvus/v2/utils/SchemaUtilsTest.java b/sdk-core/src/test/java/io/milvus/v2/utils/SchemaUtilsTest.java index 228c9c49f..c397da3a4 100644 --- a/sdk-core/src/test/java/io/milvus/v2/utils/SchemaUtilsTest.java +++ b/sdk-core/src/test/java/io/milvus/v2/utils/SchemaUtilsTest.java @@ -229,7 +229,7 @@ void testConvertToGrpcFieldSchema() { if (rpcSchema.getName().equals("varchar_field")) { List keys = new ArrayList<>(); - rpcSchema.getTypeParamsList().forEach((kv)-> keys.add(kv.getKey())); + rpcSchema.getTypeParamsList().forEach((kv) -> keys.add(kv.getKey())); Assertions.assertTrue(keys.contains("enable_analyzer")); Assertions.assertTrue(keys.contains("enable_match")); Assertions.assertTrue(keys.contains("analyzer_params")); @@ -256,7 +256,7 @@ void testConvertFromGrpcFieldSchema() { Map originParams = fieldSchema.getTypeParams(); if (originParams != null) { Map typeParams = newSchema.getTypeParams(); - originParams.forEach((k ,v)->{ + originParams.forEach((k, v) -> { Assertions.assertTrue(typeParams.containsKey(k)); Assertions.assertEquals(typeParams.get(k), originParams.get(k)); });