gianm commented on code in PR #13516:
URL: https://github.com/apache/druid/pull/13516#discussion_r1110679287


##########
processing/src/main/java/org/apache/druid/segment/join/table/IndexedTableJoinMatcher.java:
##########
@@ -204,18 +199,50 @@ public void matchCondition()
       }
     } else {
       if (conditionMatchers.size() == 1) {
-        currentIterator = conditionMatchers.get(0).match();
+        currentIterator = conditionMatchers.get(0).match().iterator();
       } else {
+        final IntSortedSet[] matchingSets = new 
IntSortedSet[conditionMatchers.size()];
+        int smallestMatchingSet = -1;
+
         for (int i = 0; i < conditionMatchers.size(); i++) {
-          final IntIterator rows = conditionMatchers.get(i).match();
-          if (rows.hasNext()) {
-            currentMatchedRows[i] = rows;
-          } else {
-            return;
+          matchingSets[i] = conditionMatchers.get(i).match();
+          if (i == 0 || matchingSets[i].size() < 
matchingSets[smallestMatchingSet].size()) {
+            smallestMatchingSet = i;
+          }
+        }
+
+        // Start intersection using the smallest matching set.
+        IntSortedSet intersection = matchingSets[smallestMatchingSet];
+
+        // Remember if we copied matchingSets[smallestMatchingSet] or not. 
Avoids unnecessary copies.
+        boolean copied = false;

Review Comment:
   I'm not sure. If it makes sense feel free to do a PR for it 😄 thanks for the 
review!



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