use of com.palantir.atlasdb.keyvalue.api.RowResult in project atlasdb by palantir.
the class AbstractKeyValueServiceTest method testGetRangeOfTimestampsReturnsAllRows.
@Test
public void testGetRangeOfTimestampsReturnsAllRows() {
keyValueService.put(TEST_TABLE, ImmutableMap.of(Cell.create(row0, column0), value0_t0, Cell.create(row1, column0), value0_t0, Cell.create(row2, column0), value0_t0), TEST_TIMESTAMP);
RangeRequest range = RangeRequest.all().withBatchHint(1);
List<RowResult<Set<Long>>> results = ImmutableList.copyOf(keyValueService.getRangeOfTimestamps(TEST_TABLE, range, TEST_TIMESTAMP + 1));
assertEquals(3, results.size());
assertArrayEquals(row0, results.get(0).getRowName());
assertArrayEquals(row1, results.get(1).getRowName());
assertArrayEquals(row2, results.get(2).getRowName());
}
use of com.palantir.atlasdb.keyvalue.api.RowResult in project atlasdb by palantir.
the class AbstractKeyValueServiceTest method doTestGetRangePagingLastRowEdgeCase.
private void doTestGetRangePagingLastRowEdgeCase(int numColumnsInMetadata, int batchSizeHint, boolean reverse) {
TableReference tableRef = createTableWithNamedColumns(numColumnsInMetadata);
byte[] last = reverse ? RangeRequests.getFirstRowName() : RangeRequests.getLastRowName();
Map<Cell, byte[]> values = ImmutableMap.of(Cell.create(last, PtBytes.toBytes("c1")), PtBytes.toBytes("a"), Cell.create(last, last), PtBytes.toBytes("b"));
keyValueService.put(tableRef, values, TEST_TIMESTAMP);
RangeRequest request = RangeRequest.builder(reverse).batchHint(batchSizeHint).build();
try (ClosableIterator<RowResult<Value>> iter = keyValueService.getRange(tableRef, request, Long.MAX_VALUE)) {
List<RowResult<Value>> results = ImmutableList.copyOf(iter);
List<RowResult<Value>> expected = ImmutableList.of(RowResult.create(last, ImmutableSortedMap.<byte[], Value>orderedBy(UnsignedBytes.lexicographicalComparator()).put(PtBytes.toBytes("c1"), Value.create(PtBytes.toBytes("a"), TEST_TIMESTAMP)).put(last, Value.create(PtBytes.toBytes("b"), TEST_TIMESTAMP)).build()));
assertEquals(expected, results);
}
}
use of com.palantir.atlasdb.keyvalue.api.RowResult in project atlasdb by palantir.
the class AbstractKeyValueServiceTest method testGetRangeOfTimestampsOmitsTimestampsLessThanMax.
@Test
public void testGetRangeOfTimestampsOmitsTimestampsLessThanMax() {
keyValueService.put(TEST_TABLE, ImmutableMap.of(Cell.create(row0, column0), value0_t0), TEST_TIMESTAMP);
keyValueService.put(TEST_TABLE, ImmutableMap.of(Cell.create(row0, column0), value0_t1), TEST_TIMESTAMP + 10);
RangeRequest range = RangeRequest.all().withBatchHint(2);
List<RowResult<Set<Long>>> results = ImmutableList.copyOf(keyValueService.getRangeOfTimestamps(TEST_TABLE, range, TEST_TIMESTAMP + 1));
assertEquals(1, results.size());
assertArrayEquals(row0, results.get(0).getRowName());
assertEquals(TEST_TIMESTAMP, (long) results.get(0).getOnlyColumnValue().iterator().next());
}
use of com.palantir.atlasdb.keyvalue.api.RowResult in project atlasdb by palantir.
the class AbstractKeyValueServiceTest method testGetRangeOfTimestampsFetchesProperRange.
@Test
public void testGetRangeOfTimestampsFetchesProperRange() {
keyValueService.put(TEST_TABLE, ImmutableMap.of(Cell.create(row0, column0), value0_t0, Cell.create(row1, column0), value0_t0, Cell.create(row2, column0), value0_t0), TEST_TIMESTAMP);
keyValueService.put(TEST_TABLE, ImmutableMap.of(Cell.create(row0, column0), value0_t1), TEST_TIMESTAMP + 10);
RangeRequest range = RangeRequest.builder().startRowInclusive(row1).endRowExclusive(row2).build();
List<RowResult<Set<Long>>> results = ImmutableList.copyOf(keyValueService.getRangeOfTimestamps(TEST_TABLE, range, TEST_TIMESTAMP + 1));
assertEquals(1, results.size());
assertArrayEquals(row1, results.get(0).getRowName());
}
use of com.palantir.atlasdb.keyvalue.api.RowResult in project atlasdb by palantir.
the class AbstractTransactionTest method testKeyValueRangesMany3.
@Test
public void testKeyValueRangesMany3() {
putDirect("row1", "col1", "", 0);
putDirect("row2", "col1", "", 0);
putDirect("row2", "col2", "", 0);
RangeRequest allRange = RangeRequest.builder().prefixRange("row1".getBytes()).batchHint(3).build();
for (int i = 0; i < 1000; i++) {
ClosableIterator<RowResult<Value>> range = keyValueService.getRange(TEST_TABLE, allRange, 1);
ImmutableList<RowResult<Value>> list = ImmutableList.copyOf(range);
assertEquals(1, list.size());
}
}
Aggregations