Skip to content

Commit

Permalink
fix(clients): chunked batch helper size property consistency (#3253)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fluf22 authored Jun 25, 2024
1 parent 7a0ff1d commit 536a348
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions templates/go/search_helpers.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -797,8 +797,8 @@ func (c *APIClient) ChunkedBatch(indexName string, objects []map[string]any, act
waitForTasks = &defaultWaitForTask
}

requests := make([]BatchRequest, 0, len(objects)%1000)
responses := make([]BatchResponse, 0, len(objects)%1000)
requests := make([]BatchRequest, 0, len(objects)%*batchSize)
responses := make([]BatchResponse, 0, len(objects)%*batchSize)

for i, obj := range objects {
requests = append(requests, *NewBatchRequest(*action, obj))
Expand All @@ -810,7 +810,7 @@ func (c *APIClient) ChunkedBatch(indexName string, objects []map[string]any, act
}

responses = append(responses, *resp)
requests = make([]BatchRequest, 0, len(objects)%1000)
requests = make([]BatchRequest, 0, len(objects)%*batchSize)
}
}

Expand Down
12 changes: 12 additions & 0 deletions templates/java/api_helpers.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,18 @@ if (waitForTasks) {
return responses;
}
public <T> List<BatchResponse> chunkedBatch(String indexName, Iterable<T> objects, Action action, boolean waitForTasks) {
return chunkedBatch(indexName, objects, action, waitForTasks, 1000, null);
}
public <T> List<BatchResponse> chunkedBatch(String indexName, Iterable<T> objects, Action action, boolean waitForTasks, int batchSize) {
return chunkedBatch(indexName, objects, action, waitForTasks, batchSize, null);
}
public <T> List<BatchResponse> chunkedBatch(String indexName, Iterable<T> objects, Action action, boolean waitForTasks, RequestOptions requestOptions) {
return chunkedBatch(indexName, objects, action, waitForTasks, 1000, requestOptions);
}
/**
* Push a new set of objects and remove all previous ones. Settings, synonyms and query rules are
* untouched. Replace all records in an index without any downtime. See
Expand Down

0 comments on commit 536a348

Please sign in to comment.