rdblue commented on a change in pull request #1664:
URL: https://github.com/apache/iceberg/pull/1664#discussion_r513581060



##########
File path: 
parquet/src/main/java/org/apache/iceberg/parquet/ParquetDictionaryRowGroupFilter.java
##########
@@ -278,8 +278,27 @@ public Boolean or(Boolean leftResult, Boolean rightResult) 
{
 
       Set<T> dictionary = dict(id, ref.comparator());
 
-      // ROWS_CANNOT_MATCH if all values of the dictionary are not in the set 
(the intersection is empty)
-      return Sets.intersection(dictionary, literalSet).isEmpty() ? 
ROWS_CANNOT_MATCH : ROWS_MIGHT_MATCH;
+      // we need to find out the smaller set to iterate through
+      Set<T> smallerSet;
+      Set<T> biggerSet;
+
+      if (literalSet.size() < dictionary.size()) {
+        smallerSet = literalSet;
+        biggerSet = dictionary;
+      } else {
+        smallerSet = dictionary;
+        biggerSet = literalSet;
+      }
+
+      for (T e : smallerSet) {

Review comment:
       Is this equivalent to reversing the order of sets passed to 
`intersection`?
   
   ```java
   if (dictionary.size() > literalSet.size()) {
     return Sets.intersection(dictionary, literalSet).isEmpty() ? 
ROWS_CANNOT_MATCH : ROWS_MIGHT_MATCH;
   } else {
     return Sets.intersection(literalSet, dictionary).isEmpty() ? 
ROWS_CANNOT_MATCH : ROWS_MIGHT_MATCH;
   }
   ```
   
   I guess that this can return earlier if at least one value in the 
intersection is found.




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

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