ソースを参照

sdk 0.8.3

Signed-off-by: sahuang <xiaohai.xu@zilliz.com>
sahuang 4 年 前
コミット
e330c32c2f

+ 7 - 1
CHANGELOG.md

@@ -1,4 +1,10 @@
-# Changelog     
+# Changelog   
+
+## milvus-sdk-java 0.8.3 (2020-07-15)
+
+### Improvement
+
+- \#117 - Remove isConnect() API
 
 ## milvus-sdk-java 0.8.0 (2020-05-15)
 

+ 3 - 5
README.md

@@ -15,6 +15,7 @@ The following table shows compatibilities between Milvus and Java SDK.
 
 | Milvus version | Java SDK version |
 | :------------: | :--------------: |
+|     0.10.1     |    0.8.3         |
 |     0.10.0     |    0.8.2         |
 |     0.9.1      |    0.8.1         |
 |     0.9.0      |    0.8.0         |
@@ -23,9 +24,6 @@ The following table shows compatibilities between Milvus and Java SDK.
 |     0.7.0      |    0.5.0         |
 |     0.6.0      |    0.4.1         |
 |     0.5.3      |    0.3.0         |
-|     0.5.2      |    0.2.2         |
-|     0.5.1      |    0.2.2         |
-|     0.5.0      |    0.2.2         |
 
 ### Install Java SDK
 
@@ -37,14 +35,14 @@ You can use **Apache Maven** or **Gradle**/**Grails** to download the SDK.
         <dependency>
             <groupId>io.milvus</groupId>
             <artifactId>milvus-sdk-java</artifactId>
-            <version>0.8.2</version>
+            <version>0.8.3</version>
         </dependency>
        ```
 
    - Gradle/Grails
 
         ```gradle
-        compile 'io.milvus:milvus-sdk-java:0.8.2'
+        compile 'io.milvus:milvus-sdk-java:0.8.3'
         ```
 
 ### Examples

+ 11 - 10
examples/src/main/java/MilvusClientExample.java

@@ -34,12 +34,12 @@ import java.util.stream.DoubleStream;
 public class MilvusClientExample {
 
   // Helper function that generates random vectors
-  static List<List<Float>> generateVectors(long vectorCount, long dimension) {
-    SplittableRandom splitCollectionRandom = new SplittableRandom();
-    List<List<Float>> vectors = new ArrayList<>();
-    for (long i = 0; i < vectorCount; ++i) {
-      splitCollectionRandom = splitCollectionRandom.split();
-      DoubleStream doubleStream = splitCollectionRandom.doubles(dimension);
+  static List<List<Float>> generateVectors(int vectorCount, int dimension) {
+    SplittableRandom splitcollectionRandom = new SplittableRandom();
+    List<List<Float>> vectors = new ArrayList<>(vectorCount);
+    for (int i = 0; i < vectorCount; ++i) {
+      splitcollectionRandom = splitcollectionRandom.split();
+      DoubleStream doubleStream = splitcollectionRandom.doubles(dimension);
       List<Float> vector =
           doubleStream.boxed().map(Double::floatValue).collect(Collectors.toList());
       vectors.add(vector);
@@ -47,7 +47,8 @@ public class MilvusClientExample {
     return vectors;
   }
 
-  // Helper function that normalizes a vector if you are using Inner Product as your metric type
+  // Helper function that normalizes a vector if you are using IP (Inner Product) as your metric
+  // type
   static List<Float> normalizeVector(List<Float> vector) {
     float squareSum = vector.stream().map(x -> x * x).reduce((float) 0, Float::sum);
     final float norm = (float) Math.sqrt(squareSum);
@@ -79,8 +80,8 @@ public class MilvusClientExample {
 
     // Create a collection with the following collection mapping
     final String collectionName = "example"; // collection name
-    final long dimension = 128; // dimension of each vector
-    final long indexFileSize = 1024; // maximum size (in MB) of each index file
+    final int dimension = 128; // dimension of each vector
+    final int indexFileSize = 1024; // maximum size (in MB) of each index file
     final MetricType metricType = MetricType.IP; // we choose IP (Inner Product) as our metric type
     CollectionMapping collectionMapping =
         new CollectionMapping.Builder(collectionName, dimension)
@@ -223,4 +224,4 @@ public class MilvusClientExample {
       throw e;
     }
   }
-}
+}

+ 1 - 1
pom.xml

@@ -25,7 +25,7 @@
 
     <groupId>io.milvus</groupId>
     <artifactId>milvus-sdk-java</artifactId>
-    <version>0.8.3-SNAPSHOT</version>
+    <version>0.8.3</version>
     <packaging>jar</packaging>
 
     <name>io.milvus:milvus-sdk-java</name>

+ 2 - 2
src/main/java/io/milvus/client/MilvusClient.java

@@ -25,9 +25,9 @@ import java.util.List;
 /** The Milvus Client Interface */
 public interface MilvusClient {
 
-  String clientVersion = "0.8.2";
+  String clientVersion = "0.8.3";
 
-  /** @return current Milvus client version: 0.8.2 */
+  /** @return current Milvus client version: 0.8.3 */
   default String getClientVersion() {
     return clientVersion;
   }

+ 1 - 1
src/main/java/io/milvus/client/MilvusGrpcClient.java

@@ -96,7 +96,7 @@ public class MilvusGrpcClient implements MilvusClient {
       String serverVersion = getServerVersion().getMessage();
       if (!serverVersion.contains("0.10.")) {
         logError(
-            "Connect failed! Server version {} does not match SDK version 0.8.2", serverVersion);
+            "Connect failed! Server version {} does not match SDK version 0.8.3", serverVersion);
         throw new ConnectFailedException("Failed to connect to Milvus server.");
       }
 

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

@@ -40,14 +40,14 @@ class MilvusClientTest {
   private RandomStringGenerator generator;
 
   private String randomCollectionName;
-  private long size;
-  private long dimension;
+  private int size;
+  private int dimension;
 
   // Helper function that generates random float vectors
-  static List<List<Float>> generateFloatVectors(long vectorCount, long dimension) {
+  static List<List<Float>> generateFloatVectors(int vectorCount, int dimension) {
     SplittableRandom splittableRandom = new SplittableRandom();
-    List<List<Float>> vectors = new ArrayList<>();
-    for (long i = 0; i < vectorCount; ++i) {
+    List<List<Float>> vectors = new ArrayList<>(vectorCount);
+    for (int i = 0; i < vectorCount; ++i) {
       splittableRandom = splittableRandom.split();
       DoubleStream doubleStream = splittableRandom.doubles(dimension);
       List<Float> vector =
@@ -58,12 +58,12 @@ class MilvusClientTest {
   }
 
   // Helper function that generates random binary vectors
-  static List<ByteBuffer> generateBinaryVectors(long vectorCount, long dimension) {
+  static List<ByteBuffer> generateBinaryVectors(int vectorCount, int dimension) {
     Random random = new Random();
-    List<ByteBuffer> vectors = new ArrayList<>();
-    final long dimensionInByte = dimension / 8;
-    for (long i = 0; i < vectorCount; ++i) {
-      ByteBuffer byteBuffer = ByteBuffer.allocate((int) dimensionInByte);
+    List<ByteBuffer> vectors = new ArrayList<>(vectorCount);
+    final int dimensionInByte = dimension / 8;
+    for (int i = 0; i < vectorCount; ++i) {
+      ByteBuffer byteBuffer = ByteBuffer.allocate(dimensionInByte);
       random.nextBytes(byteBuffer.array());
       vectors.add(byteBuffer);
     }
@@ -326,7 +326,7 @@ class MilvusClientTest {
 
   @org.junit.jupiter.api.Test
   void insertBinary() {
-    final long binaryDimension = 10000;
+    final int binaryDimension = 10000;
 
     String binaryCollectionName = generator.generate(10);
     CollectionMapping collectionMapping =