Search in sources :

Example 56 with RangeRequest

use of com.palantir.atlasdb.keyvalue.api.RangeRequest in project atlasdb by palantir.

the class AbstractTransactionTest method testRangeAfterTimestamp2.

@Test
public void testRangeAfterTimestamp2() {
    putDirect("row1", "col2", "", 5);
    putDirect("row2", "col2", "", 0);
    putDirect("row3", "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.moreResultsAvailable());
}
Also used : TokenBackedBasicResultsPage(com.palantir.util.paging.TokenBackedBasicResultsPage) RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) Value(com.palantir.atlasdb.keyvalue.api.Value) Test(org.junit.Test)

Example 57 with RangeRequest

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

Example 58 with RangeRequest

use of com.palantir.atlasdb.keyvalue.api.RangeRequest 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);
}
Also used : BatchingVisitable(com.palantir.common.base.BatchingVisitable) RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) Transaction(com.palantir.atlasdb.transaction.api.Transaction) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) Test(org.junit.Test)

Example 59 with RangeRequest

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

Example 60 with RangeRequest

use of com.palantir.atlasdb.keyvalue.api.RangeRequest in project atlasdb by palantir.

the class AbstractTransactionTest method testRangePageBatchSizeOne.

@Test
public void testRangePageBatchSizeOne() {
    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());
    assertEquals(0, ranges.values().iterator().next().getResults().size());
    assertEquals(false, ranges.values().iterator().next().moreResultsAvailable());
}
Also used : TokenBackedBasicResultsPage(com.palantir.util.paging.TokenBackedBasicResultsPage) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) Value(com.palantir.atlasdb.keyvalue.api.Value) Test(org.junit.Test)

Aggregations

RangeRequest (com.palantir.atlasdb.keyvalue.api.RangeRequest)68 RowResult (com.palantir.atlasdb.keyvalue.api.RowResult)36 Test (org.junit.Test)35 Value (com.palantir.atlasdb.keyvalue.api.Value)17 TokenBackedBasicResultsPage (com.palantir.util.paging.TokenBackedBasicResultsPage)14 Cell (com.palantir.atlasdb.keyvalue.api.Cell)12 Transaction (com.palantir.atlasdb.transaction.api.Transaction)7 List (java.util.List)5 Set (java.util.Set)5 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)4 StringValue (com.palantir.atlasdb.table.description.test.StringValue)4 AbstractPagingIterable (com.palantir.util.paging.AbstractPagingIterable)4 Map (java.util.Map)4 ColumnSelection (com.palantir.atlasdb.keyvalue.api.ColumnSelection)3 AbstractIterator (com.google.common.collect.AbstractIterator)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Hashing (com.google.common.hash.Hashing)2 NameComponentDescription (com.palantir.atlasdb.table.description.NameComponentDescription)2 BatchingVisitableView (com.palantir.common.base.BatchingVisitableView)2 ClosableIterator (com.palantir.common.base.ClosableIterator)2