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



##########
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:
       Calling `isEmpty` on `intersection` is equivalent to just calling 
`Collections$disjoint`. We may rely on the order of args but that seems fragile 
to me. There is no guarantee the internal implementation won't change.




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