use of com.palantir.atlasdb.keyvalue.api.Value in project atlasdb by palantir.
the class CassandraKeyValueServiceImpl method addGarbageCollectionSentinelValues.
/**
* Adds a value with timestamp = Value.INVALID_VALUE_TIMESTAMP to each of the given cells. If
* a value already exists at that time stamp, nothing is written for that cell.
* <p>
* Does not require all Cassandra nodes to be up and available, works as long as quorum is achieved.
*
* @param tableRef the name of the table to add the value to.
* @param cells a set of cells to store the values in.
*/
@Override
public void addGarbageCollectionSentinelValues(TableReference tableRef, Iterable<Cell> cells) {
try {
final Value value = Value.create(PtBytes.EMPTY_BYTE_ARRAY, Value.INVALID_VALUE_TIMESTAMP);
cellValuePutter.put("addGarbageCollectionSentinelValues", tableRef, Iterables.transform(cells, cell -> Maps.immutableEntry(cell, value)));
} catch (Exception e) {
throw QosAwareThrowables.unwrapAndThrowRateLimitExceededOrAtlasDbDependencyException(e);
}
}
use of com.palantir.atlasdb.keyvalue.api.Value in project atlasdb by palantir.
the class CqlKeyValueService method addGarbageCollectionSentinelValues.
@Override
public void addGarbageCollectionSentinelValues(TableReference tableRef, Iterable<Cell> cells) {
try {
final Value value = Value.create(new byte[0], Value.INVALID_VALUE_TIMESTAMP);
putInternal(tableRef, Iterables.transform(cells, cell -> Maps.immutableEntry(cell, value)), TransactionType.NONE);
} catch (Throwable t) {
throw Throwables.throwUncheckedException(t);
}
}
use of com.palantir.atlasdb.keyvalue.api.Value in project atlasdb by palantir.
the class CqlKeyValueService method getPutPartitionResultSetFuture.
protected ResultSetFuture getPutPartitionResultSetFuture(TableReference tableRef, List<Entry<Cell, Value>> partition, TransactionType transactionType, int ttl) {
PreparedStatement preparedStatement = getPreparedStatement(tableRef, getPutQueryForPossibleTransaction(tableRef, transactionType, ttl), session);
preparedStatement.setConsistencyLevel(writeConsistency);
// Be mindful when using the atomicity semantics of UNLOGGED batch statements.
// This usage should be okay, as the KVS.multiPut explicitly does not guarantee
// atomicity across cells (nor batch isolation, which we also cannot provide)
BatchStatement batchStatement = new BatchStatement(BatchStatement.Type.UNLOGGED);
if (shouldTraceQuery(tableRef)) {
batchStatement.enableTracing();
}
for (Entry<Cell, Value> e : partition) {
BoundStatement boundStatement = preparedStatement.bind();
boundStatement.setBytes(fieldNameProvider.row(), ByteBuffer.wrap(e.getKey().getRowName()));
boundStatement.setBytes(fieldNameProvider.column(), ByteBuffer.wrap(e.getKey().getColumnName()));
boundStatement.setLong(fieldNameProvider.timestamp(), ~e.getValue().getTimestamp());
boundStatement.setBytes(fieldNameProvider.value(), ByteBuffer.wrap(e.getValue().getContents()));
if (partition.size() > 1) {
batchStatement.add(boundStatement);
} else {
return session.executeAsync(boundStatement);
}
}
return session.executeAsync(batchStatement);
}
use of com.palantir.atlasdb.keyvalue.api.Value in project atlasdb by palantir.
the class CqlKeyValueService method getMetadataForTable.
@Override
public byte[] getMetadataForTable(TableReference tableRef) {
Cell cell = CqlKeyValueServices.getMetadataCell(tableRef);
Value value = get(AtlasDbConstants.DEFAULT_METADATA_TABLE, ImmutableMap.of(cell, Long.MAX_VALUE)).get(cell);
if (value == null) {
return new byte[0];
} else {
return value.getContents();
}
}
Aggregations