Search in sources :

Example 1 with TableRowSelection

use of com.palantir.atlasdb.api.TableRowSelection in project atlasdb by palantir.

the class TableRowSelectionDeserializer method deserialize.

@Override
public TableRowSelection deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonNode node = jp.readValueAsTree();
    String tableName = node.get("table").textValue();
    TableMetadata metadata = metadataCache.getMetadata(tableName);
    Iterable<byte[]> rows = AtlasDeserializers.deserializeRows(metadata.getRowMetadata(), node.get("rows"));
    Iterable<byte[]> columns = AtlasDeserializers.deserializeNamedCols(metadata.getColumns(), node.get("cols"));
    if (Iterables.isEmpty(columns)) {
        return new TableRowSelection(tableName, rows, ColumnSelection.all());
    } else {
        return new TableRowSelection(tableName, rows, ColumnSelection.create(columns));
    }
}
Also used : TableMetadata(com.palantir.atlasdb.table.description.TableMetadata) TableRowSelection(com.palantir.atlasdb.api.TableRowSelection) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 2 with TableRowSelection

use of com.palantir.atlasdb.api.TableRowSelection in project atlasdb by palantir.

the class AtlasConsoleServiceTest method testGetRows.

@Test
public void testGetRows() throws IOException {
    final TableRowSelection input = context.mock(TableRowSelection.class);
    final TableRowResult output = context.mock(TableRowResult.class);
    context.checking(fromJson(input, TableRowSelection.class));
    context.checking(new Expectations() {

        {
            oneOf(delegate).getRows(token, input);
            will(returnValue(output));
        }
    });
    context.checking(toJson(output, TableRowResult.class));
    assertEquals(service.getRows(token, QUERY), RESULT);
    context.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) TableRowSelection(com.palantir.atlasdb.api.TableRowSelection) TableRowResult(com.palantir.atlasdb.api.TableRowResult) Test(org.junit.Test)

Example 3 with TableRowSelection

use of com.palantir.atlasdb.api.TableRowSelection in project atlasdb by palantir.

the class TransactionRemotingTest method testGetRowsNone.

@Test
public void testGetRowsNone() {
    setupFooStatus1("sweep.priority");
    TransactionToken txId = TransactionToken.autoCommit();
    TableRowResult badResults = service.getRows(txId, new TableRowSelection("sweep.priority", ImmutableList.of(new byte[1]), ColumnSelection.all()));
    Assert.assertTrue(Iterables.isEmpty(badResults.getResults()));
}
Also used : TableRowResult(com.palantir.atlasdb.api.TableRowResult) TableRowSelection(com.palantir.atlasdb.api.TableRowSelection) TransactionToken(com.palantir.atlasdb.api.TransactionToken) Test(org.junit.Test)

Example 4 with TableRowSelection

use of com.palantir.atlasdb.api.TableRowSelection in project atlasdb by palantir.

the class TransactionRemotingTest method testGetRowsSome.

@Test
public void testGetRowsSome() {
    setupFooStatus1("sweep.priority");
    TransactionToken txId = TransactionToken.autoCommit();
    TableRowResult goodResults = service.getRows(txId, new TableRowSelection("sweep.priority", ImmutableList.of(SweepPriorityRow.of("foo").persistToBytes()), ColumnSelection.all()));
    SweepPriorityRowResult result = SweepPriorityRowResult.of(Iterables.getOnlyElement(goodResults.getResults()));
    Assert.assertEquals(1L, result.getCellsExamined().longValue());
}
Also used : TableRowResult(com.palantir.atlasdb.api.TableRowResult) TableRowSelection(com.palantir.atlasdb.api.TableRowSelection) TransactionToken(com.palantir.atlasdb.api.TransactionToken) SweepPriorityRowResult(com.palantir.atlasdb.schema.generated.SweepPriorityTable.SweepPriorityRowResult) Test(org.junit.Test)

Example 5 with TableRowSelection

use of com.palantir.atlasdb.api.TableRowSelection in project atlasdb by palantir.

the class AtlasConsoleServiceImpl method getRows.

@Override
public String getRows(TransactionToken token, String data) throws IOException {
    TableRowSelection rows = fromJson(data, TableRowSelection.class);
    TableRowResult result = service.getRows(token, rows);
    return toJson(result, TableRowResult.class);
}
Also used : TableRowSelection(com.palantir.atlasdb.api.TableRowSelection) TableRowResult(com.palantir.atlasdb.api.TableRowResult)

Aggregations

TableRowSelection (com.palantir.atlasdb.api.TableRowSelection)5 TableRowResult (com.palantir.atlasdb.api.TableRowResult)4 Test (org.junit.Test)3 TransactionToken (com.palantir.atlasdb.api.TransactionToken)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 SweepPriorityRowResult (com.palantir.atlasdb.schema.generated.SweepPriorityTable.SweepPriorityRowResult)1 TableMetadata (com.palantir.atlasdb.table.description.TableMetadata)1 Expectations (org.jmock.Expectations)1