You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/11/03 13:46:00 UTC

[GitHub] [calcite] eolivelli commented on a change in pull request #2238: [CALCITE-4364] `a in (1, 2) and a = 1` should be simplified to `a=1`

eolivelli commented on a change in pull request #2238:
URL: https://github.com/apache/calcite/pull/2238#discussion_r516232865



##########
File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
##########
@@ -2710,6 +2710,16 @@ private boolean accept1(RexNode e, SqlKind kind,
       }
     }
 
+    /** Checks whether it is worth to fix and convert to {@code SEARCH} calls. */
+    boolean needToFix(int newTermsCnt) {
+      // Fix and converts to SEARCH if:
+      // 1. A Sarg has complexity greater than 1;
+      // 2. The terms are reduced as simpler Sarg points.
+      return map.values().stream().anyMatch(b -> b.complexity() > 1)

Review comment:
       Streams are cool but they are very expensive.
   Probably we are in some hot path here.
   Is it worth to use a simple loop?




----------------------------------------------------------------
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:
users@infra.apache.org