Search in sources :

Example 16 with TokenBackedBasicResultsPage

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);
    }
}
Also used : TokenBackedBasicResultsPage(com.palantir.util.paging.TokenBackedBasicResultsPage) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) Value(com.palantir.atlasdb.keyvalue.api.Value) BlockingWorkerPool(com.palantir.common.concurrent.BlockingWorkerPool)

Aggregations

TokenBackedBasicResultsPage (com.palantir.util.paging.TokenBackedBasicResultsPage)16 RangeRequest (com.palantir.atlasdb.keyvalue.api.RangeRequest)14 Value (com.palantir.atlasdb.keyvalue.api.Value)13 RowResult (com.palantir.atlasdb.keyvalue.api.RowResult)10 Test (org.junit.Test)7 AbstractPagingIterable (com.palantir.util.paging.AbstractPagingIterable)6 Cell (com.palantir.atlasdb.keyvalue.api.Cell)3 Set (java.util.Set)3 SortedMap (java.util.SortedMap)3 AbstractIterator (com.google.common.collect.AbstractIterator)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 BatchColumnRangeSelection (com.palantir.atlasdb.keyvalue.api.BatchColumnRangeSelection)2 ColumnSelection (com.palantir.atlasdb.keyvalue.api.ColumnSelection)2 RowColumnRangeIterator (com.palantir.atlasdb.keyvalue.api.RowColumnRangeIterator)2 Entry (java.util.Map.Entry)2 Timer (com.codahale.metrics.Timer)1 BoundStatement (com.datastax.driver.core.BoundStatement)1 ResultSet (com.datastax.driver.core.ResultSet)1 Row (com.datastax.driver.core.Row)1 UnavailableException (com.datastax.driver.core.exceptions.UnavailableException)1