use of com.palantir.atlasdb.api.RangeToken in project atlasdb by palantir.
the class AtlasConsoleServiceImpl method getRange.
@Override
public String getRange(TransactionToken token, String data) throws IOException {
TableRange range = fromJson(data, TableRange.class);
RangeToken result = service.getRange(token, range);
return toJson(result, RangeToken.class);
}
use of com.palantir.atlasdb.api.RangeToken in project atlasdb by palantir.
the class TransactionRemotingTest method testGetRangeSome.
@Test
public void testGetRangeSome() {
setupFooStatus1("sweep.priority");
TransactionToken token = TransactionToken.autoCommit();
RangeToken range = service.getRange(token, new TableRange("sweep.priority", new byte[0], new byte[0], ImmutableList.<byte[]>of(), 10));
SweepPriorityRowResult result = SweepPriorityRowResult.of(Iterables.getOnlyElement(range.getResults().getResults()));
Assert.assertEquals(1L, result.getCellsExamined().longValue());
Assert.assertNull(range.getNextRange());
}
use of com.palantir.atlasdb.api.RangeToken in project atlasdb by palantir.
the class TransactionRemotingTest method testGetRangeMultipleBatchesWithColSelection.
@Test
public void testGetRangeMultipleBatchesWithColSelection() {
setupMultipleValues();
TransactionToken token = TransactionToken.autoCommit();
RangeToken range = service.getRange(token, new TableRange("sweep.priority", new byte[0], new byte[0], ImmutableList.<byte[]>of("e".getBytes()), 2));
Assert.assertEquals(2, Iterables.size(range.getResults().getResults()));
Assert.assertNotNull(range.getNextRange());
// get second range
RangeToken range2 = service.getRange(token, range.getNextRange());
Assert.assertEquals(1, Iterables.size(range2.getResults().getResults()));
Assert.assertNull(range2.getNextRange());
}
use of com.palantir.atlasdb.api.RangeToken in project atlasdb by palantir.
the class TransactionRemotingTest method testAbort.
@Test
public void testAbort() {
TransactionToken txId = service.startTransaction();
service.put(txId, new TableCellVal("sweep.priority", getSweepPriorityTableContents("foo")));
service.abort(txId);
service.commit(txId);
txId = TransactionToken.autoCommit();
RangeToken range = service.getRange(txId, 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 RangeTokenDeserializer method deserialize.
@Override
public RangeToken deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
JsonToken jsonToken = jp.getCurrentToken();
if (jsonToken == JsonToken.START_OBJECT) {
jsonToken = jp.nextToken();
}
TableRowResult results = null;
TableRange nextRange = null;
for (; jsonToken == JsonToken.FIELD_NAME; jsonToken = jp.nextToken()) {
String fieldName = jp.getCurrentName();
jsonToken = jp.nextToken();
if (fieldName.equals("data")) {
results = jp.readValueAs(TableRowResult.class);
} else if (fieldName.equals("next")) {
nextRange = jp.readValueAs(TableRange.class);
}
}
return new RangeToken(results, nextRange);
}
Aggregations