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

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

Introduction

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

Prototype

public DecoratedKey partitionKey();

Source Link

Document

The partition key of the partition this in an iterator over.

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--;/*w ww  .ja va  2  s. c  o  m*/
            }
            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 ww  w. j  a v  a  2s  .co  m

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

From source file:com.stratio.cassandra.lucene.util.SimpleRowIterator.java

License:Apache License

/**
 * Builds a new {@link SimpleRowIterator} from the current position of the specified {@link RowIterator}. Any other
 * rows in the specified iterator won't be read.
 *
 * @param iterator the {@link Row} iterator
 *///from w  w w.jav a 2 s .c o m
public SimpleRowIterator(RowIterator iterator) {
    this.metadata = iterator.metadata();
    this.key = iterator.partitionKey();
    this.columns = iterator.columns();
    this.staticRow = iterator.staticRow();
    this.row = iterator.next();
    this.rows = Collections.singletonList(row).iterator();
}