Search in sources :

Example 1 with RangeToken

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);
}
Also used : RangeToken(com.palantir.atlasdb.api.RangeToken) TableRange(com.palantir.atlasdb.api.TableRange)

Example 2 with RangeToken

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());
}
Also used : TransactionToken(com.palantir.atlasdb.api.TransactionToken) SweepPriorityRowResult(com.palantir.atlasdb.schema.generated.SweepPriorityTable.SweepPriorityRowResult) RangeToken(com.palantir.atlasdb.api.RangeToken) TableRange(com.palantir.atlasdb.api.TableRange) Test(org.junit.Test)

Example 3 with RangeToken

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());
}
Also used : TransactionToken(com.palantir.atlasdb.api.TransactionToken) RangeToken(com.palantir.atlasdb.api.RangeToken) TableRange(com.palantir.atlasdb.api.TableRange) Test(org.junit.Test)

Example 4 with RangeToken

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());
}
Also used : TransactionToken(com.palantir.atlasdb.api.TransactionToken) TableCellVal(com.palantir.atlasdb.api.TableCellVal) RangeToken(com.palantir.atlasdb.api.RangeToken) TableRange(com.palantir.atlasdb.api.TableRange) Test(org.junit.Test)

Example 5 with RangeToken

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);
}
Also used : TableRowResult(com.palantir.atlasdb.api.TableRowResult) RangeToken(com.palantir.atlasdb.api.RangeToken) TableRange(com.palantir.atlasdb.api.TableRange) JsonToken(com.fasterxml.jackson.core.JsonToken)

Aggregations

RangeToken (com.palantir.atlasdb.api.RangeToken)9 TableRange (com.palantir.atlasdb.api.TableRange)9 Test (org.junit.Test)6 TransactionToken (com.palantir.atlasdb.api.TransactionToken)5 TableRowResult (com.palantir.atlasdb.api.TableRowResult)2 JsonToken (com.fasterxml.jackson.core.JsonToken)1 TableCell (com.palantir.atlasdb.api.TableCell)1 TableCellVal (com.palantir.atlasdb.api.TableCellVal)1 Cell (com.palantir.atlasdb.keyvalue.api.Cell)1 RangeRequest (com.palantir.atlasdb.keyvalue.api.RangeRequest)1 RowResult (com.palantir.atlasdb.keyvalue.api.RowResult)1 SweepPriorityRowResult (com.palantir.atlasdb.schema.generated.SweepPriorityTable.SweepPriorityRowResult)1 Expectations (org.jmock.Expectations)1