private UnfilteredPartitionIterator extendWithShortReadProtection(UnfilteredPartitionIterator partitions, InetAddress source, DataLimits.Counter mergedResultCounter) { DataLimits.Counter singleResultCounter = command.limits().newCounter(command.nowInSec(), false, command.selectsFullPartition(), enforceStrictLiveness).onlyCount(); ShortReadPartitionsProtection protection = new ShortReadPartitionsProtection(source, singleResultCounter, mergedResultCounter, queryStartNanoTime); /* * The order of extention and transformations is important here. Extending with more partitions has to happen * first due to the way BaseIterator.hasMoreContents() works: only transformations applied after extension will * be called on the first partition of the extended iterator. * * Additionally, we want singleResultCounter to be applied after SRPP, so that its applyToPartition() method will * be called last, after the extension done by SRRP.applyToPartition() call. That way we preserve the same order * when it comes to calling SRRP.moreContents() and applyToRow() callbacks. * * See ShortReadPartitionsProtection.applyToPartition() for more details. */ // extend with moreContents() only if it's a range read command with no partition key specified if (!command.isLimitedToOnePartition()) partitions = MorePartitions.extend(partitions, protection); // register SRPP.moreContents() partitions = Transformation.apply(partitions, protection); // register SRPP.applyToPartition() partitions = Transformation.apply(partitions, singleResultCounter); // register the per-source counter return partitions; }
private UnfilteredPartitionIterator extendWithShortReadProtection(UnfilteredPartitionIterator partitions, InetAddress source, DataLimits.Counter mergedResultCounter) { DataLimits.Counter singleResultCounter = command.limits().newCounter(command.nowInSec(), false, command.selectsFullPartition(), enforceStrictLiveness).onlyCount(); ShortReadPartitionsProtection protection = new ShortReadPartitionsProtection(source, singleResultCounter, mergedResultCounter, queryStartNanoTime); /* * The order of extention and transformations is important here. Extending with more partitions has to happen * first due to the way BaseIterator.hasMoreContents() works: only transformations applied after extension will * be called on the first partition of the extended iterator. * * Additionally, we want singleResultCounter to be applied after SRPP, so that its applyToPartition() method will * be called last, after the extension done by SRRP.applyToPartition() call. That way we preserve the same order * when it comes to calling SRRP.moreContents() and applyToRow() callbacks. * * See ShortReadPartitionsProtection.applyToPartition() for more details. */ // extend with moreContents() only if it's a range read command with no partition key specified if (!command.isLimitedToOnePartition()) partitions = MorePartitions.extend(partitions, protection); // register SRPP.moreContents() partitions = Transformation.apply(partitions, protection); // register SRPP.applyToPartition() partitions = Transformation.apply(partitions, singleResultCounter); // register the per-source counter return partitions; }
private UnfilteredPartitionIterator extendWithShortReadProtection(UnfilteredPartitionIterator partitions, InetAddress source, DataLimits.Counter mergedResultCounter) { DataLimits.Counter singleResultCounter = command.limits().newCounter(command.nowInSec(), false, command.selectsFullPartition(), enforceStrictLiveness).onlyCount(); ShortReadPartitionsProtection protection = new ShortReadPartitionsProtection(source, singleResultCounter, mergedResultCounter, queryStartNanoTime); /* * The order of extention and transformations is important here. Extending with more partitions has to happen * first due to the way BaseIterator.hasMoreContents() works: only transformations applied after extension will * be called on the first partition of the extended iterator. * * Additionally, we want singleResultCounter to be applied after SRPP, so that its applyToPartition() method will * be called last, after the extension done by SRRP.applyToPartition() call. That way we preserve the same order * when it comes to calling SRRP.moreContents() and applyToRow() callbacks. * * See ShortReadPartitionsProtection.applyToPartition() for more details. */ // extend with moreContents() only if it's a range read command with no partition key specified if (!command.isLimitedToOnePartition()) partitions = MorePartitions.extend(partitions, protection); // register SRPP.moreContents() partitions = Transformation.apply(partitions, protection); // register SRPP.applyToPartition() partitions = Transformation.apply(partitions, singleResultCounter); // register the per-source counter return partitions; }