Added support for unnest in expression toolbox sequence matching.

Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/46c7926e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/46c7926e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/46c7926e

Branch: refs/heads/prestonc/benchmarks_staging
Commit: 46c7926ea249bd5b9b09bf22dcfa2b39d600cac1
Parents: 676977c
Author: Preston Carman <[email protected]>
Authored: Tue Mar 4 17:27:21 2014 -0800
Committer: Preston Carman <[email protected]>
Committed: Tue Mar 4 17:27:21 2014 -0800

----------------------------------------------------------------------
 ...stractRemoveRedundantTypeExpressionsRule.java |  3 ++-
 .../rewriter/rules/util/ExpressionToolbox.java   | 19 ++++++++++++-------
 2 files changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/46c7926e/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/AbstractRemoveRedundantTypeExpressionsRule.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/AbstractRemoveRedundantTypeExpressionsRule.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/AbstractRemoveRedundantTypeExpressionsRule.java
index 5298f2a..5d83be7 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/AbstractRemoveRedundantTypeExpressionsRule.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/AbstractRemoveRedundantTypeExpressionsRule.java
@@ -63,6 +63,7 @@ public abstract class 
AbstractRemoveRedundantTypeExpressionsRule implements IAlg
     private boolean processTypeExpression(Mutable<ILogicalOperator> opRef, 
Mutable<ILogicalExpression> search) {
         boolean modified = false;
         SequenceType inputSequenceType;
+        SequenceType sTypeArg;
         functionList.clear();
         ExpressionToolbox.findAllFunctionExpressions(search, 
getSearchFunction(), functionList);
         for (Mutable<ILogicalExpression> searchM : functionList) {
@@ -74,7 +75,7 @@ public abstract class 
AbstractRemoveRedundantTypeExpressionsRule implements IAlg
             inputSequenceType = ExpressionToolbox.getOutputSequenceType(opRef, 
argFirstM, dCtx);
 
             // Find the argument type.
-            SequenceType sTypeArg = null;
+            sTypeArg = null;
             if (hasTypeArgument()) {
                 sTypeArg = 
ExpressionToolbox.getTypeExpressionTypeArgument(searchM, dCtx);
             }

http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/46c7926e/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 7794ed0..dc9e0d3 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
@@ -20,7 +20,6 @@ import java.util.List;
 
 import org.apache.commons.lang3.mutable.Mutable;
 import org.apache.vxquery.compiler.algebricks.VXQueryConstantValue;
-import org.apache.vxquery.context.RootStaticContextImpl;
 import org.apache.vxquery.context.StaticContextImpl;
 import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
 import org.apache.vxquery.functions.BuiltinFunctions;
@@ -33,13 +32,13 @@ import org.apache.vxquery.types.SequenceType;
 import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression;
 import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalExpressionTag;
-import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalOperatorTag;
 import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable;
 import 
edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
 import 
edu.uci.ics.hyracks.algebricks.core.algebra.expressions.ConstantExpression;
 import 
edu.uci.ics.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression;
 import 
edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import 
edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator;
+import 
edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.UnnestOperator;
 import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
 
 public class ExpressionToolbox {
@@ -171,8 +170,7 @@ public class ExpressionToolbox {
         return pTypeCode.getInteger();
     }
 
-    public static SequenceType 
getTypeExpressionTypeArgument(Mutable<ILogicalExpression> searchM,
-            StaticContextImpl dCtx) {
+    public static SequenceType 
getTypeExpressionTypeArgument(Mutable<ILogicalExpression> searchM, 
StaticContextImpl dCtx) {
         int typeId = getTypeExpressionTypeArgument(searchM);
         if (typeId > 0) {
             return dCtx.lookupSequenceType(typeId);
@@ -209,10 +207,17 @@ public class ExpressionToolbox {
                     return null;
                 }
                 AbstractLogicalOperator variableOp = (AbstractLogicalOperator) 
variableProducer.getValue();
-                if (variableOp.getOperatorTag() == 
LogicalOperatorTag.DATASOURCESCAN) {
-                    return SequenceType.create(AnyNodeType.INSTANCE, 
Quantifier.QUANT_ONE);
+                switch (variableOp.getOperatorTag()) {
+                    case DATASOURCESCAN:
+                        return SequenceType.create(AnyNodeType.INSTANCE, 
Quantifier.QUANT_ONE);
+                    case UNNEST:
+                        UnnestOperator unnest = (UnnestOperator) variableOp;
+                        return getOutputSequenceType(variableProducer, 
unnest.getExpressionRef(), dCtx);
+                    default:
+                        // TODO Consider support for other operators. i.e. 
Assign.
+                        break;
                 }
-                // TODO Consider support for other operators. i.e. Assign.
+
         }
         return null;
     }

Reply via email to