use of org.apache.cassandra.thrift.SliceRange in project scale7-pelops by s7.
the class Selector method newColumnsPredicateAll.
/**
* Create a new <code>SlicePredicate</code> instance that selects "all" columns
* @param reversed Whether the results should be returned in reverse order
* @param maxColCount The maximum number of columns to return
* @return The new <code>SlicePredicate</code>
*/
public static SlicePredicate newColumnsPredicateAll(boolean reversed, int maxColCount) {
SlicePredicate predicate = new SlicePredicate();
predicate.setSlice_range(new SliceRange(Bytes.EMPTY.getBytes(), Bytes.EMPTY.getBytes(), reversed, maxColCount));
return predicate;
}
use of org.apache.cassandra.thrift.SliceRange in project titan by thinkaurelius.
the class CassandraBinaryInputFormat method getSliceRange.
private SliceRange getSliceRange(final SliceQuery slice, final int limit) {
final SliceRange sliceRange = new SliceRange();
sliceRange.setStart(slice.getSliceStart().asByteBuffer());
sliceRange.setFinish(slice.getSliceEnd().asByteBuffer());
sliceRange.setCount(Math.min(limit, slice.getLimit()));
return sliceRange;
}
use of org.apache.cassandra.thrift.SliceRange in project eiger by wlloyd.
the class QueryFilter method getFilter.
public static IFilter getFilter(SlicePredicate predicate, AbstractType comparator) {
if (predicate.column_names != null) {
final SortedSet<ByteBuffer> columnNameSet = new TreeSet<ByteBuffer>(comparator);
columnNameSet.addAll(predicate.column_names);
return new NamesQueryFilter(columnNameSet);
}
SliceRange range = predicate.slice_range;
return new SliceQueryFilter(range.start, range.finish, range.reversed, range.count);
}
use of org.apache.cassandra.thrift.SliceRange in project scale7-pelops by s7.
the class Selector method newColumnsPredicate.
/**
* Create a new <code>SlicePredicate</code> instance.
* @param startName The inclusive column start name of the range to select in the slice
* @param finishName The inclusive column end name of the range to select in the slice
* @param reversed Whether the results should be returned in reverse order
* @param maxColCount The maximum number of columns to return
* @return The new <code>SlicePredicate</code>
*/
public static SlicePredicate newColumnsPredicate(Bytes startName, Bytes finishName, boolean reversed, int maxColCount) {
SlicePredicate predicate = new SlicePredicate();
predicate.setSlice_range(new SliceRange(nullSafeGet(startName), nullSafeGet(finishName), reversed, maxColCount));
return predicate;
}
use of org.apache.cassandra.thrift.SliceRange in project titan by thinkaurelius.
the class CassandraEmbeddedKeyColumnValueStore method getKeySlice.
/**
* Create a RangeSliceCommand and run it against the StorageProxy.
* <p>
* To match the behavior of the standard Cassandra thrift API endpoint, the
* {@code nowMillis} argument should be the number of milliseconds since the
* UNIX Epoch (e.g. System.currentTimeMillis() or equivalent obtained
* through a {@link TimestampProvider}). This is per
* {@link org.apache.cassandra.thrift.CassandraServer#get_range_slices(ColumnParent, SlicePredicate, KeyRange, ConsistencyLevel)},
* which passes the server's System.currentTimeMillis() to the
* {@code RangeSliceCommand} constructor.
*/
private List<Row> getKeySlice(Token start, Token end, @Nullable SliceQuery sliceQuery, int pageSize, long nowMillis) throws BackendException {
IPartitioner partitioner = StorageService.getPartitioner();
SliceRange columnSlice = new SliceRange();
if (sliceQuery == null) {
columnSlice.setStart(ArrayUtils.EMPTY_BYTE_ARRAY).setFinish(ArrayUtils.EMPTY_BYTE_ARRAY).setCount(5);
} else {
columnSlice.setStart(sliceQuery.getSliceStart().asByteBuffer()).setFinish(sliceQuery.getSliceEnd().asByteBuffer()).setCount(sliceQuery.hasLimit() ? sliceQuery.getLimit() : Integer.MAX_VALUE);
}
/* Note: we need to fetch columns for each row as well to remove "range ghosts" */
SlicePredicate predicate = new SlicePredicate().setSlice_range(columnSlice);
RowPosition startPosition = start.minKeyBound(partitioner);
RowPosition endPosition = end.minKeyBound(partitioner);
List<Row> rows;
try {
CFMetaData cfm = Schema.instance.getCFMetaData(keyspace, columnFamily);
IDiskAtomFilter filter = ThriftValidation.asIFilter(predicate, cfm, null);
RangeSliceCommand cmd = new RangeSliceCommand(keyspace, columnFamily, nowMillis, filter, new Bounds<RowPosition>(startPosition, endPosition), pageSize);
rows = StorageProxy.getRangeSlice(cmd, ConsistencyLevel.QUORUM);
} catch (Exception e) {
throw new PermanentBackendException(e);
}
return rows;
}
Aggregations