use of com.palantir.atlasdb.keyvalue.api.Value in project atlasdb by palantir.
the class TransactionKvsWrapper method get.
public Long get(Long startTimestamp) {
Cell cell = getTransactionCell(startTimestamp);
Map<Cell, Value> returnMap = keyValueService.get(TransactionConstants.TRANSACTION_TABLE, ImmutableMap.of(cell, MAX_TIMESTAMP));
if (returnMap.containsKey(cell)) {
return TransactionConstants.getTimestampForValue(returnMap.get(cell).getContents());
} else {
return null;
}
}
use of com.palantir.atlasdb.keyvalue.api.Value in project atlasdb by palantir.
the class ScrubberTest method testScrubQueueIsCleared.
@Test
public void testScrubQueueIsCleared() {
Cell cell1 = Cell.create(new byte[] { 1 }, new byte[] { 2 });
Cell cell2 = Cell.create(new byte[] { 2 }, new byte[] { 3 });
Cell cell3 = Cell.create(new byte[] { 3 }, new byte[] { 4 });
TableReference tableRef = TableReference.createFromFullyQualifiedName("foo.bar");
kvs.createTable(tableRef, new byte[] {});
kvs.putWithTimestamps(tableRef, ImmutableMultimap.<Cell, Value>builder().put(cell1, Value.create(new byte[] { 3 }, 10)).put(cell1, Value.create(new byte[] { 4 }, 20)).put(cell2, Value.create(new byte[] { 4 }, 30)).put(cell2, Value.create(new byte[] { 5 }, 40)).put(cell2, Value.create(new byte[] { 6 }, 50)).put(cell3, Value.create(new byte[] { 7 }, 60)).build());
transactions.putUnlessExists(10, 15);
transactions.putUnlessExists(20, 25);
transactions.putUnlessExists(30, 35);
transactions.putUnlessExists(50, 55);
transactions.putUnlessExists(60, 65);
scrubStore.queueCellsForScrubbing(ImmutableMultimap.of(cell1, tableRef), 10, 100);
scrubStore.queueCellsForScrubbing(ImmutableMultimap.of(cell1, tableRef), 20, 100);
scrubStore.queueCellsForScrubbing(ImmutableMultimap.of(cell2, tableRef), 40, 100);
scrubStore.queueCellsForScrubbing(ImmutableMultimap.of(cell2, tableRef), 50, 100);
scrubStore.queueCellsForScrubbing(ImmutableMultimap.of(cell3, tableRef), 60, 100);
scrubber.runBackgroundScrubTask(null);
List<SortedMap<Long, Multimap<TableReference, Cell>>> scrubQueue = BatchingVisitables.copyToList(scrubStore.getBatchingVisitableScrubQueue(Long.MAX_VALUE, null, null));
Assert.assertEquals(ImmutableList.of(), scrubQueue);
}
use of com.palantir.atlasdb.keyvalue.api.Value in project atlasdb by palantir.
the class LockEntryTest method fromRowResultProducesLockEntry.
@Test
public void fromRowResultProducesLockEntry() {
KeyValueService kvs = new InMemoryKeyValueService(false);
kvs.createTable(TEST_TABLE, AtlasDbConstants.GENERIC_TABLE_METADATA);
kvs.checkAndSet(CheckAndSetRequest.newCell(TEST_TABLE, LOCK_ENTRY.cell(), LOCK_ENTRY.value()));
Iterator<RowResult<Value>> range = kvs.getRange(TEST_TABLE, RangeRequest.all(), AtlasDbConstants.TRANSACTION_TS + 1);
RowResult<Value> onlyEntry = Iterables.getOnlyElement(ImmutableSet.copyOf(range));
LockEntry lockEntry = LockEntry.fromRowResult(onlyEntry);
assertEquals(LOCK_ENTRY, lockEntry);
}
use of com.palantir.atlasdb.keyvalue.api.Value in project atlasdb by palantir.
the class SimpleTransactionService method get.
@Override
public Map<Long, Long> get(Iterable<Long> startTimestamps) {
Map<Cell, Long> startTsMap = Maps.newHashMap();
for (Long startTimestamp : startTimestamps) {
Cell cell = getTransactionCell(startTimestamp);
startTsMap.put(cell, MAX_TIMESTAMP);
}
Map<Cell, Value> rawResults = keyValueService.get(TransactionConstants.TRANSACTION_TABLE, startTsMap);
Map<Long, Long> result = Maps.newHashMapWithExpectedSize(rawResults.size());
for (Map.Entry<Cell, Value> e : rawResults.entrySet()) {
long startTs = TransactionConstants.getTimestampForValue(e.getKey().getRowName());
long commitTs = TransactionConstants.getTimestampForValue(e.getValue().getContents());
result.put(startTs, commitTs);
}
return result;
}
use of com.palantir.atlasdb.keyvalue.api.Value in project atlasdb by palantir.
the class JdbcKeyValueService method breakUpValuesByRow.
private static NavigableMap<byte[], SortedMap<byte[], Value>> breakUpValuesByRow(Result<? extends Record> records) {
NavigableMap<byte[], SortedMap<byte[], Value>> ret = Maps.newTreeMap(UnsignedBytes.lexicographicalComparator());
for (Record record : records) {
byte[] row = record.getValue(A_ROW_NAME);
SortedMap<byte[], Value> colMap = ret.computeIfAbsent(row, rowName -> Maps.newTreeMap(UnsignedBytes.lexicographicalComparator()));
colMap.put(record.getValue(A_COL_NAME), Value.create(record.getValue(A_VALUE), record.getValue(A_TIMESTAMP)));
}
return ret;
}
Aggregations