Example usage for org.apache.cassandra.db PartitionRangeReadCommand limits

List of usage examples for org.apache.cassandra.db PartitionRangeReadCommand limits

Introduction

In this page you can find the example usage for org.apache.cassandra.db PartitionRangeReadCommand limits.

Prototype

public DataLimits limits();

Source Link

Document

The limits for the query.

Usage

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

License:Apache License

private PartitionIterator update(PartitionRangeReadCommand command, PartitionIterator data,
        ConsistencyLevel cl) {//from  w w  w .j a  v  a2s  .  c om

    // Collect query bounds
    RangeMerger rangeMerger = LuceneStorageProxy.rangeMerger(command, cl);
    List<AbstractBounds<PartitionPosition>> bounds = new LinkedList<>();
    while (rangeMerger.hasNext()) {
        bounds.add(rangeMerger.next().range);
    }

    List<SimpleRowIterator> rowIterators = new LinkedList<>();
    int count = 0;
    while (data.hasNext()) {
        RowIterator partition = data.next();
        DecoratedKey key = partition.partitionKey();
        AbstractBounds<PartitionPosition> bound = bounds.stream().filter(b -> b.contains(key)).findAny()
                .orElseGet(null);
        while (partition.hasNext()) {
            clear(bound);
            SimpleRowIterator newRowIterator = new SimpleRowIterator(partition);
            rowIterators.add(newRowIterator);
            Clustering clustering = newRowIterator.getRow().clustering();
            entries.put(key, clustering);
            if (remaining > 0) {
                remaining--;
            }
            count++;
        }
        partition.close();
    }
    data.close();

    hasMorePages = remaining > 0 && count >= command.limits().count();

    return new SimplePartitionIterator(rowIterators);
}