You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: templates/java/api_helpers.mustache
+94-28Lines changed: 94 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -585,6 +585,91 @@ public CompletableFuture<List<SearchForFacetValuesResponse>> searchForFacetsAsyn
585
585
);
586
586
}
587
587
588
+
/**
589
+
* Helper: Chunks the given `objects` list in subset of 1000 elements max in order to make it fit in `push` requests by leveraging the Transformation pipeline setup in the Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/).
590
+
*
591
+
* @summary Helper: Chunks the given `objects` list in subset of 1000 elements max in order to
592
+
* make it fit in `batch` requests.
593
+
* @param indexName - The `indexName` to replace `objects` in.
594
+
* @param objects - The array of `objects` to store in the given Algolia `indexName`.
595
+
* @param action - The `batch` `action` to perform on the given array of `objects`.
596
+
* @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
597
+
* processed, this operation may slow the total execution time of this method but is more
598
+
* reliable.
599
+
* @param batchSize - The size of the chunk of `objects`. The number of `batch` calls will be
600
+
* equal to `length(objects) / batchSize`. Defaults to 1000.
601
+
* @param referenceIndexName - This is required when targeting an index that does not have a push connector setup (e.g. a tmp index), but you wish to attach another index's transformation to it (e.g. the source index name).
602
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded
603
+
* to the `getTask` method and merged with the transporter requestOptions.
604
+
*/
605
+
public <T> List<WatchResponse> chunkedPush(
606
+
String indexName,
607
+
Iterable<T> objects,
608
+
Action action,
609
+
boolean waitForTasks,
610
+
int batchSize,
611
+
String referenceIndexName,
612
+
RequestOptions requestOptions
613
+
) {
614
+
if (this.ingestionTransporter == null) {
615
+
throw new AlgoliaRuntimeException("`setTransformationRegion` must have been called before calling this method.");
616
+
}
617
+
618
+
List<WatchResponse> responses = new ArrayList<>();
0 commit comments