aweisberg commented on code in PR #7:
URL: https://github.com/apache/cassandra-accord/pull/7#discussion_r1014264678


##########
accord-core/src/main/java/accord/primitives/KeyRanges.java:
##########
@@ -116,44 +119,64 @@ public KeyRanges select(int[] indexes)
         return ofSortedAndDeoverlapped(selection);
     }
 
-    public boolean intersects(Keys keys)
+    public boolean intersects(AbstractKeys<?, ?> keys)
     {
         return findNextIntersection(0, keys, 0) >= 0;
     }
 
+    public <K extends RoutingKey> boolean intersects(AbstractKeys<K, ?> keys, 
Predicate<? super K> matches)
+    {
+        int ri = 0, ki = 0;
+        while (true)
+        {
+            long rki = findNextIntersection(ri, keys, ki);
+            if (rki < 0)
+                return false;
+
+            ri = (int) (rki >>> 32);
+            ki = (int) (rki);
+
+            if (matches.test(keys.get(ki)))
+                return true;
+
+            ki++;
+        }
+    }
+
     public boolean intersects(KeyRanges that)
     {
         return SortedArrays.findNextIntersection(this.ranges, 0, that.ranges, 
0, KeyRange::compareIntersecting) >= 0;
     }
 
-    public int findFirstKey(Keys keys)
+    public int findFirstKey(AbstractKeys<?, ?> keys)
     {
         return findNextKey(0, keys, 0);
     }
 
-    public int findNextKey(int ri, Keys keys, int ki)
+    public int findNextKey(int ri, AbstractKeys<?, ?> keys, int ki)
     {
-        return (int) (findNextIntersection(ri, keys, ki) >> 32);
+        return (int) findNextIntersection(ri, keys, ki);
     }
 
-    // returns ki in top 32 bits, ri in bottom, or -1 if no match found
-    public long findNextIntersection(int ri, Keys keys, int ki)
+    // returns ri in top 32 bits, ki in bottom, or -1 if no match found
+    // TODO (now): inconsistent bits order vs SortedArrays
+    public long findNextIntersection(int ri, AbstractKeys<?, ?> keys, int ki)
     {
-        return SortedArrays.findNextIntersectionWithMultipleMatches(keys.keys, 
ki, ranges, ri);
+        return 
swapHighLow32b(SortedArrays.findNextIntersectionWithMultipleMatches(keys.keys, 
ki, ranges, ri));

Review Comment:
   Thanks. What it stood for wasn't completely obvious to me from the context 
because I just don't make the connection to the intended name.
   
   The names are fine.



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