use of com.pingcap.tikv.util.Batch in project tispark by pingcap.
the class KVClient method doSendBatchGet.
private List<KvPair> doSendBatchGet(BackOffer backOffer, List<ByteString> keys, long version) {
ExecutorCompletionService<Pair<List<Batch>, List<KvPair>>> completionService = new ExecutorCompletionService<>(batchGetThreadPool);
List<Batch> batches = getBatches(backOffer, keys, BATCH_GET_SIZE, MAX_BATCH_LIMIT, this.clientBuilder);
// prevent stack overflow
Queue<List<Batch>> taskQueue = new LinkedList<>();
List<KvPair> result = new ArrayList<>();
taskQueue.offer(batches);
while (!taskQueue.isEmpty()) {
List<Batch> task = taskQueue.poll();
for (Batch batch : task) {
completionService.submit(() -> doSendBatchGetInBatchesWithRetry(batch.getBackOffer(), batch, version));
}
result.addAll(getTasksWithOutput(completionService, taskQueue, task, BackOffer.RAWKV_MAX_BACKOFF));
}
return result;
}
Aggregations