maedhroz commented on code in PR #3194:
URL: https://github.com/apache/cassandra/pull/3194#discussion_r1544707141


##########
src/java/org/apache/cassandra/index/sai/iterators/KeyRangeConcatIterator.java:
##########
@@ -18,100 +18,105 @@
 package org.apache.cassandra.index.sai.iterators;
 
 import java.util.ArrayList;
-import java.util.Comparator;
 import java.util.List;
-import java.util.PriorityQueue;
 
 import com.google.common.annotations.VisibleForTesting;
 
 import org.apache.cassandra.index.sai.utils.PrimaryKey;
 import org.apache.cassandra.io.util.FileUtils;
 
 /**
- * {@link KeyRangeConcatIterator} takes a list of sorted range iterator and 
concatenates them, leaving duplicates in
+ * {@link KeyRangeConcatIterator} takes a list of sorted range iterators and 
concatenates them, leaving duplicates in
  * place, to produce a new stably sorted iterator. Duplicates are eliminated 
later in
  * {@link org.apache.cassandra.index.sai.plan.StorageAttachedIndexSearcher}
  * as results from multiple SSTable indexes and their respective segments are 
consumed.
- *
+ * <p>
  * ex. (1, 2, 3) + (3, 3, 4, 5) -> (1, 2, 3, 3, 3, 4, 5)
  * ex. (1, 2, 2, 3) + (3, 4, 4, 6, 6, 7) -> (1, 2, 2, 3, 3, 4, 4, 6, 6, 7)
- *
- * TODO Investigate removing the use of PriorityQueue from this class <a 
href="https://issues.apache.org/jira/browse/CASSANDRA-18165";>CASSANDRA-18165</a>
  */
 public class KeyRangeConcatIterator extends KeyRangeIterator
 {
     public static final String MUST_BE_SORTED_ERROR = "RangeIterator must be 
sorted, previous max: %s, next min: %s";
-    private final PriorityQueue<KeyRangeIterator> ranges;
-    private final List<KeyRangeIterator> toRelease;
+    private final List<KeyRangeIterator> ranges;
 
-    protected KeyRangeConcatIterator(KeyRangeIterator.Builder.Statistics 
statistics, PriorityQueue<KeyRangeIterator> ranges)
+    private int current;
+
+    protected KeyRangeConcatIterator(KeyRangeIterator.Builder.Statistics 
statistics, List<KeyRangeIterator> ranges, Runnable onClose)
     {
-        super(statistics);
+        super(statistics, onClose);
+
+        if (ranges.isEmpty())
+            throw new IllegalArgumentException("Cannot concatenate empty list 
of ranges");
 
-        this.ranges = ranges;
-        this.toRelease = new ArrayList<>(ranges);
+        this.current = 0;
+        this.ranges = new ArrayList<>(ranges);

Review Comment:
   > So you suggest it to be this.ranges = ranges?
   
   Yeah, basically...the defensive copy just seems paranoid.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to