Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions examples/src/main/java/io/milvus/v2/BulkWriterExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private static void exampleAllTypesCollectionRemote(List<BulkFileType> fileTypes
CreateCollectionReq.CollectionSchema collectionSchema = buildAllTypesSchema();
List<List<String>> batchFiles = allTypesRemoteWriter(collectionSchema, fileType, rows);
createCollection(ALL_TYPES_COLLECTION_NAME, collectionSchema, true);
callBulkInsert(collectionSchema, batchFiles);
callBulkInsert(batchFiles);
verifyImportData(collectionSchema, originalData);
}

Expand Down Expand Up @@ -502,6 +502,7 @@ private static RemoteBulkWriter buildRemoteBulkWriter(CreateCollectionReq.Collec
.withFileType(fileType)
.withChunkSize(512 * 1024 * 1024)
.withConnectParam(connectParam)
.withConfig("sep", "|") // only take effect for CSV file
.build();
return new RemoteBulkWriter(bulkWriterParam);
}
Expand Down Expand Up @@ -573,12 +574,15 @@ public List<Float> toFloatArray() {
}
}

private static void callBulkInsert(CreateCollectionReq.CollectionSchema collectionSchema, List<List<String>> batchFiles) throws InterruptedException {
private static void callBulkInsert(List<List<String>> batchFiles) throws InterruptedException {
String url = String.format("http://%s:%s", HOST, PORT);
System.out.println("\n===================== import files to milvus ====================");
Map<String, Object> options = new HashMap<>();
options.put("sep", "|"); // this option only take effect for CSV
MilvusImportRequest milvusImportRequest = MilvusImportRequest.builder()
.collectionName(ALL_TYPES_COLLECTION_NAME)
.files(batchFiles)
.options(options)
.build();
String bulkImportResult = BulkImport.bulkImport(url, milvusImportRequest);
System.out.println(bulkImportResult);
Expand Down Expand Up @@ -760,6 +764,9 @@ private static void verifyImportData(CreateCollectionReq.CollectionSchema collec

List<QueryResp.QueryResult> results = query(expr, Lists.newArrayList("*"));
System.out.println("Verify data...");
if (results.size() != QUERY_IDS.size()) {
throw new RuntimeException("Result count is incorrect");
}
for (QueryResp.QueryResult result : results) {
Map<String, Object> fetchedEntity = result.getEntity();
long id = (Long)fetchedEntity.get("id");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import lombok.experimental.SuperBuilder;

import java.io.Serializable;
import java.util.Map;

@Data
@SuperBuilder(toBuilder = true)
Expand All @@ -36,4 +37,6 @@ public class BaseImportRequest implements Serializable {
* If you are calling the cloud API, this parameter needs to be filled in; otherwise, you can ignore it.
*/
private String apiKey;

private Map<String, Object> options;
}
Loading