Example usage for org.apache.cassandra.db DataRange contains

List of usage examples for org.apache.cassandra.db DataRange contains

Introduction

In this page you can find the example usage for org.apache.cassandra.db DataRange contains.

Prototype

public boolean contains(PartitionPosition pos) 

Source Link

Document

Whether the provided ring position is covered by this DataRange .

Usage

From source file:com.stratio.cassandra.lucene.IndexPagingState.java

License:Apache License

private Pair<DecoratedKey, Clustering> forCommand(PartitionRangeReadCommand command) {
    DataRange dataRange = command.dataRange();
    for (Map.Entry<DecoratedKey, Clustering> entry : entries.entrySet()) {
        DecoratedKey key = entry.getKey();
        if (dataRange.contains(key)) {
            Clustering clustering = entry.getValue();
            return Pair.create(key, clustering);
        }//from   ww  w.  ja  va 2  s  . c om
    }
    return null;
}

From source file:com.tuplejump.stargate.cassandra.RowScanner.java

License:Apache License

@Override
protected Row computeNext() {
    DataRange range = filter.dataRange;
    SliceQueryFilter sliceQueryFilter = (SliceQueryFilter) filter.dataRange
            .columnFilter(ByteBufferUtil.EMPTY_BYTE_BUFFER);
    if (indexIterator == null)
        indexIterator = collector.docs().iterator();
    while (indexIterator.hasNext() && columnsCount <= limit) {
        try {/*from   w  w  w .j a v  a2 s.com*/
            IndexEntryCollector.IndexEntry entry = indexIterator.next();
            String pkNameString = entry.pkName;
            ByteBuffer rowKey = entry.rowKey;
            long ts = entry.timestamp;
            float score = entry.score;

            Pair<DecoratedKey, IDiskAtomFilter> keyAndFilter = getFilterAndKey(rowKey, sliceQueryFilter);
            if (keyAndFilter == null) {
                continue;
            }

            DecoratedKey dk = keyAndFilter.left;
            if (!range.contains(dk)) {
                if (SearchSupport.logger.isTraceEnabled()) {
                    SearchSupport.logger.trace("Skipping entry {} outside of assigned scan range", dk.token);
                }
                continue;
            }

            if (SearchSupport.logger.isTraceEnabled()) {
                SearchSupport.logger.trace("Returning index hit for {}", dk);
            }

            Row row = getRow(pkNameString, keyAndFilter.right, dk, ts, score);
            if (row == null) {
                if (SearchSupport.logger.isTraceEnabled())
                    SearchSupport.logger.trace("Returned Row is null");
                continue;
            }
            columnsCount++;
            return row;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    return endOfData();
}