ifesdjeen commented on code in PR #3054:
URL: https://github.com/apache/cassandra/pull/3054#discussion_r1467690905


##########
src/java/org/apache/cassandra/index/sai/disk/SSTableKeyTracker.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.index.sai.disk;
+
+import org.apache.cassandra.index.sai.utils.PrimaryKey;
+
+public abstract class SSTableKeyTracker
+{
+    public PrimaryKey minKey;

Review Comment:
   Looks like min/max keys are currently only used exclusively (i.e. if there 
are statics, static will be used, otherwise regular), usages in 
MemtableIndexFlusher and SegmentBuilder also show mutual exclusivity. Should 
this logic just be encapsulated in this class, or are there usages that I am 
missing?



##########
src/java/org/apache/cassandra/index/sai/iterators/KeyRangeIntersectionIterator.java:
##########
@@ -77,8 +81,23 @@ protected PrimaryKey computeNext()
                 if (index != alreadyAvanced)
                 {
                     KeyRangeIterator range = ranges.get(index);
-                    PrimaryKey nextKey = nextOrNull(range, highestKey);
-                    if (nextKey == null || nextKey.compareTo(highestKey) > 0)
+                    PrimaryKey nextKey = range.getCurrent();
+
+                    // Note that we will either have a data model that 
produces SKINNY primary keys or a data model
+                    // that produces some combination of WIDE and STATIC 
prikary keys.
+                    if (nextKey.kind() == Kind.WIDE || nextKey.kind() == 
highestKey.kind())
+                        // We can always skip if the target is of the same 
kind or this range is non-static. 
+                        nextKey = nextOrNull(range, highestKey);
+                    else if (nextKey.kind() == Kind.STATIC && 
nextKey.compareTo(highestKey) < 0)

Review Comment:
   here, `nextKey.compareTo(highestKey)` , is the reasoning behind this that 
nextKey is guaranteed to be static, but highestKey can only be non-static? I 
can imagine situations where we have two partitions without rows, and only with 
clusterings. Won’t we trigger `==` in this case?



##########
src/java/org/apache/cassandra/index/sai/iterators/KeyRangeIntersectionIterator.java:
##########
@@ -77,8 +81,23 @@ protected PrimaryKey computeNext()
                 if (index != alreadyAvanced)
                 {
                     KeyRangeIterator range = ranges.get(index);
-                    PrimaryKey nextKey = nextOrNull(range, highestKey);
-                    if (nextKey == null || nextKey.compareTo(highestKey) > 0)
+                    PrimaryKey nextKey = range.getCurrent();
+
+                    // Note that we will either have a data model that 
produces SKINNY primary keys or a data model
+                    // that produces some combination of WIDE and STATIC 
prikary keys.
+                    if (nextKey.kind() == Kind.WIDE || nextKey.kind() == 
highestKey.kind())
+                        // We can always skip if the target is of the same 
kind or this range is non-static. 
+                        nextKey = nextOrNull(range, highestKey);
+                    else if (nextKey.kind() == Kind.STATIC && 
nextKey.compareTo(highestKey) < 0)
+                        // For a range of static keys, only skip if we'e 
advanced to a new partition, and when we

Review Comment:
   nit: "skip if we've" (`v` is missing)



-- 
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