asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjaco...@apache.org
Subject incubator-asterixdb-hyracks git commit: Adapted Inline Variable rules to allow functions that are treated as constant at runtime to be inlineable
Date Wed, 21 Oct 2015 17:37:40 GMT
Repository: incubator-asterixdb-hyracks
Updated Branches:
  refs/heads/master 4eb3c9af8 -> 492b6fea9


Adapted Inline Variable rules to allow functions that are treated as constant at runtime to
be inlineable

Change-Id: Ib990773ec36a3f51abef72ce6ceb7715aa1d5e37
Reviewed-on: https://asterix-gerrit.ics.uci.edu/368
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/commit/492b6fea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/tree/492b6fea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/diff/492b6fea

Branch: refs/heads/master
Commit: 492b6fea99a4f6b90f674f46b1945f609cd1f5f1
Parents: 4eb3c9a
Author: Steven Jacobs <sjaco002@ucr.edu>
Authored: Mon Oct 19 15:38:07 2015 -0700
Committer: Steven Jacobs <sjaco002@ucr.edu>
Committed: Wed Oct 21 10:34:38 2015 -0700

----------------------------------------------------------------------
 .../rewriter/rules/InlineVariablesRule.java      | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/492b6fea/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/InlineVariablesRule.java
----------------------------------------------------------------------
diff --git a/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/InlineVariablesRule.java
b/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/InlineVariablesRule.java
index 512e7d3..1ecb893 100644
--- a/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/InlineVariablesRule.java
+++ b/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/InlineVariablesRule.java
@@ -26,7 +26,6 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.commons.lang3.mutable.Mutable;
-
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator;
@@ -120,6 +119,21 @@ public class InlineVariablesRule implements IAlgebraicRewriteRule {
         return false;
     }
 
+    /* An expression will be constant at runtime if it has:
+     * 1. A type
+     * 2. No free variables
+     */
+    public static boolean functionIsConstantAtRuntime(AbstractLogicalOperator op,
+            AbstractFunctionCallExpression funcExpr, IOptimizationContext context) throws
AlgebricksException {
+        //make sure that there are no variables in the expression
+        Set<LogicalVariable> usedVariables = new HashSet<LogicalVariable>();
+        funcExpr.getUsedVariables(usedVariables);
+        if (usedVariables.size() > 0) {
+            return false;
+        }
+        return true;
+    }
+
     protected boolean inlineVariables(Mutable<ILogicalOperator> opRef, IOptimizationContext
context)
             throws AlgebricksException {
         AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
@@ -134,7 +148,8 @@ public class InlineVariablesRule implements IAlgebraicRewriteRule {
                 // Ignore functions that are either in the doNotInline set or are non-functional
              
                 if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
                     AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression)
expr;
-                    if (doNotInlineFuncs.contains(funcExpr.getFunctionIdentifier()) || !funcExpr.isFunctional())
{
+                    if (doNotInlineFuncs.contains(funcExpr.getFunctionIdentifier())
+                            || (!funcExpr.isFunctional() && !functionIsConstantAtRuntime(op,
funcExpr, context))) {
                         continue;
                     }
                 }


Mime
View raw message