use of com.palantir.atlasdb.keyvalue.api.RowResult in project atlasdb by palantir.
the class AbstractTransactionTest method testRangeAfterTimestamp.
@Test
public void testRangeAfterTimestamp() {
putDirect("row1", "col2", "", 5);
putDirect("row2", "col2", "", 0);
RangeRequest rangeRequest = RangeRequest.builder().batchHint(1).build();
Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> ranges = keyValueService.getFirstBatchForRanges(TEST_TABLE, Collections.singleton(rangeRequest), 1);
assertEquals(1, ranges.keySet().size());
TokenBackedBasicResultsPage<RowResult<Value>, byte[]> page = ranges.values().iterator().next();
assertTrue(!page.getResults().isEmpty() || page.moreResultsAvailable());
}
use of com.palantir.atlasdb.keyvalue.api.RowResult in project atlasdb by palantir.
the class AbstractTransactionTest method testRangesTransactionColumnSelection.
@Test
public void testRangesTransactionColumnSelection() {
Transaction t = startTransaction();
put(t, "row1", "col1", "v1");
t.commit();
RangeRequest range1 = RangeRequest.builder().batchHint(3).build();
RangeRequest range2 = range1.getBuilder().retainColumns(ColumnSelection.create(ImmutableSet.of(PtBytes.toBytes("col1")))).build();
t = startTransaction();
Iterable<BatchingVisitable<RowResult<byte[]>>> ranges = t.getRanges(TEST_TABLE, Iterables.limit(Iterables.cycle(range1, range2), 1000));
for (BatchingVisitable<RowResult<byte[]>> batchingVisitable : ranges) {
final List<RowResult<byte[]>> list = BatchingVisitables.copyToList(batchingVisitable);
assertEquals(1, list.size());
assertEquals(1, list.get(0).getColumns().size());
}
RangeRequest range3 = range1.getBuilder().retainColumns(ColumnSelection.create(ImmutableSet.of(PtBytes.toBytes("col2")))).build();
verifyAllGetRangesImplsRangeSizes(t, range3, 0);
}
use of com.palantir.atlasdb.keyvalue.api.RowResult in project atlasdb by palantir.
the class AbstractTransactionTest method testKeyValueRangeColumnSelection.
@Test
public void testKeyValueRangeColumnSelection() {
putDirect("row1", "col1", "v1", 0);
putDirect("row1", "col2", "v2", 2);
putDirect("row1", "col4", "v5", 3);
putDirect("row1a", "col4", "v5", 100);
putDirect("row2", "col2", "v3", 1);
putDirect("row2", "col4", "v4", 6);
List<byte[]> selectedColumns = ImmutableList.of(PtBytes.toBytes("col2"));
RangeRequest simpleRange = RangeRequest.builder().retainColumns(ColumnSelection.create(selectedColumns)).build();
ImmutableList<RowResult<Value>> list = ImmutableList.copyOf(keyValueService.getRange(TEST_TABLE, simpleRange, 1));
assertEquals(0, list.size());
list = ImmutableList.copyOf(keyValueService.getRange(TEST_TABLE, simpleRange, 2));
assertEquals(1, list.size());
RowResult<Value> row = list.iterator().next();
assertEquals(1, row.getColumns().size());
list = ImmutableList.copyOf(keyValueService.getRange(TEST_TABLE, simpleRange, 3));
assertEquals(2, list.size());
row = list.iterator().next();
assertEquals(1, row.getColumns().size());
list = ImmutableList.copyOf(keyValueService.getRange(TEST_TABLE, simpleRange.getBuilder().endRowExclusive(PtBytes.toBytes("row2")).build(), 3));
assertEquals(1, list.size());
row = list.iterator().next();
assertEquals(1, row.getColumns().size());
list = ImmutableList.copyOf(keyValueService.getRange(TEST_TABLE, simpleRange.getBuilder().startRowInclusive(PtBytes.toBytes("row1a")).build(), 3));
assertEquals(1, list.size());
row = list.iterator().next();
assertEquals(1, row.getColumns().size());
}
use of com.palantir.atlasdb.keyvalue.api.RowResult in project atlasdb by palantir.
the class AbstractTransactionTest method testRangeBatchSizeOne.
@Test
public void testRangeBatchSizeOne() {
RangeRequest range = RangeRequest.builder().batchHint(1).build();
ClosableIterator<RowResult<Value>> ranges = keyValueService.getRange(TEST_TABLE, range, 1);
assertEquals(false, ranges.hasNext());
}
use of com.palantir.atlasdb.keyvalue.api.RowResult in project atlasdb by palantir.
the class AbstractTransactionTest method testKeyValueRangeReverse.
@Test
public void testKeyValueRangeReverse() {
if (!supportsReverse()) {
return;
}
putDirect("row1", "col1", "", 0);
putDirect("row2", "col1", "", 0);
putDirect("row2", "col2", "", 0);
RangeRequest allRange = RangeRequest.reverseBuilder().batchHint(3).build();
ClosableIterator<RowResult<Value>> range = keyValueService.getRange(TEST_TABLE, allRange, 1);
ImmutableList<RowResult<Value>> list = ImmutableList.copyOf(range);
assertEquals(2, list.size());
assertEquals("row2", PtBytes.toString(list.iterator().next().getRowName()));
}
Aggregations