use of com.palantir.util.paging.TokenBackedBasicResultsPage in project atlasdb by palantir.
the class KeyValueServices method getFirstBatchForRangesUsingGetRangeConcurrent.
@SuppressWarnings("checkstyle:LineLength")
public static Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> getFirstBatchForRangesUsingGetRangeConcurrent(ExecutorService executor, final KeyValueService kv, final TableReference tableRef, Iterable<RangeRequest> rangeRequests, final long timestamp, int maxConcurrentRequests) {
final Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> ret = Maps.newConcurrentMap();
BlockingWorkerPool pool = new BlockingWorkerPool(executor, maxConcurrentRequests);
try {
for (final RangeRequest request : rangeRequests) {
pool.submitTask(() -> getFirstBatchForRangeUsingGetRange(kv, tableRef, request, timestamp, ret));
}
pool.waitForSubmittedTasks();
return ret;
} catch (InterruptedException e) {
throw Throwables.rewrapAndThrowUncheckedException(e);
}
}
Aggregations