use of com.palantir.atlasdb.transaction.api.ImmutableGetRangesQuery in project atlasdb by palantir.
the class AbstractTransactionTest method getRangesProcessesVisitableOnOriginalElements.
@Test
public void getRangesProcessesVisitableOnOriginalElements() {
UnaryOperator<RangeRequest> fiveElementLimit = range -> range.withBatchHint(5);
RangeRequest sevenElementRequest = RangeRequest.builder().startRowInclusive(PtBytes.toBytes("tom")).batchHint(7).build();
RangeRequest nineElementRequest = RangeRequest.builder().startRowInclusive(PtBytes.toBytes("tom")).batchHint(9).build();
BiFunction<RangeRequest, BatchingVisitable<RowResult<byte[]>>, RangeRequest> exposingProcessor = (rangeRequest, $) -> rangeRequest;
Transaction transaction = startTransaction();
List<RangeRequest> visited = transaction.getRanges(ImmutableGetRangesQuery.<RangeRequest>builder().tableRef(TEST_TABLE).rangeRequests(ImmutableList.of(sevenElementRequest, nineElementRequest)).rangeRequestOptimizer(fiveElementLimit).visitableProcessor(exposingProcessor).build()).collect(Collectors.toList());
assertThat(visited).containsExactlyInAnyOrder(sevenElementRequest, nineElementRequest);
}
use of com.palantir.atlasdb.transaction.api.ImmutableGetRangesQuery in project atlasdb by palantir.
the class AbstractTransactionTest method getRangesSendsQueriesThatHaveGoneThroughTheOptimizer.
@Test
public void getRangesSendsQueriesThatHaveGoneThroughTheOptimizer() {
RangeRequest goldenRequest = RangeRequest.builder().startRowInclusive(PtBytes.toBytes("tom")).build();
RangeRequest otherRequest = RangeRequest.builder().startRowInclusive(PtBytes.toBytes("zzzz")).build();
// Contract is not entirely valid, but we don't have a good way of mocking out the KVS.
UnaryOperator<RangeRequest> goldenForcingOperator = $ -> goldenRequest;
putDirect("tom", "col", "value", 0);
BiFunction<RangeRequest, BatchingVisitable<RowResult<byte[]>>, byte[]> singleValueExtractor = ($, visitable) -> Iterables.getOnlyElement(BatchingVisitables.copyToList(visitable)).getOnlyColumnValue();
Transaction transaction = startTransaction();
List<byte[]> extractedValue = transaction.getRanges(ImmutableGetRangesQuery.<byte[]>builder().tableRef(TEST_TABLE).rangeRequests(ImmutableList.of(otherRequest)).rangeRequestOptimizer(goldenForcingOperator).visitableProcessor(singleValueExtractor).build()).collect(Collectors.toList());
assertThat(extractedValue).containsExactly(PtBytes.toBytes("value"));
}
Aggregations