Search in sources :

Example 1 with TransactionToken

use of com.palantir.atlasdb.api.TransactionToken in project atlasdb by palantir.

the class TransactionRemotingTest method testGetCellsSome.

@Test
public void testGetCellsSome() {
    setupFooStatus1("sweep.priority");
    TransactionToken txId = service.startTransaction();
    Map<Cell, byte[]> contents = getSweepPriorityTableContents("foo");
    TableCellVal goodCells = service.getCells(txId, new TableCell("sweep.priority", contents.keySet()));
    Assert.assertEquals(contents.keySet(), goodCells.getResults().keySet());
    Assert.assertArrayEquals(Iterables.getOnlyElement(contents.values()), Iterables.getOnlyElement(goodCells.getResults().values()));
    service.commit(txId);
}
Also used : TableCell(com.palantir.atlasdb.api.TableCell) TransactionToken(com.palantir.atlasdb.api.TransactionToken) TableCellVal(com.palantir.atlasdb.api.TableCellVal) Cell(com.palantir.atlasdb.keyvalue.api.Cell) TableCell(com.palantir.atlasdb.api.TableCell) Test(org.junit.Test)

Example 2 with TransactionToken

use of com.palantir.atlasdb.api.TransactionToken in project atlasdb by palantir.

the class TransactionRemotingTest method testGetRangeSome.

@Test
public void testGetRangeSome() {
    setupFooStatus1("sweep.priority");
    TransactionToken token = TransactionToken.autoCommit();
    RangeToken range = service.getRange(token, new TableRange("sweep.priority", new byte[0], new byte[0], ImmutableList.<byte[]>of(), 10));
    SweepPriorityRowResult result = SweepPriorityRowResult.of(Iterables.getOnlyElement(range.getResults().getResults()));
    Assert.assertEquals(1L, result.getCellsExamined().longValue());
    Assert.assertNull(range.getNextRange());
}
Also used : TransactionToken(com.palantir.atlasdb.api.TransactionToken) SweepPriorityRowResult(com.palantir.atlasdb.schema.generated.SweepPriorityTable.SweepPriorityRowResult) RangeToken(com.palantir.atlasdb.api.RangeToken) TableRange(com.palantir.atlasdb.api.TableRange) Test(org.junit.Test)

Example 3 with TransactionToken

use of com.palantir.atlasdb.api.TransactionToken in project atlasdb by palantir.

the class TransactionRemotingTest method testGetRowsNone.

@Test
public void testGetRowsNone() {
    setupFooStatus1("sweep.priority");
    TransactionToken txId = TransactionToken.autoCommit();
    TableRowResult badResults = service.getRows(txId, new TableRowSelection("sweep.priority", ImmutableList.of(new byte[1]), ColumnSelection.all()));
    Assert.assertTrue(Iterables.isEmpty(badResults.getResults()));
}
Also used : TableRowResult(com.palantir.atlasdb.api.TableRowResult) TableRowSelection(com.palantir.atlasdb.api.TableRowSelection) TransactionToken(com.palantir.atlasdb.api.TransactionToken) Test(org.junit.Test)

Example 4 with TransactionToken

use of com.palantir.atlasdb.api.TransactionToken in project atlasdb by palantir.

the class TransactionRemotingTest method testGetRowsSome.

@Test
public void testGetRowsSome() {
    setupFooStatus1("sweep.priority");
    TransactionToken txId = TransactionToken.autoCommit();
    TableRowResult goodResults = service.getRows(txId, new TableRowSelection("sweep.priority", ImmutableList.of(SweepPriorityRow.of("foo").persistToBytes()), ColumnSelection.all()));
    SweepPriorityRowResult result = SweepPriorityRowResult.of(Iterables.getOnlyElement(goodResults.getResults()));
    Assert.assertEquals(1L, result.getCellsExamined().longValue());
}
Also used : TableRowResult(com.palantir.atlasdb.api.TableRowResult) TableRowSelection(com.palantir.atlasdb.api.TableRowSelection) TransactionToken(com.palantir.atlasdb.api.TransactionToken) SweepPriorityRowResult(com.palantir.atlasdb.schema.generated.SweepPriorityTable.SweepPriorityRowResult) Test(org.junit.Test)

Example 5 with TransactionToken

use of com.palantir.atlasdb.api.TransactionToken in project atlasdb by palantir.

the class TransactionRemotingTest method testGetRangeMultipleBatchesWithColSelection.

@Test
public void testGetRangeMultipleBatchesWithColSelection() {
    setupMultipleValues();
    TransactionToken token = TransactionToken.autoCommit();
    RangeToken range = service.getRange(token, new TableRange("sweep.priority", new byte[0], new byte[0], ImmutableList.<byte[]>of("e".getBytes()), 2));
    Assert.assertEquals(2, Iterables.size(range.getResults().getResults()));
    Assert.assertNotNull(range.getNextRange());
    // get second range
    RangeToken range2 = service.getRange(token, range.getNextRange());
    Assert.assertEquals(1, Iterables.size(range2.getResults().getResults()));
    Assert.assertNull(range2.getNextRange());
}
Also used : TransactionToken(com.palantir.atlasdb.api.TransactionToken) RangeToken(com.palantir.atlasdb.api.RangeToken) TableRange(com.palantir.atlasdb.api.TableRange) Test(org.junit.Test)

Aggregations

TransactionToken (com.palantir.atlasdb.api.TransactionToken)16 Test (org.junit.Test)11 TableCellVal (com.palantir.atlasdb.api.TableCellVal)9 RangeToken (com.palantir.atlasdb.api.RangeToken)7 TableRange (com.palantir.atlasdb.api.TableRange)7 TableCell (com.palantir.atlasdb.api.TableCell)6 Cell (com.palantir.atlasdb.keyvalue.api.Cell)5 TableRowResult (com.palantir.atlasdb.api.TableRowResult)4 TableRowSelection (com.palantir.atlasdb.api.TableRowSelection)4 RawTransaction (com.palantir.atlasdb.transaction.impl.RawTransaction)3 Preconditions (com.google.common.base.Preconditions)2 Cache (com.google.common.cache.Cache)2 CacheBuilder (com.google.common.cache.CacheBuilder)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 AtlasDbService (com.palantir.atlasdb.api.AtlasDbService)2 KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)2 RangeRequest (com.palantir.atlasdb.keyvalue.api.RangeRequest)2 RowResult (com.palantir.atlasdb.keyvalue.api.RowResult)2 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)2