You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Vladimir Sitnikov (JIRA)" <ji...@apache.org> on 2018/08/07 11:22:00 UTC
[jira] [Updated] (CALCITE-2452) RexSimplify: avoid multiple similar
optimization passes over the same nodes
[ https://issues.apache.org/jira/browse/CALCITE-2452?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vladimir Sitnikov updated CALCITE-2452:
---------------------------------------
Description:
simplifyAndTerms(List<RexNode> terms) has two loops and it calls simplify on each expression twice.
simplifyAnd(RexCall e) calls simplifyList (that walks all the tree down), then simplifyAnd2ForUnknownAsFalse calls simplify_ again.
It looks like just one pass should be sufficient for most of the cases, and the logic should probably be adjusted as follows:
{code:java}
simplify(RexNode node){
// e.g. simplify the node with assumption that all the arguments were simplified, etc, avoid complicated checks
node = simplifyTrivialCases(node);
// this walks over the tree, simplifies operands first then simplifies the call itself
node = simplifyArgumentsThenSimplifyNode(node);
return node;
}{code}
Method naming should clearly indicate that the method is heavy, so it would not accidentally be used.
was:
simplifyAndTerms(List<RexNode> terms) has two loops and it calls simplify on each expression twice.
simplifyAnd(RexCall e) calls simplifyList (that walks all the tree down), then simplifyAnd2ForUnknownAsFalse calls simplify_ again.
It looks like just one pass should be sufficient for most of the cases, and the logic should probably be adjusted as follows:
{code:java}
simplify(RexNode node){
// e.g. simplify the node with assumption that all the arguments were simplified, etc, avoid complicated checks
node = simplifyTrivialCases(node);
// this walks over the tree, simplifies operands first then simplifies the call itself
node = simplifyArgumentsThenSimplifyNode(node);
return node;
}
Method naming should clearly indicate that the method is heavy, so it would not accidentally be used.
> RexSimplify: avoid multiple similar optimization passes over the same nodes
> ---------------------------------------------------------------------------
>
> Key: CALCITE-2452
> URL: https://issues.apache.org/jira/browse/CALCITE-2452
> Project: Calcite
> Issue Type: Sub-task
> Reporter: Vladimir Sitnikov
> Assignee: Julian Hyde
> Priority: Major
>
> simplifyAndTerms(List<RexNode> terms) has two loops and it calls simplify on each expression twice.
> simplifyAnd(RexCall e) calls simplifyList (that walks all the tree down), then simplifyAnd2ForUnknownAsFalse calls simplify_ again.
> It looks like just one pass should be sufficient for most of the cases, and the logic should probably be adjusted as follows:
> {code:java}
> simplify(RexNode node){
> // e.g. simplify the node with assumption that all the arguments were simplified, etc, avoid complicated checks
> node = simplifyTrivialCases(node);
> // this walks over the tree, simplifies operands first then simplifies the call itself
> node = simplifyArgumentsThenSimplifyNode(node);
> return node;
> }{code}
> Method naming should clearly indicate that the method is heavy, so it would not accidentally be used.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)