Updated the AbstractUsedVaraibalesProcessingRule to repeat until no more changes occur.
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/99159a02 Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/99159a02 Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/99159a02 Branch: refs/heads/prestonc/benchmark Commit: 99159a0260355038cc95866c5f79b40a8765d742 Parents: 679a9f6 Author: Preston Carman <[email protected]> Authored: Tue May 6 17:36:15 2014 -0700 Committer: Preston Carman <[email protected]> Committed: Thu May 8 14:15:35 2014 -0700 ---------------------------------------------------------------------- .../rules/AbstractUsedVariablesProcessingRule.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/99159a02/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/AbstractUsedVariablesProcessingRule.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/AbstractUsedVariablesProcessingRule.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/AbstractUsedVariablesProcessingRule.java index 04c6f1e..7cbe503 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/AbstractUsedVariablesProcessingRule.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/AbstractUsedVariablesProcessingRule.java @@ -54,13 +54,20 @@ public abstract class AbstractUsedVariablesProcessingRule implements IAlgebraicR if (hasRun) { return false; } - usedVariables.clear(); - boolean modified = rewritePreOnePass(opRef, context); + boolean modified = false; + boolean modified_last_pass; + do { + usedVariables.clear(); + modified_last_pass = rewritePreTrackingUsedVariables(opRef, context); + if (modified_last_pass) { + modified = modified_last_pass; + } + } while (modified_last_pass); hasRun = true; return modified; } - protected boolean rewritePreOnePass(Mutable<ILogicalOperator> opRef, IOptimizationContext context) + protected boolean rewritePreTrackingUsedVariables(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { boolean modified = processOperator(opRef, context); AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); @@ -70,7 +77,7 @@ public abstract class AbstractUsedVariablesProcessingRule implements IAlgebraicR AbstractOperatorWithNestedPlans opwnp = (AbstractOperatorWithNestedPlans) op; for (ILogicalPlan rootPlans : opwnp.getNestedPlans()) { for (Mutable<ILogicalOperator> inputOpRef : rootPlans.getRoots()) { - if (rewritePreOnePass(inputOpRef, context)) { + if (rewritePreTrackingUsedVariables(inputOpRef, context)) { modified = true; } } @@ -83,7 +90,7 @@ public abstract class AbstractUsedVariablesProcessingRule implements IAlgebraicR // Descend into children merging unnest along the way. if (op.hasInputs()) { for (Mutable<ILogicalOperator> inputOpRef : op.getInputs()) { - if (rewritePreOnePass(inputOpRef, context)) { + if (rewritePreTrackingUsedVariables(inputOpRef, context)) { modified = true; } }
