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