use of com.palantir.atlasdb.keyvalue.cassandra.CassandraKeyValueServices.StartTsResultsCollector in project atlasdb by palantir.
the class CassandraKeyValueServiceImpl method get.
private Map<Cell, Value> get(String kvsMethodName, TableReference tableRef, Set<Cell> cells, long maxTimestampExclusive) {
StartTsResultsCollector collector = new StartTsResultsCollector(maxTimestampExclusive);
cellLoader.loadWithTs(kvsMethodName, tableRef, cells, maxTimestampExclusive, false, collector, readConsistency);
return collector.getCollectedResults();
}
use of com.palantir.atlasdb.keyvalue.cassandra.CassandraKeyValueServices.StartTsResultsCollector in project atlasdb by palantir.
the class CassandraKeyValueServiceImpl method getRowsForSpecificColumns.
private Map<Cell, Value> getRowsForSpecificColumns(final TableReference tableRef, final Iterable<byte[]> rows, ColumnSelection selection, final long startTs) {
Preconditions.checkArgument(!selection.allColumnsSelected(), "Must select specific columns");
Collection<byte[]> selectedColumns = selection.getSelectedColumns();
Set<Cell> cells = Sets.newHashSetWithExpectedSize(selectedColumns.size() * Iterables.size(rows));
for (byte[] row : rows) {
for (byte[] col : selectedColumns) {
cells.add(Cell.create(row, col));
}
}
StartTsResultsCollector collector = new StartTsResultsCollector(startTs);
cellLoader.loadWithTs("getRows", tableRef, cells, startTs, false, collector, readConsistency);
return collector.getCollectedResults();
}
use of com.palantir.atlasdb.keyvalue.cassandra.CassandraKeyValueServices.StartTsResultsCollector in project atlasdb by palantir.
the class CassandraKeyValueServiceImpl method get.
/**
* Gets values from the key-value store.
* <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 retrieve values from.
* @param timestampByCell specifies, for each row, the maximum timestamp (exclusive) at which to
* retrieve that rows's value.
*
* @return map of retrieved values. Values which do not exist (either
* because they were deleted or never created in the first place)
* are simply not returned.
*
* @throws IllegalArgumentException if any of the requests were invalid
* (e.g., attempting to retrieve values from a non-existent table).
*/
@Override
public Map<Cell, Value> get(TableReference tableRef, Map<Cell, Long> timestampByCell) {
if (timestampByCell.isEmpty()) {
log.info("Attempted get on '{}' table with empty cells", LoggingArgs.tableRef(tableRef));
return ImmutableMap.of();
}
try {
Long firstTs = timestampByCell.values().iterator().next();
if (Iterables.all(timestampByCell.values(), Predicates.equalTo(firstTs))) {
return get("get", tableRef, timestampByCell.keySet(), firstTs);
}
SetMultimap<Long, Cell> cellsByTs = Multimaps.invertFrom(Multimaps.forMap(timestampByCell), HashMultimap.<Long, Cell>create());
Builder<Cell, Value> builder = ImmutableMap.builder();
for (long ts : cellsByTs.keySet()) {
StartTsResultsCollector collector = new StartTsResultsCollector(ts);
cellLoader.loadWithTs("get", tableRef, cellsByTs.get(ts), ts, false, collector, readConsistency);
builder.putAll(collector.getCollectedResults());
}
return builder.build();
} catch (Exception e) {
throw QosAwareThrowables.unwrapAndThrowRateLimitExceededOrAtlasDbDependencyException(e);
}
}
Aggregations