Steven Jacobs has submitted this change and it was merged. Change subject: Adapted Inline Variable rules to allow functions that are treated as constant at runtime to be inlineable ......................................................................
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 <[email protected]> Reviewed-by: Yingyi Bu <[email protected]> --- M algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/InlineVariablesRule.java 1 file changed, 17 insertions(+), 2 deletions(-) Approvals: Yingyi Bu: Looks good to me, approved Jenkins: Verified 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.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 @@ 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 @@ // 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; } } -- To view, visit https://asterix-gerrit.ics.uci.edu/368 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib990773ec36a3f51abef72ce6ceb7715aa1d5e37 Gerrit-PatchSet: 5 Gerrit-Project: hyracks Gerrit-Branch: master Gerrit-Owner: Steven Jacobs <[email protected]> Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Preston Carman <[email protected]> Gerrit-Reviewer: Steven Jacobs <[email protected]> Gerrit-Reviewer: Yingyi Bu <[email protected]> Gerrit-Reviewer: Yingyi Bu <[email protected]>
