Example usage for org.apache.cassandra.db Slices get

List of usage examples for org.apache.cassandra.db Slices get

Introduction

In this page you can find the example usage for org.apache.cassandra.db Slices get.

Prototype

public abstract Slice get(int i);

Source Link

Document

Returns the ith slice of this Slices object.

Usage

From source file:com.stratio.cassandra.lucene.key.KeyMapper.java

License:Apache License

/**
 * Returns the start {@link ClusteringPrefix} of the first partition of the specified {@link DataRange}.
 *
 * @param dataRange the data range/*from   www .j  a va2  s  .c  o  m*/
 * @return the start clustering prefix of {@code dataRange}, or {@code null} if there is no such start
 */
public static Optional<ClusteringPrefix> startClusteringPrefix(DataRange dataRange) {
    PartitionPosition startPosition = dataRange.startKey();
    if (startPosition instanceof DecoratedKey) {
        DecoratedKey startKey = (DecoratedKey) startPosition;
        ClusteringIndexFilter filter = dataRange.clusteringIndexFilter(startKey);
        if (filter instanceof ClusteringIndexSliceFilter) {
            ClusteringIndexSliceFilter sliceFilter = (ClusteringIndexSliceFilter) filter;
            Slices slices = sliceFilter.requestedSlices();
            return Optional.of(slices.get(0).start());
        }
    }
    return Optional.empty();
}

From source file:com.stratio.cassandra.lucene.key.KeyMapper.java

License:Apache License

/**
 * Returns the stop {@link ClusteringPrefix} of the last partition of the specified {@link DataRange}.
 *
 * @param dataRange the data range/*from w w w .  j a v a 2 s  .  co  m*/
 * @return the stop clustering prefix of {@code dataRange}, or {@code null} if there is no such start
 */
public static Optional<ClusteringPrefix> stopClusteringPrefix(DataRange dataRange) {
    PartitionPosition stopPosition = dataRange.stopKey();
    if (stopPosition instanceof DecoratedKey) {
        DecoratedKey stopKey = (DecoratedKey) stopPosition;
        ClusteringIndexFilter filter = dataRange.clusteringIndexFilter(stopKey);
        if (filter instanceof ClusteringIndexSliceFilter) {
            ClusteringIndexSliceFilter sliceFilter = (ClusteringIndexSliceFilter) filter;
            Slices slices = sliceFilter.requestedSlices();
            return Optional.of(slices.get(slices.size() - 1).end());
        }
    }
    return Optional.empty();
}

From source file:com.stratio.cassandra.lucene.key.KeyMapper.java

License:Apache License

/**
 * Returns a Lucene {@link Query} to retrieve all the rows in the specified clustering slice filter.
 *
 * @param key the partition key//from  ww  w .  ja v  a  2s . co  m
 * @param sliceFilter the slice filter
 * @return the Lucene query
 */
public Query query(DecoratedKey key, ClusteringIndexSliceFilter sliceFilter) {
    Slices slices = sliceFilter.requestedSlices();
    ClusteringPrefix startBound = slices.get(0).start();
    ClusteringPrefix stopBound = slices.get(slices.size() - 1).end();
    return query(key, startBound, stopBound, false, false);
}