Search in sources :

Example 6 with RowResult

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());
}
Also used : RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) Test(org.junit.Test)

Example 7 with RowResult

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);
    }
}
Also used : RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) Cell(com.palantir.atlasdb.keyvalue.api.Cell)

Example 8 with RowResult

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());
}
Also used : RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) Test(org.junit.Test)

Example 9 with RowResult

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());
}
Also used : RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) Test(org.junit.Test)

Example 10 with RowResult

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());
    }
}
Also used : RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) Test(org.junit.Test)

Aggregations

RowResult (com.palantir.atlasdb.keyvalue.api.RowResult)57 RangeRequest (com.palantir.atlasdb.keyvalue.api.RangeRequest)40 Test (org.junit.Test)23 Cell (com.palantir.atlasdb.keyvalue.api.Cell)17 Value (com.palantir.atlasdb.keyvalue.api.Value)16 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)10 TokenBackedBasicResultsPage (com.palantir.util.paging.TokenBackedBasicResultsPage)10 Set (java.util.Set)8 ColumnSelection (com.palantir.atlasdb.keyvalue.api.ColumnSelection)7 Transaction (com.palantir.atlasdb.transaction.api.Transaction)7 SortedMap (java.util.SortedMap)7 Map (java.util.Map)6 ImmutableSet (com.google.common.collect.ImmutableSet)5 Lists (com.google.common.collect.Lists)5 AbstractPagingIterable (com.palantir.util.paging.AbstractPagingIterable)5 Entry (java.util.Map.Entry)5 ImmutableList (com.google.common.collect.ImmutableList)4 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)4 PtBytes (com.palantir.atlasdb.encoding.PtBytes)4 ClosableIterator (com.palantir.common.base.ClosableIterator)4