Search in sources :

Example 16 with RangeRequest

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

the class AbstractTransactionTest method testRangesTransaction.

@Test
public void testRangesTransaction() {
    Transaction t = startTransaction();
    put(t, "row1", "col1", "v1");
    t.commit();
    RangeRequest allRange = RangeRequest.builder().batchHint(3).build();
    t = startTransaction();
    verifyAllGetRangesImplsRangeSizes(t, allRange, 1);
}
Also used : Transaction(com.palantir.atlasdb.transaction.api.Transaction) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) Test(org.junit.Test)

Example 17 with RangeRequest

use of com.palantir.atlasdb.keyvalue.api.RangeRequest 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)

Example 18 with RangeRequest

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

the class AbstractTransactionTest method testKeyValueRanges2.

@Test
public void testKeyValueRanges2() {
    putDirect("row1", "col1", "", 0);
    putDirect("row2", "col1", "", 0);
    putDirect("row2", "col2", "", 0);
    final RangeRequest allRange = RangeRequest.builder().build();
    final RangeRequest oneRange = RangeRequest.builder().startRowInclusive("row2".getBytes()).build();
    final RangeRequest allRangeBatch = RangeRequest.builder().batchHint(3).build();
    Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> ranges = keyValueService.getFirstBatchForRanges(TEST_TABLE, ImmutableList.of(allRange, oneRange, allRangeBatch), 1);
    assertTrue(ranges.get(allRange).getResults().size() >= 1);
    assertEquals(2, ranges.get(allRangeBatch).getResults().size());
    assertFalse(ranges.get(allRangeBatch).moreResultsAvailable());
    assertEquals(1, ranges.get(oneRange).getResults().size());
}
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)

Example 19 with RangeRequest

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

the class AbstractTransactionTest method testKeyValueRangesMany2.

@Test
public void testKeyValueRangesMany2() {
    putDirect("row1", "col1", "", 0);
    putDirect("row2", "col1", "", 0);
    putDirect("row2", "col2", "", 0);
    RangeRequest allRange = RangeRequest.builder().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(2, list.size());
    }
}
Also used : RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) Test(org.junit.Test)

Example 20 with RangeRequest

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

the class AbstractTransactionTest method testRangeAfterTimestampReverse.

@Test
public void testRangeAfterTimestampReverse() {
    if (!supportsReverse()) {
        return;
    }
    putDirect("row1", "col2", "", 0);
    putDirect("row2", "col2", "", 0);
    putDirect("row3", "col2", "", 5);
    RangeRequest rangeRequest = RangeRequest.reverseBuilder().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)

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