jacek-lewandowski commented on code in PR #2065:
URL: https://github.com/apache/cassandra/pull/2065#discussion_r1065579876


##########
src/java/org/apache/cassandra/db/Slice.java:
##########
@@ -229,20 +237,24 @@ public Slice forPaging(ClusteringComparator comparator, 
Clustering<?> lastReturn
     }
 
     /**
-     * Given the per-clustering column minimum and maximum value a sstable 
contains, whether or not this slice potentially
-     * intersects that sstable or not.
+     * Whether this slice and the provided slice intersects.
      *
      * @param comparator the comparator for the table this is a slice of.
-     * @param minClusteringValues the smallest values for each clustering 
column that a sstable contains.
-     * @param maxClusteringValues the biggest values for each clustering 
column that a sstable contains.
-     *
-     * @return whether the slice might intersects with the sstable having 
{@code minClusteringValues} and
-     * {@code maxClusteringValues}.
+     * @param other      the other slice to check intersection with.
+     * @return whether this slice intersects {@code other}.
      */
-    public boolean intersects(ClusteringComparator comparator, 
List<ByteBuffer> minClusteringValues, List<ByteBuffer> maxClusteringValues)
+    public boolean intersects(ClusteringComparator comparator, Slice other)
     {
-        // If this slice starts after max clustering or ends before min 
clustering, it can't intersect
-        return start.compareTo(comparator, maxClusteringValues) <= 0 && 
end.compareTo(comparator, minClusteringValues) >= 0;
+        // Empty slices never intersect anything (and we have to special case 
it as there is many ways to build an
+        // empty slice; for instance, without this, (0, 0) would intersect 
Slice.ALL or [-1, 1]).
+        if (isEmpty(comparator) || other.isEmpty(comparator))

Review Comment:
   Actually... In this case we need to do 3 comparisons in  each case. In the 
current implementation we do 1 or 2 comparisons when one slice is empty and 4 
(indeed) when we have no empty slices. Alternatively, we could associate an 
emptiness flag with a slice upon creation.



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