You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by pr...@apache.org on 2014/04/02 06:12:17 UTC
[37/50] [abbrv] git commit: Added comments and reverted a previous
change.
Added comments and reverted a previous change.
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/7566f5ef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/7566f5ef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/7566f5ef
Branch: refs/heads/prestonc/hash_join
Commit: 7566f5ef62de9ce95151ba69990ad4303f5296c1
Parents: 43b6a2c
Author: Preston Carman <pr...@apache.org>
Authored: Mon Mar 17 23:22:45 2014 -0700
Committer: Preston Carman <pr...@apache.org>
Committed: Tue Apr 1 20:56:25 2014 -0700
----------------------------------------------------------------------
.../ConvertFromAlgebricksExpressionsRule.java | 27 +++++++++++++++++++-
.../ConvertToAlgebricksExpressionsRule.java | 23 +++++++++++++++++
.../rewriter/rules/util/ExpressionToolbox.java | 16 +++++-------
3 files changed, 55 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/7566f5ef/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertFromAlgebricksExpressionsRule.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertFromAlgebricksExpressionsRule.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertFromAlgebricksExpressionsRule.java
index 482f05d..1bc2bd6 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertFromAlgebricksExpressionsRule.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertFromAlgebricksExpressionsRule.java
@@ -39,6 +39,29 @@ import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import edu.uci.ics.hyracks.algebricks.core.algebra.functions.IFunctionInfo;
import edu.uci.ics.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule;
+/**
+ * The rule searches for where the Algebricks builtin function are temporarly in the plan in place of XQuery function.
+ * The combination the Algebricks builtin function are replace with boolean XQuery function and the XQuery equivalent
+ * function.
+ *
+ * <pre>
+ * Before
+ *
+ * plan__parent
+ * %OPERATOR( $v1 : algebricks_function( \@input_expression ) )
+ * plan__child
+ *
+ * Where xquery_function creates an atomic value.
+ *
+ * After
+ *
+ * plan__parent
+ * %OPERATOR( $v1 : boolean(xquery_function( \@input_expression ) ) )
+ * plan__child
+ * </pre>
+ *
+ * @author prestonc
+ */
public class ConvertFromAlgebricksExpressionsRule implements IAlgebraicRewriteRule {
final List<Mutable<ILogicalExpression>> functionList = new ArrayList<Mutable<ILogicalExpression>>();
@@ -74,6 +97,7 @@ public class ConvertFromAlgebricksExpressionsRule implements IAlgebraicRewriteRu
return modified;
}
+ @SuppressWarnings("unchecked")
private boolean processExpression(Mutable<ILogicalOperator> opRef, Mutable<ILogicalExpression> search) {
boolean modified = false;
for (FunctionIdentifier fid : ALGEBRICKS_MAP.keySet()) {
@@ -83,7 +107,8 @@ public class ConvertFromAlgebricksExpressionsRule implements IAlgebraicRewriteRu
AbstractFunctionCallExpression searchFunction = (AbstractFunctionCallExpression) searchM.getValue();
searchFunction.setFunctionInfo(ALGEBRICKS_MAP.get(fid));
// Add boolean function before vxquery expression.
- ScalarFunctionCallExpression booleanExp = new ScalarFunctionCallExpression(BuiltinFunctions.FN_BOOLEAN_1, new MutableObject<ILogicalExpression>(searchM.getValue()));
+ ScalarFunctionCallExpression booleanExp = new ScalarFunctionCallExpression(
+ BuiltinFunctions.FN_BOOLEAN_1, new MutableObject<ILogicalExpression>(searchM.getValue()));
searchM.setValue(booleanExp);
modified = true;
}
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/7566f5ef/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertToAlgebricksExpressionsRule.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertToAlgebricksExpressionsRule.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertToAlgebricksExpressionsRule.java
index ebe265e..943d630 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertToAlgebricksExpressionsRule.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertToAlgebricksExpressionsRule.java
@@ -38,6 +38,29 @@ import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import edu.uci.ics.hyracks.algebricks.core.algebra.functions.IFunctionInfo;
import edu.uci.ics.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule;
+/**
+ * The rule searches for where the XQuery function are used in place of Algebricks builtin function.
+ * The combination the boolean XQuery function and the XQuery equivalent function are replace with
+ * the Algebricks builtin function .
+ *
+ * <pre>
+ * Before
+ *
+ * plan__parent
+ * %OPERATOR( $v1 : boolean(xquery_function( \@input_expression ) ) )
+ * plan__child
+ *
+ * Where xquery_function creates an atomic value.
+ *
+ * After
+ *
+ * plan__parent
+ * %OPERATOR( $v1 : algebricks_function( \@input_expression ) )
+ * plan__child
+ * </pre>
+ *
+ * @author prestonc
+ */
public class ConvertToAlgebricksExpressionsRule implements IAlgebraicRewriteRule {
final List<Mutable<ILogicalExpression>> functionList = new ArrayList<Mutable<ILogicalExpression>>();
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/7566f5ef/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/util/ExpressionToolbox.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/util/ExpressionToolbox.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/util/ExpressionToolbox.java
index d674f76..34efdd8 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/util/ExpressionToolbox.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/util/ExpressionToolbox.java
@@ -18,12 +18,9 @@ package org.apache.vxquery.compiler.rewriter.rules.util;
import java.util.List;
-import javax.xml.namespace.QName;
-
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.vxquery.compiler.algebricks.VXQueryConstantValue;
import org.apache.vxquery.context.StaticContext;
-import org.apache.vxquery.context.StaticContextImpl;
import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
import org.apache.vxquery.functions.BuiltinFunctions;
import org.apache.vxquery.functions.BuiltinOperators;
@@ -148,15 +145,14 @@ public class ExpressionToolbox {
}
}
- public static Function getBuiltIn(Mutable<ILogicalExpression> mutableLe, StaticContext rootContext) {
+ public static Function getBuiltIn(Mutable<ILogicalExpression> mutableLe) {
ILogicalExpression le = mutableLe.getValue();
if (le.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
AbstractFunctionCallExpression afce = (AbstractFunctionCallExpression) le;
- FunctionIdentifier fid = afce.getFunctionIdentifier();
- QName functionName = new QName(fid.getNamespace(), fid.getName());
- Function found = rootContext.lookupFunction(functionName, fid.getArity());
- if (found != null) {
- return found;
+ for (Function function : BuiltinFunctions.FUNCTION_COLLECTION) {
+ if (function.getFunctionIdentifier().equals(afce.getFunctionIdentifier())) {
+ return function;
+ }
}
for (Function function : BuiltinOperators.OPERATOR_COLLECTION) {
if (function.getFunctionIdentifier().equals(afce.getFunctionIdentifier())) {
@@ -202,7 +198,7 @@ public class ExpressionToolbox {
switch (argFirstLe.getExpressionTag()) {
case FUNCTION_CALL:
// Only process defined functions.
- Function function = ExpressionToolbox.getBuiltIn(argFirstM, dCtx);
+ Function function = ExpressionToolbox.getBuiltIn(argFirstM);
if (function == null) {
return null;
} else if (function.getFunctionIdentifier().equals(BuiltinOperators.CAST.getFunctionIdentifier())) {