use of com.palantir.atlasdb.keyvalue.api.RangeRequest 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.RangeRequest 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.RangeRequest 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.RangeRequest in project atlasdb by palantir.
the class AbstractKeyValueServiceTest method setupTestRowsZeroOneAndTwoAndDeleteFrom.
private void setupTestRowsZeroOneAndTwoAndDeleteFrom(byte[] start, byte[] end, boolean reverse) {
putTestDataForRowsZeroOneAndTwo();
RangeRequest range = RangeRequest.builder(reverse).startRowInclusive(start).endRowExclusive(end).build();
keyValueService.deleteRange(TEST_TABLE, range);
}
use of com.palantir.atlasdb.keyvalue.api.RangeRequest in project atlasdb by palantir.
the class AbstractTransactionTest method testRangePagingBatchSizeOneReverse.
@Test
public void testRangePagingBatchSizeOneReverse() {
if (!supportsReverse()) {
return;
}
int totalPuts = 100;
for (int i = 0; i < totalPuts; i++) {
putDirect("row" + i, "col1", "v1", 0);
}
RangeRequest rangeRequest = RangeRequest.reverseBuilder().batchHint(1).build();
Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> ranges = keyValueService.getFirstBatchForRanges(TEST_TABLE, Iterables.limit(Iterables.cycle(rangeRequest), 100), 1);
assertEquals(1, ranges.keySet().size());
assertEquals(1, ranges.values().iterator().next().getResults().size());
assertEquals("row99", PtBytes.toString(ranges.values().iterator().next().getResults().iterator().next().getRowName()));
}
Aggregations