[
https://issues.apache.org/jira/browse/DRILL-3912?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14947665#comment-14947665
]
ASF GitHub Bot commented on DRILL-3912:
---------------------------------------
GitHub user StevenMPhillips opened a pull request:
https://github.com/apache/drill/pull/189
DRILL-3912: Common subexpression elimination
In EvaluationVisitor, map each logical expression subtree to the
HoldingContainer produced when the subtree is evaluated, and store it in a
HashMap.
Tow new classes, HashVisitor and EqualityVisitor are used to determine the
hashcode and equality for the map. Two logical expression trees are equal if
all child nodes are equal, and the root nodes are the same type and have the
same fields.
Only expressions that are in scope are available in the map. When entering
a new scope, the current map is copied into a new map. The current map is
pushed onto a stack, and the new map becomes the current map. When that scope
is left, the previous map is popped off the stack and becomes the current
scope. Thus previously evaluated expression in the outer scope are available
while in the inner scope, but any new expressions will not be available when in
the outer scope.
A new scope is entered when evaluating a boolean expression, or when
evaluating either branch of an If Expression.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/StevenMPhillips/drill drill-3912
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/drill/pull/189.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #189
----
commit f13b4eab7ea1cb61efcda0e137006bc983c9a339
Author: Steven Phillips <[email protected]>
Date: 2015-10-07T10:44:10Z
DRILL-3912: Common subexpression elimination
----
> Common subexpression elimination
> --------------------------------
>
> Key: DRILL-3912
> URL: https://issues.apache.org/jira/browse/DRILL-3912
> Project: Apache Drill
> Issue Type: Bug
> Reporter: Steven Phillips
> Assignee: Steven Phillips
>
> Drill currently will evaluate the full expression tree, even if there are
> redundant subtrees. Many of these redundant evaluations can be eliminated by
> reusing the results from previously evaluated expression trees.
> For example,
> {code}
> select a + 1, (a + 1)* (a - 1) from t
> {code}
> Will compute the entire (a + 1) expression twice. With CSE, it will only be
> evaluated once.
> The benefit will be reducing the work done when evaluating expressions, as
> well as reducing the amount of code that is generated, which could also lead
> to better JIT optimization.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)