use of org.apache.cassandra.thrift.KeySlice in project atlasdb by palantir.
the class GetCellTimestamps method getRows.
private List<byte[]> getRows(byte[] rangeStart) {
KeyRange keyRange = new KeyRange().setStart_key(rangeStart).setEnd_key(new byte[0]).setCount(batchHint);
SlicePredicate slicePredicate = SlicePredicates.create(SlicePredicates.Range.ALL, SlicePredicates.Limit.ZERO);
List<KeySlice> rows = rowGetter.getRows("getCandidateCellsForSweeping", keyRange, slicePredicate);
return rows.stream().map(KeySlice::getKey).collect(Collectors.toList());
}
use of org.apache.cassandra.thrift.KeySlice in project atlasdb by palantir.
the class ThriftObjectSizeUtilsTest method getKeySlicesSize.
@Test
public void getKeySlicesSize() {
List<KeySlice> slices = ImmutableList.of(new KeySlice().setKey(TEST_NAME_BYTES).setColumns(ImmutableList.of(EMPTY_COLUMN_OR_SUPERCOLUMN)));
long expectedSize = TEST_NAME_BYTES_SIZE + EMPTY_COLUMN_OR_SUPERCOLUMN_SIZE;
assertThat(ThriftObjectSizeUtils.getApproximateSizeOfKeySlices(slices)).isEqualTo(expectedSize);
}
use of org.apache.cassandra.thrift.KeySlice in project titan by thinkaurelius.
the class CassandraThriftKeyColumnValueStore method getRangeSlices.
private List<KeySlice> getRangeSlices(KeyRange keyRange, @Nullable SliceQuery sliceQuery) throws StorageException {
SliceRange sliceRange = new SliceRange();
if (sliceQuery == null) {
sliceRange.setStart(ArrayUtils.EMPTY_BYTE_ARRAY).setFinish(ArrayUtils.EMPTY_BYTE_ARRAY).setCount(5);
} else {
sliceRange.setStart(sliceQuery.getSliceStart().asByteBuffer()).setFinish(sliceQuery.getSliceEnd().asByteBuffer()).setCount((sliceQuery.hasLimit()) ? sliceQuery.getLimit() : Integer.MAX_VALUE);
}
CTConnection connection = null;
try {
connection = pool.borrowObject(keyspace);
List<KeySlice> slices = connection.getClient().get_range_slices(new ColumnParent(columnFamily), new SlicePredicate().setSlice_range(sliceRange), keyRange, ConsistencyLevel.QUORUM);
for (KeySlice s : slices) {
logger.debug("Key {}", ByteBufferUtil.toString(s.key, "-"));
}
/* Note: we need to fetch columns for each row as well to remove "range ghosts" */
List<KeySlice> result = new ArrayList<KeySlice>(slices.size());
KeyIterationPredicate pred = new KeyIterationPredicate();
for (KeySlice ks : slices) if (pred.apply(ks))
result.add(ks);
return result;
} catch (Exception e) {
throw convertException(e);
} finally {
if (connection != null)
pool.returnObjectUnsafe(keyspace, connection);
}
}
Aggregations