ccaominh commented on a change in pull request #8373: Speed up 
ExpressionSelectors.makeExprEvalSelector
URL: https://github.com/apache/incubator-druid/pull/8373#discussion_r317713168
 
 

 ##########
 File path: core/src/main/java/org/apache/druid/math/expr/ExprMacroTable.java
 ##########
 @@ -97,9 +99,13 @@ public Expr get(final String functionName, final List<Expr> 
args)
   {
     protected final Expr arg;
 
+    // Use Supplier to memoize values as 
ExpressionSelectors#makeExprEvalSelector() can make repeated calls for them
+    private final Supplier<BindingDetails> analyzeInputsSupplier;
+
     public BaseScalarUnivariateMacroFunctionExpr(Expr arg)
     {
       this.arg = arg;
+      analyzeInputsSupplier = Suppliers.memoize(this::supplyAnalyzeInputs);
 
 Review comment:
   Both the caching and converting to streams contributed to the perf. I 
observed most the time being spent iterating over the sets in BindingDetails. 
The caching eliminated one of the iteration loops and getting rid of the stream 
sped up the remaining loops.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to