You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "jasonstack (via GitHub)" <gi...@apache.org> on 2023/06/15 00:27:13 UTC

[GitHub] [cassandra] jasonstack commented on a diff in pull request #2416: fix Segment#intersects to compare bound instead of token

jasonstack commented on code in PR #2416:
URL: https://github.com/apache/cassandra/pull/2416#discussion_r1230294758


##########
src/java/org/apache/cassandra/index/sai/disk/v1/segment/Segment.java:
##########
@@ -87,14 +87,15 @@ public boolean intersects(AbstractBounds<PartitionPosition> keyRange)
         if (keyRange instanceof Range && ((Range<?>)keyRange).isWrapAround())
             return keyRange.contains(minKeyBound) || keyRange.contains(maxKeyBound);
 
-        int cmp = keyRange.right.getToken().compareTo(minKey);
+        int cmp = keyRange.right.compareTo(minKeyBound);
         // if right is minimum, it means right is the max token and bigger than maxKey.
         // if right bound is less than minKey, no intersection
         if (!keyRange.right.isMinimum() && (!keyRange.inclusiveRight() && cmp == 0 || cmp < 0))
             return false;
 
+        cmp = keyRange.left.compareTo(maxKeyBound);
         // if left bound is bigger than maxKey, no intersection
-        return keyRange.isStartInclusive() || keyRange.left.getToken().compareTo(maxKey) < 0;
+        return (keyRange.isStartInclusive() || cmp != 0) && cmp <= 0;

Review Comment:
   removed `minKey` and `maxKey`



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org