Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split to 2 packages #1223

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 7 additions & 7 deletions .github/workflows/java_sdk_ci_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ jobs:
mvn clean versions:set -DnewVersion=2.4.0
mvn clean install -Dmaven.test.skip=true

- name: Test
timeout-minutes: 60
shell: bash
working-directory: tests/milvustestv2
run: |
echo "run testcases"
mvn clean test -Dsurefire.suiteXmlFiles=testng.xml
# - name: Test
# timeout-minutes: 60
# shell: bash
# working-directory: tests/milvustestv2
# run: |
# echo "run testcases"
# mvn clean test -Dsurefire.suiteXmlFiles=testng.xml

# - name: Upload logs
# if: ${{ always() }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ hs_err_pid*
target/
volumes/
*.iml
.flattened-pom.xml

# Example files
examples/bulk_writer
Expand Down
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "src/main/milvus-proto"]
path = src/main/milvus-proto
[submodule "sdk-core/src/main/milvus-proto"]
path = sdk-core/src/main/milvus-proto
url = https://github.com/milvus-io/milvus-proto.git
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## milvus-sdk-java 2.5.2 (TBD)
### Improvement
- Split milvus Java SDK to two packages to reduce dependency complexity

## milvus-sdk-java 2.5.1 (2024-12-04)
### Improvement
- Support upsert items with auto-id primary key
Expand Down
6 changes: 3 additions & 3 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This document will help to setup your development environment and running tests
$ git clone --recursive [email protected]:milvus-io/milvus-sdk-java.git
```

Milvus proto files are managed by a submodule project under the directory: src/milvus-proto
Milvus proto files are managed by a submodule project under the directory: sdk-core/src/main/milvus-proto
Fetch Milvus proto files by the following command(If the previous clone is not with submodules)
```shell
$ git submodule update --init
Expand All @@ -31,10 +31,10 @@ $ mvn install
```

## Update Milvus proto files
Milvus proto files are managed by a submodule project under the directory: src/milvus-proto
Milvus proto files are managed by a submodule project under the directory: sdk-core/src/main/milvus-proto
Before developing new interfaces, you need to get the latest proto files by the following command:
```shell
$ git submodule update --remote
$ git submodule update --remote
```

## Building Milvus
Expand Down
35 changes: 30 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The following table shows compatibilities between Milvus and Java SDK.
| >= 2.2.9 | 2.2.7 ~ 2.2.15 |
| 2.3.x | 2.3.11 |
| 2.4.x | 2.4.8 |
| 2.5.x | 2.5.1 |
| 2.5.x | 2.5.2 |

### Install Java SDK

Expand All @@ -33,22 +33,47 @@ You can use **Apache Maven** or **Gradle** add Milvus SDK to your project.
<dependency>
<groupId>io.milvus</groupId>
<artifactId>milvus-sdk-java</artifactId>
<version>2.5.1</version>
<version>2.5.2</version>
</dependency>
```

- Gradle/Groovy

```groovy
implementation 'io.milvus:milvus-sdk-java:2.5.1'
implementation 'io.milvus:milvus-sdk-java:2.5.2'
```

- Gradle/Kotlin

```kotlin
implementation("io.milvus:milvus-sdk-java:2.5.1")
implementation("io.milvus:milvus-sdk-java:2.5.2")
```


From v2.5.2, milvus Java SDK is split into two packages: milvus-sdk-java and milvus-sdk-java-bulkwriter, because BulkWriter requires quite a lot of dependencies. If you don't need BulkWriter tool, you can ignore the milvus-sdk-java-bulkwriter package.
To use BulkWriter, import milvus-sdk-java-bulkwriter to your project.

- Apache Maven

```xml
<dependency>
<groupId>io.milvus</groupId>
<artifactId>milvus-sdk-java-bulkwriter</artifactId>
<version>2.5.2</version>
</dependency>
```

- Gradle/Groovy

```groovy
implementation 'io.milvus:milvus-sdk-java-bulkwriter:2.5.2'
```

- Gradle/Kotlin

```kotlin
implementation("io.milvus:milvus-sdk-java-bulkwriter:2.5.2")
```

### Examples

Please refer to [examples](https://github.com/milvus-io/milvus-sdk-java/tree/master/examples) folder for Java SDK examples.
Expand Down
29 changes: 23 additions & 6 deletions examples/main/java/io/milvus/v1/ClientPoolExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,19 @@ public static void createCollection(MilvusClientV1Pool pool) {
public static Thread runInsertThread(MilvusClientV1Pool pool, String clientName, int repeatRequests) {
Thread t = new Thread(() -> {
Gson gson = new Gson();
Random rand = new Random();
for (int i = 0; i < repeatRequests; i++) {
MilvusClient client = pool.getClient(clientName);
MilvusClient client = null;
while(client == null) {
try {
// getClient() might exceeds the borrowMaxWaitMillis and throw exception
// retry to call until it return a client
client = pool.getClient(clientName);
} catch (Exception e) {
System.out.printf("Failed to get client, will retry, error: %s%n", e.getMessage());
}
}
try {
int rowCount = rand.nextInt(10) + 10;
int rowCount = 1;
List<JsonObject> rows = new ArrayList<>();
for (int j = 0; j < rowCount; j++) {
JsonObject row = new JsonObject();
Expand Down Expand Up @@ -141,7 +149,16 @@ public static Thread runInsertThread(MilvusClientV1Pool pool, String clientName,
public static Thread runSearchThread(MilvusClientV1Pool pool, String clientName, int repeatRequests) {
Thread t = new Thread(() -> {
for (int i = 0; i < repeatRequests; i++) {
MilvusClient client = pool.getClient(clientName);
MilvusClient client = null;
while(client == null) {
try {
// getClient() might exceeds the borrowMaxWaitMillis and throw exception
// retry to call until it return a client
client = pool.getClient(clientName);
} catch (Exception e) {
System.out.printf("Failed to get client, will retry, error: %s%n", e.getMessage());
}
}
try {
R<SearchResults> searchRet = client.search(SearchParam.newBuilder()
.withCollectionName(CollectionName)
Expand Down Expand Up @@ -191,7 +208,7 @@ public static void main(String[] args) throws InterruptedException {
createCollection(pool);

List<Thread> threadList = new ArrayList<>();
int threadCount = 10;
int threadCount = 100;
int repeatRequests = 100;
long start = System.currentTimeMillis();
for (int k = 0; k < threadCount; k++) {
Expand All @@ -212,7 +229,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, threadCount*repeatRequests, (end-start)*0.001);
threadCount*repeatRequests*3, threadCount*repeatRequests*3, (end-start)*0.001);
System.out.printf("Total %d idle clients and %d active clients%n",
pool.getTotalIdleClientNumber(), pool.getTotalActiveClientNumber());
pool.clear(); // clear idle clients
Expand Down
30 changes: 23 additions & 7 deletions examples/main/java/io/milvus/v2/ClientPoolExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public class ClientPoolExample {
public static String CollectionName = "java_sdk_example_pool_v2";
Expand Down Expand Up @@ -79,11 +78,19 @@ public static void createCollection(MilvusClientV2Pool pool) {
public static Thread runInsertThread(MilvusClientV2Pool pool, String clientName, int repeatRequests) {
Thread t = new Thread(() -> {
Gson gson = new Gson();
Random rand = new Random();
for (int i = 0; i < repeatRequests; i++) {
MilvusClientV2 client = pool.getClient(clientName);
MilvusClientV2 client = null;
while(client == null) {
try {
// getClient() might exceeds the borrowMaxWaitMillis and throw exception
// retry to call until it return a client
client = pool.getClient(clientName);
} catch (Exception e) {
System.out.printf("Failed to get client, will retry, error: %s%n", e.getMessage());
}
}
try {
int rowCount = rand.nextInt(10) + 10;
int rowCount = 1;
List<JsonObject> rows = new ArrayList<>();
for (int j = 0; j < rowCount; j++) {
JsonObject row = new JsonObject();
Expand All @@ -110,7 +117,16 @@ public static Thread runInsertThread(MilvusClientV2Pool pool, String clientName,
public static Thread runSearchThread(MilvusClientV2Pool pool, String clientName, int repeatRequests) {
Thread t = new Thread(() -> {
for (int i = 0; i < repeatRequests; i++) {
MilvusClientV2 client = pool.getClient(clientName);
MilvusClientV2 client = null;
while(client == null) {
try {
// getClient() might exceeds the borrowMaxWaitMillis and throw exception
// retry to call until it return a client
client = pool.getClient(clientName);
} catch (Exception e) {
System.out.printf("Failed to get client, will retry, error: %s%n", e.getMessage());
}
}
try {
SearchResp result = client.search(SearchReq.builder()
.collectionName(CollectionName)
Expand Down Expand Up @@ -154,7 +170,7 @@ public static void main(String[] args) throws InterruptedException {
createCollection(pool);

List<Thread> threadList = new ArrayList<>();
int threadCount = 10;
int threadCount = 100;
int repeatRequests = 100;
long start = System.currentTimeMillis();
for (int k = 0; k < threadCount; k++) {
Expand All @@ -175,7 +191,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, threadCount*repeatRequests, (end-start)*0.001);
threadCount*repeatRequests*3, threadCount*repeatRequests*3, (end-start)*0.001);
System.out.printf("Total %d idle clients and %d active clients%n",
pool.getTotalIdleClientNumber(), pool.getTotalActiveClientNumber());

Expand Down
9 changes: 7 additions & 2 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<groupId>io.milvus</groupId>
<artifactId>milvus-sdk-java-examples</artifactId>
<version>2.5.1</version>
<version>2.5.2</version>

<build>
<plugins>
Expand Down Expand Up @@ -64,7 +64,12 @@
<dependency>
<groupId>io.milvus</groupId>
<artifactId>milvus-sdk-java</artifactId>
<version>2.5.1</version>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>io.milvus</groupId>
<artifactId>milvus-sdk-java-bulkwriter</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>org.tensorflow</groupId>
Expand Down
Loading
Loading