Search in sources :

Example 1 with Filter

use of org.apache.cassandra.db.transform.Filter in project cassandra by apache.

the class DataResolver method resolveInternal.

@SuppressWarnings("resource")
private PartitionIterator resolveInternal(ResolveContext context, UnfilteredPartitionIterators.MergeListener mergeListener, ResponseProvider responseProvider, UnaryOperator<PartitionIterator> preCountFilter) {
    int count = context.replicas.size();
    List<UnfilteredPartitionIterator> results = new ArrayList<>(count);
    for (int i = 0; i < count; i++) results.add(responseProvider.getResponse(i));
    /*
         * Even though every response, individually, will honor the limit, it is possible that we will, after the merge,
         * have more rows than the client requested. To make sure that we still conform to the original limit,
         * we apply a top-level post-reconciliation counter to the merged partition iterator.
         *
         * Short read protection logic (ShortReadRowsProtection.moreContents()) relies on this counter to be applied
         * to the current partition to work. For this reason we have to apply the counter transformation before
         * empty partition discard logic kicks in - for it will eagerly consume the iterator.
         *
         * That's why the order here is: 1) merge; 2) filter rows; 3) count; 4) discard empty partitions
         *
         * See CASSANDRA-13747 for more details.
         */
    UnfilteredPartitionIterator merged = UnfilteredPartitionIterators.merge(results, mergeListener);
    Filter filter = new Filter(command.nowInSec(), command.metadata().enforceStrictLiveness());
    FilteredPartitions filtered = FilteredPartitions.filter(merged, filter);
    PartitionIterator counted = Transformation.apply(preCountFilter.apply(filtered), context.mergedResultCounter);
    return Transformation.apply(counted, new EmptyPartitionsDiscarder());
}
Also used : Filter(org.apache.cassandra.db.transform.Filter) FilteredPartitions(org.apache.cassandra.db.transform.FilteredPartitions) UnfilteredPartitionIterator(org.apache.cassandra.db.partitions.UnfilteredPartitionIterator) PartitionIterator(org.apache.cassandra.db.partitions.PartitionIterator) EmptyPartitionsDiscarder(org.apache.cassandra.db.transform.EmptyPartitionsDiscarder) ArrayList(java.util.ArrayList) UnfilteredPartitionIterator(org.apache.cassandra.db.partitions.UnfilteredPartitionIterator)

Aggregations

ArrayList (java.util.ArrayList)1 PartitionIterator (org.apache.cassandra.db.partitions.PartitionIterator)1 UnfilteredPartitionIterator (org.apache.cassandra.db.partitions.UnfilteredPartitionIterator)1 EmptyPartitionsDiscarder (org.apache.cassandra.db.transform.EmptyPartitionsDiscarder)1 Filter (org.apache.cassandra.db.transform.Filter)1 FilteredPartitions (org.apache.cassandra.db.transform.FilteredPartitions)1