Search in sources :

Example 1 with Batch

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;
}
Also used : Batch(com.pingcap.tikv.util.Batch) KvPair(org.tikv.kvproto.Kvrpcpb.KvPair) ArrayList(java.util.ArrayList) ExecutorCompletionService(java.util.concurrent.ExecutorCompletionService) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList) Pair(com.pingcap.tikv.util.Pair) KvPair(org.tikv.kvproto.Kvrpcpb.KvPair)

Aggregations

Batch (com.pingcap.tikv.util.Batch)1 Pair (com.pingcap.tikv.util.Pair)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ExecutorCompletionService (java.util.concurrent.ExecutorCompletionService)1 KvPair (org.tikv.kvproto.Kvrpcpb.KvPair)1