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

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

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


##########
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 wonder if we can make an anti-set here which contains all the rows in `smallestMatchingSet` which aren't present in other `matchingSets`. In the end, we can remove the whole anti-set from `smallestMatchingSet`



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