public static UnfilteredPartitionIterator concat(final List<UnfilteredPartitionIterator> iterators) { if (iterators.size() == 1) return iterators.get(0); class Extend implements MorePartitions<UnfilteredPartitionIterator> { int i = 1; public UnfilteredPartitionIterator moreContents() { if (i >= iterators.size()) return null; return iterators.get(i++); } } return MorePartitions.extend(iterators.get(0), new Extend()); }
@SuppressWarnings("resource") // The created resources are returned right away public static PartitionIterator concat(final List<PartitionIterator> iterators) { if (iterators.size() == 1) return iterators.get(0); class Extend implements MorePartitions<PartitionIterator> { int i = 1; public PartitionIterator moreContents() { if (i >= iterators.size()) return null; return iterators.get(i++); } } return MorePartitions.extend(iterators.get(0), new Extend()); }
public static UnfilteredPartitionIterator concat(final List<UnfilteredPartitionIterator> iterators) { if (iterators.size() == 1) return iterators.get(0); class Extend implements MorePartitions<UnfilteredPartitionIterator> { int i = 1; public UnfilteredPartitionIterator moreContents() { if (i >= iterators.size()) return null; return iterators.get(i++); } } return MorePartitions.extend(iterators.get(0), new Extend()); }
@SuppressWarnings("resource") // The created resources are returned right away public static PartitionIterator concat(final List<PartitionIterator> iterators) { if (iterators.size() == 1) return iterators.get(0); class Extend implements MorePartitions<PartitionIterator> { int i = 1; public PartitionIterator moreContents() { if (i >= iterators.size()) return null; return iterators.get(i++); } } return MorePartitions.extend(iterators.get(0), new Extend()); }
public static UnfilteredPartitionIterator concat(final List<UnfilteredPartitionIterator> iterators) { if (iterators.size() == 1) return iterators.get(0); class Extend implements MorePartitions<UnfilteredPartitionIterator> { int i = 1; public UnfilteredPartitionIterator moreContents() { if (i >= iterators.size()) return null; return iterators.get(i++); } } return MorePartitions.extend(iterators.get(0), new Extend()); }
public static UnfilteredPartitionIterator concat(final List<UnfilteredPartitionIterator> iterators) { if (iterators.size() == 1) return iterators.get(0); class Extend implements MorePartitions<UnfilteredPartitionIterator> { int i = 1; public UnfilteredPartitionIterator moreContents() { if (i >= iterators.size()) return null; return iterators.get(i++); } } return MorePartitions.extend(iterators.get(0), new Extend()); }
@SuppressWarnings("resource") // The created resources are returned right away public static PartitionIterator concat(final List<PartitionIterator> iterators) { if (iterators.size() == 1) return iterators.get(0); class Extend implements MorePartitions<PartitionIterator> { int i = 1; public PartitionIterator moreContents() { if (i >= iterators.size()) return null; return iterators.get(i++); } } return MorePartitions.extend(iterators.get(0), new Extend()); }
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; }