Example usage for org.apache.cassandra.db.rows RowIterator close

List of usage examples for org.apache.cassandra.db.rows RowIterator close

Introduction

In this page you can find the example usage for org.apache.cassandra.db.rows RowIterator close.

Prototype

public void close();

Source Link

Usage

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

License:Apache License

private PartitionIterator update(Group group, PartitionIterator data) {
    List<SimpleRowIterator> rowIterators = new LinkedList<>();

    int count = 0;
    while (data.hasNext()) {
        RowIterator partition = data.next();
        DecoratedKey key = partition.partitionKey();
        while (partition.hasNext()) {
            SimpleRowIterator newRowIterator = new SimpleRowIterator(partition);
            rowIterators.add(newRowIterator);
            Clustering clustering = newRowIterator.getRow().clustering();
            entries.put(key, clustering);
            if (remaining > 0) {
                remaining--;//from w w w  .  ja v a2  s .com
            }
            count++;
        }
        partition.close();
    }
    data.close();

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

    return new SimplePartitionIterator(rowIterators);
}

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 va 2s  .  com*/

    // 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);
}