add_batch
Example 1 -
hyperspace_client.add_batch(batch, collection_name)hyperspaceClient.addBatch(batch, collection_name);await hyperspaceClient.addBatch(batch, collection_name);Example 2 -
BATCH_SIZE = 250
batch = []
collection_name = "new_collection"
for i, document in enumerate(documents):
batch.append(document )
if (i+1) % BATCH_SIZE == 0:
response = hyperspace_client.add_batch(batch, collection_name)
batch.clear()
if batch:
response = hyperspace_client.add_batch(batch, collection_name)
hyperspace_client.commit(collection_name)import java.util.ArrayList;
final int batchSize = 250;
for (int i= 0; index < documents.size(); i++) {
batch.add(documents.get(i));
if ((i+ 1) % batchSize == 0) {
List<DataPoint> batchCopy = new ArrayList<>(batch);
futures.add(hyperspaceClient.addBatch(batchCopy, collectionName));
batch.clear();
}
}
if (!batch.isEmpty()) {
futures.add(hyperspaceClient.addBatch(new ArrayList<>(batch), collectionName));
}
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
hyperspaceClient.commit(collectionName).join();Last updated