Search in sources :

Example 6 with TableRowResult

use of com.palantir.atlasdb.api.TableRowResult 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)

Example 7 with TableRowResult

use of com.palantir.atlasdb.api.TableRowResult 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);
        }
    });
}
Also used : TableRowResult(com.palantir.atlasdb.api.TableRowResult) RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) TableRowResult(com.palantir.atlasdb.api.TableRowResult) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) RangeToken(com.palantir.atlasdb.api.RangeToken) TableRange(com.palantir.atlasdb.api.TableRange)

Aggregations

TableRowResult (com.palantir.atlasdb.api.TableRowResult)7 TableRowSelection (com.palantir.atlasdb.api.TableRowSelection)4 Test (org.junit.Test)3 RangeToken (com.palantir.atlasdb.api.RangeToken)2 TableRange (com.palantir.atlasdb.api.TableRange)2 TransactionToken (com.palantir.atlasdb.api.TransactionToken)2 RowResult (com.palantir.atlasdb.keyvalue.api.RowResult)2 JsonToken (com.fasterxml.jackson.core.JsonToken)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 RangeRequest (com.palantir.atlasdb.keyvalue.api.RangeRequest)1 SweepPriorityRowResult (com.palantir.atlasdb.schema.generated.SweepPriorityTable.SweepPriorityRowResult)1 NamedColumnDescription (com.palantir.atlasdb.table.description.NamedColumnDescription)1 TableMetadata (com.palantir.atlasdb.table.description.TableMetadata)1 Expectations (org.jmock.Expectations)1