use of com.palantir.atlasdb.keyvalue.api.ColumnRangeSelection in project atlasdb by palantir.
the class RowsColumnRangeBatchRequestsTest method createRequest.
private RowsColumnRangeBatchRequest createRequest(int numTotalRows) {
ColumnRangeSelection fullColumnRange = new ColumnRangeSelection(col(0), col(5));
ImmutableRowsColumnRangeBatchRequest.Builder request = ImmutableRowsColumnRangeBatchRequest.builder().columnRangeSelection(fullColumnRange);
if (hasPartialFirstRow) {
request.partialFirstRow(Maps.immutableEntry(row(0), BatchColumnRangeSelection.create(col(3), col(5), 10)));
}
int firstFullRowIndex = hasPartialFirstRow ? 2 : 1;
int lastFullRowIndex = hasPartialLastRow ? numTotalRows - 1 : numTotalRows;
for (int rowNum = firstFullRowIndex; rowNum <= lastFullRowIndex; rowNum++) {
request.addRowsToLoadFully(row(rowNum));
}
if (hasPartialLastRow) {
request.partialLastRow(Maps.immutableEntry(row(numTotalRows), BatchColumnRangeSelection.create(fullColumnRange, 10)));
}
return request.build();
}
use of com.palantir.atlasdb.keyvalue.api.ColumnRangeSelection in project atlasdb by palantir.
the class KvsGetRowsColumnRangeBenchmarks method getAllColumnsAligned.
@Benchmark
@Threads(1)
@Warmup(time = 16, timeUnit = TimeUnit.SECONDS)
@Measurement(time = 160, timeUnit = TimeUnit.SECONDS)
public Object getAllColumnsAligned(WideRowsTable table) {
List<byte[]> rows = IntStream.rangeClosed(0, WideRowsTable.NUM_ROWS - 1).mapToObj(WideRowsTable::getRow).collect(Collectors.toList());
RowColumnRangeIterator rowsColumnRange = table.getKvs().getRowsColumnRange(table.getTableRef(), rows, new ColumnRangeSelection(null, null), 10000, Long.MAX_VALUE);
int expectedNumCells = WideRowsTable.NUM_ROWS * WideRowsTable.NUM_COLS_PER_ROW;
List<Map.Entry<Cell, Value>> loadedCells = new ArrayList<>(expectedNumCells);
while (rowsColumnRange.hasNext()) {
loadedCells.add(rowsColumnRange.next());
}
Preconditions.checkState(loadedCells.size() == expectedNumCells, "Should be %s cells, but were: %s", expectedNumCells, loadedCells.size());
return loadedCells;
}
use of com.palantir.atlasdb.keyvalue.api.ColumnRangeSelection in project atlasdb by palantir.
the class KvsGetRowsColumnRangeBenchmarks method getAllColumnsSingleBigRow.
@Benchmark
@Threads(1)
@Warmup(time = 16, timeUnit = TimeUnit.SECONDS)
@Measurement(time = 160, timeUnit = TimeUnit.SECONDS)
public Object getAllColumnsSingleBigRow(VeryWideRowTable table, Blackhole blackhole) {
RowColumnRangeIterator iter = table.getKvs().getRowsColumnRange(table.getTableRef(), Collections.singleton(Tables.ROW_BYTES.array()), new ColumnRangeSelection(null, null), 10000, Long.MAX_VALUE);
int count = 0;
while (iter.hasNext()) {
blackhole.consume(iter.next());
++count;
}
Preconditions.checkState(count == table.getNumCols(), "Should be %s cells, but were: %s", table.getNumCols(), count);
return count;
}
use of com.palantir.atlasdb.keyvalue.api.ColumnRangeSelection in project atlasdb by palantir.
the class AbstractKeyValueServiceTest method testGetRowColumnRangeCellBatchMultipleRows.
@Test
public void testGetRowColumnRangeCellBatchMultipleRows() {
putTestDataForSingleTimestamp();
RowColumnRangeIterator values = keyValueService.getRowsColumnRange(TEST_TABLE, ImmutableList.of(row1, row0, row2), new ColumnRangeSelection(PtBytes.EMPTY_BYTE_ARRAY, PtBytes.EMPTY_BYTE_ARRAY), 3, TEST_TIMESTAMP + 1);
assertNextElementMatches(values, Cell.create(row1, column0), value10);
assertNextElementMatches(values, Cell.create(row1, column2), value12);
assertNextElementMatches(values, TEST_CELL, value00);
assertNextElementMatches(values, Cell.create(row0, column1), value01);
assertNextElementMatches(values, Cell.create(row2, column1), value21);
assertNextElementMatches(values, Cell.create(row2, column2), value22);
assertFalse(values.hasNext());
}
use of com.palantir.atlasdb.keyvalue.api.ColumnRangeSelection in project atlasdb by palantir.
the class RangeScanDynamicColumnsBenchmark method getRange.
@Override
protected List<byte[]> getRange(Transaction txn, long startInclusive, long endExclusive) {
KvDynamicColumnsTable table = BenchmarksTableFactory.of().getKvDynamicColumnsTable(txn);
List<byte[]> data = Lists.newArrayList();
table.getRowsColumnRange(ImmutableSet.of(KvDynamicColumnsRow.of(bucket)), new ColumnRangeSelection(KvDynamicColumnsColumn.of(startInclusive).persistToBytes(), KvDynamicColumnsColumn.of(endExclusive).persistToBytes()), batchSize).forEachRemaining(entry -> data.add(entry.getValue().getValue()));
return data;
}
Aggregations