You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "gianm (via GitHub)" <gi...@apache.org> on 2023/02/18 06:01:14 UTC

[GitHub] [druid] gianm commented on a diff in pull request #13516: Speed up composite key joins on IndexedTable.

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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org