Quellcode durchsuchen

Merge pull request #6 from youny626/branch-0.5.0

Update pom & fix deleteByRange error message & update unittest
Jin Hai vor 5 Jahren
Ursprung
Commit
c2d6a74021

+ 2 - 2
milvus-sdk-java.iml

@@ -34,9 +34,9 @@
     <orderEntry type="library" scope="TEST" name="Maven: io.grpc:grpc-testing:1.24.0" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
-    <orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java-util:3.10.0" level="project" />
+    <orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java-util:3.9.0" level="project" />
     <orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.3.2" level="project" />
-    <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.5" level="project" />
+    <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.7" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter:5.5.2" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.5.2" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" />

+ 98 - 6
pom.xml

@@ -7,16 +7,37 @@
     <groupId>io.milvus</groupId>
     <artifactId>milvus-sdk-java</artifactId>
     <version>1.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
 
     <name>milvus-sdk-java</name>
-    <description>Java SDK for Milvus distributed high-performance vector search engine. </description>
-    <url>https://github.com/milvus-io/milvus-sdk-java</url>
+    <description>Java SDK for Milvus distributed high-performance vector search engine.</description>
+    <url>https://www.milvus.io/</url>
+
+    <licenses>
+        <license>
+            <name>Apache License, Version 2.0</name>
+            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+            <distribution>repo</distribution>
+        </license>
+    </licenses>
+
+    <scm>
+        <connection>scm:git:https://github.com/milvus-io/milvus-sdk-java.git</connection>
+        <url>https://github.com/milvus-io/milvus-sdk-java</url>
+    </scm>
+
+    <distributionManagement>
+        <snapshotRepository>
+            <id>ossrh</id>
+            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+        </snapshotRepository>
+    </distributionManagement>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <grpc.version>1.24.0</grpc.version><!-- CURRENT_GRPC_VERSION -->
-        <protobuf.version>3.10.0</protobuf.version>
-        <protoc.version>3.10.0</protoc.version>
+        <grpc.version>1.24.0</grpc.version>
+        <protobuf.version>3.9.0</protobuf.version>
+        <protoc.version>3.9.0</protoc.version>
         <maven.compiler.source>1.8</maven.compiler.source>
         <maven.compiler.target>1.8</maven.compiler.target>
     </properties>
@@ -69,7 +90,6 @@
             <version>RELEASE</version>
             <scope>test</scope>
         </dependency>
-        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-text -->
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-text</artifactId>
@@ -77,6 +97,67 @@
         </dependency>
     </dependencies>
 
+    <profiles>
+        <profile>
+            <id>release</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.sonatype.plugins</groupId>
+                        <artifactId>nexus-staging-maven-plugin</artifactId>
+                        <version>1.6.8</version>
+                        <extensions>true</extensions>
+                        <configuration>
+                            <serverId>ossrh</serverId>
+                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
+                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
+                        </configuration>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-source-plugin</artifactId>
+                        <version>3.1.0</version>
+                        <executions>
+                            <execution>
+                                <id>attach-sources</id>
+                                <goals>
+                                    <goal>jar-no-fork</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-javadoc-plugin</artifactId>
+                        <version>3.1.1</version>
+                        <executions>
+                            <execution>
+                                <id>attach-javadocs</id>
+                                <goals>
+                                    <goal>jar</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-gpg-plugin</artifactId>
+                        <version>1.6</version>
+                        <executions>
+                            <execution>
+                                <id>sign-artifacts</id>
+                                <phase>verify</phase>
+                                <goals>
+                                    <goal>sign</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
     <build>
         <extensions>
             <extension>
@@ -86,6 +167,17 @@
             </extension>
         </extensions>
         <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-release-plugin</artifactId>
+                <version>2.5.3</version>
+                <configuration>
+                    <autoVersionSubmodules>true</autoVersionSubmodules>
+                    <useReleaseProfile>false</useReleaseProfile>
+                    <releaseProfiles>release</releaseProfiles>
+                    <goals>deploy</goals>
+                </configuration>
+            </plugin>
             <plugin>
                 <groupId>org.xolstice.maven.plugins</groupId>
                 <artifactId>protobuf-maven-plugin</artifactId>

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

@@ -554,7 +554,9 @@ public class MilvusGrpcClient implements MilvusClient {
                              deleteByRangeParam.getTableName(), deleteByRangeParam.getDateRange().toString());
                 return new Response(Response.Status.SUCCESS);
             } else {
-                logSevere("Deleted vectors from table `{0}` in range {1} failed:\n{1}", response.toString());
+                logSevere("Deleted vectors from table `{0}` in range {1} failed:\n{2}",
+                          deleteByRangeParam.getTableName(), deleteByRangeParam.getDateRange().toString(),
+                          response.toString());
                 return new Response(Response.Status.valueOf(response.getErrorCodeValue()), response.getReason());
             }
         } catch (StatusRuntimeException e) {

+ 19 - 20
src/test/java/io/milvus/client/MilvusGrpcClientTest.java

@@ -138,16 +138,15 @@ class MilvusGrpcClientTest {
         TimeUnit.SECONDS.sleep(1);
 
         List<DateRange> queryRanges = new ArrayList<>();
-        Calendar rightNow = Calendar.getInstance();
-        Date startDate = new Calendar.Builder()
-                                     .setDate(rightNow.get(Calendar.YEAR), rightNow.get(Calendar.MONTH) , rightNow.get(Calendar.DAY_OF_MONTH) - 1)
-                                     .build()
-                                     .getTime();
-        Date endDate = new Calendar.Builder()
-                                   .setDate(rightNow.get(Calendar.YEAR), rightNow.get(Calendar.MONTH), rightNow.get(Calendar.DAY_OF_MONTH) + 1)
-                                   .build()
-                                   .getTime();
-        queryRanges.add(new DateRange(startDate, endDate));
+        Date today = new Date();
+        Calendar c = Calendar.getInstance();
+        c.setTime(today);
+        c.add(Calendar.DAY_OF_MONTH, -1);
+        Date yesterday = c.getTime();
+        c.setTime(today);
+        c.add(Calendar.DAY_OF_MONTH, 1);
+        Date tomorrow = c.getTime();
+        queryRanges.add(new DateRange(yesterday, tomorrow));
         System.out.println(queryRanges);
         SearchParam searchParam = new SearchParam
                                         .Builder(randomTableName, vectorsToSearch)
@@ -208,17 +207,17 @@ class MilvusGrpcClientTest {
 
     @org.junit.jupiter.api.Test
     void deleteByRange() {
-        Calendar rightNow = Calendar.getInstance();
-        Date startDate = new Calendar.Builder()
-                .setDate(rightNow.get(Calendar.YEAR), rightNow.get(Calendar.MONTH) , rightNow.get(Calendar.DAY_OF_MONTH) - 1)
-                .build()
-                .getTime();
-        Date endDate = new Calendar.Builder()
-                .setDate(rightNow.get(Calendar.YEAR), rightNow.get(Calendar.MONTH), rightNow.get(Calendar.DAY_OF_MONTH) + 1)
-                .build()
-                .getTime();
+        Date today = new Date();
+        Calendar c = Calendar.getInstance();
+        c.setTime(today);
+        c.add(Calendar.DAY_OF_MONTH, -1);
+        Date yesterday = c.getTime();
+        c.setTime(today);
+        c.add(Calendar.DAY_OF_MONTH, 1);
+        Date tomorrow = c.getTime();
+
         DeleteByRangeParam deleteByRangeParam = new DeleteByRangeParam.Builder(
-                new DateRange(startDate, endDate), randomTableName).build();
+                new DateRange(yesterday, tomorrow), randomTableName).build();
         Response deleteByRangeResponse = client.deleteByRange(deleteByRangeParam);
         assertTrue(deleteByRangeResponse.ok());
     }