use of com.palantir.atlasdb.api.RangeToken in project atlasdb by palantir.
the class AtlasConsoleServiceTest method testGetRange.
@Test
public void testGetRange() throws IOException {
final TableRange input = context.mock(TableRange.class);
final RangeToken output = context.mock(RangeToken.class);
context.checking(fromJson(input, TableRange.class));
context.checking(new Expectations() {
{
oneOf(delegate).getRange(token, input);
will(returnValue(output));
}
});
context.checking(toJson(output, RangeToken.class));
assertEquals(service.getRange(token, QUERY), RESULT);
context.assertIsSatisfied();
}
use of com.palantir.atlasdb.api.RangeToken in project atlasdb by palantir.
the class TransactionRemotingTest method testGetRangeNone.
@Test
public void testGetRangeNone() {
setupFooStatus1("sweep.priority");
TransactionToken token = TransactionToken.autoCommit();
RangeToken range = service.getRange(token, new TableRange("sweep.priority", new byte[1], new byte[2], ImmutableList.<byte[]>of(), 10));
Assert.assertTrue(Iterables.isEmpty(range.getResults().getResults()));
Assert.assertNull(range.getNextRange());
}
use of com.palantir.atlasdb.api.RangeToken in project atlasdb by palantir.
the class TransactionRemotingTest method testDelete.
@Test
public void testDelete() {
setupFooStatus1("sweep.priority");
Map<Cell, byte[]> contents = getSweepPriorityTableContents("foo");
TransactionToken token = TransactionToken.autoCommit();
service.delete(token, new TableCell("sweep.priority", contents.keySet()));
RangeToken range = service.getRange(token, new TableRange("sweep.priority", new byte[0], new byte[0], ImmutableList.<byte[]>of(), 10));
Assert.assertTrue(Iterables.isEmpty(range.getResults().getResults()));
Assert.assertNull(range.getNextRange());
}
use of com.palantir.atlasdb.api.RangeToken in project atlasdb by palantir.
the class AtlasDbServiceImpl method getRange.
@Override
public RangeToken getRange(TransactionToken token, final TableRange range) {
return runReadOnly(token, transaction -> {
int limit = range.getBatchSize() + 1;
RangeRequest request = RangeRequest.builder().startRowInclusive(range.getStartRow()).endRowExclusive(range.getEndRow()).batchHint(limit).retainColumns(range.getColumns()).build();
BatchingVisitable<RowResult<byte[]>> visitable = transaction.getRange(getTableRef(range.getTableName()), request);
List<RowResult<byte[]>> results = BatchingVisitables.limit(visitable, limit).immutableCopy();
if (results.size() == limit) {
TableRowResult data = new TableRowResult(range.getTableName(), results.subList(0, limit - 1));
RowResult<byte[]> lastResultInBatch = results.get(limit - 1);
TableRange nextRange = range.withStartRow(lastResultInBatch.getRowName());
return new RangeToken(data, nextRange);
} else {
TableRowResult data = new TableRowResult(range.getTableName(), results);
return new RangeToken(data, null);
}
});
}
Aggregations