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));
}
}
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();
}
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()));
}
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());
}
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);
}
Aggregations