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 2013/09/06 01:02:17 UTC

svn commit: r1520455 - in /incubator/vxquery/trunk/vxquery/vxquery-core/src/main: java/org/apache/vxquery/compiler/rewriter/rules/ java/org/apache/vxquery/functions/ xslt/

Author: prestonc
Date: Thu Sep  5 23:02:17 2013
New Revision: 1520455

URL: http://svn.apache.org/r1520455
Log:
Updated the function class properties to include a boolean value for scalar, aggregate, or unnesting evaluator factories. The value is true when those factories exists. The rewrite rule has been updated to be a generic search for scalar functions that could be unnesting functions.

Modified:
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertAssignToUnnestRule.java
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/Function.java
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/xslt/generate-fn-defns.xsl
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/xslt/generate-op-defns.xsl

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertAssignToUnnestRule.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertAssignToUnnestRule.java?rev=1520455&r1=1520454&r2=1520455&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertAssignToUnnestRule.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ConvertAssignToUnnestRule.java Thu Sep  5 23:02:17 2013
@@ -18,6 +18,7 @@ package org.apache.vxquery.compiler.rewr
 
 import org.apache.commons.lang3.mutable.Mutable;
 import org.apache.vxquery.functions.BuiltinOperators;
+import org.apache.vxquery.functions.Function;
 
 import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
 import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression;
@@ -41,15 +42,16 @@ import edu.uci.ics.hyracks.algebricks.co
  * 
  *   plan__parent
  *   UNNEST( $v2 : iterate( $v1 ) )
- *   ASSIGN( $v1 : child( $v0 ) )
+ *   ASSIGN( $v1 : sf1( $v0 ) )
  *   plan__child
  *   
  *   where plan__parent does not use $v1 and $v0 is defined in plan__child.
+ *   sf1 is a scalar function that has a unnesting implementation.
  *   
  * After
  * 
  *   plan__parent
- *   UNNEST( $v2 : child( $v0 ) )
+ *   UNNEST( $v2 : uf1( $v0 ) )
  *   plan__child
  * </pre>
  * 
@@ -86,10 +88,11 @@ public class ConvertAssignToUnnestRule i
             return false;
         }
         AbstractFunctionCallExpression functionCall2 = (AbstractFunctionCallExpression) logicalExpression2;
-        if (!functionCall2.getFunctionIdentifier().equals(BuiltinOperators.CHILD.getFunctionIdentifier())) {
+        Function functionInfo2 = (Function) functionCall2.getFunctionInfo();
+        if (!functionInfo2.hasUnnestingEvaluatorFactory()) {
             return false;
         }
-
+        
         // TODO add checks for variables used that have now been removed.
 
         // Update the unnest parameters.
@@ -98,7 +101,7 @@ public class ConvertAssignToUnnestRule i
             unnest.getInputs().get(index++).setValue(input.getValue());
         }
 
-        UnnestingFunctionCallExpression child = new UnnestingFunctionCallExpression(BuiltinOperators.CHILD, functionCall2.getArguments());
+        UnnestingFunctionCallExpression child = new UnnestingFunctionCallExpression(functionInfo2, functionCall2.getArguments());
         unnest.getExpressionRef().setValue(child);
         
         return true;

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/Function.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/Function.java?rev=1520455&r1=1520454&r2=1520455&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/Function.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/Function.java Thu Sep  5 23:02:17 2013
@@ -41,9 +41,12 @@ public abstract class Function implement
     protected final Signature signature;
 
     protected IPropertyPropagationPolicy<DocumentOrder> documentOrderPropagationPolicy;
-
     protected IPropertyPropagationPolicy<UniqueNodes> uniqueNodesPropagationPolicy;
 
+    protected boolean aggregateEvaluatorFactory = false;
+    protected boolean scalarEvaluatorFactory = false;
+    protected boolean unnestingEvaluatorFactory = false;
+
     public Function(QName qname, Signature signature) {
         this.fid = new FunctionIdentifier(VXQUERY, "{" + qname.getNamespaceURI() + "}" + qname.getLocalPart());
         this.qname = qname;
@@ -83,6 +86,18 @@ public abstract class Function implement
         return this.uniqueNodesPropagationPolicy;
     }
 
+    public boolean hasAggregateEvaluatorFactory() {
+        return this.aggregateEvaluatorFactory;
+    }
+
+    public boolean hasScalarEvaluatorFactory() {
+        return this.scalarEvaluatorFactory;
+    }
+
+    public boolean hasUnnestingEvaluatorFactory() {
+        return this.unnestingEvaluatorFactory;
+    }
+
     public QName getName() {
         return qname;
     }

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/xslt/generate-fn-defns.xsl
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/xslt/generate-fn-defns.xsl?rev=1520455&r1=1520454&r2=1520455&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/xslt/generate-fn-defns.xsl (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/xslt/generate-fn-defns.xsl Thu Sep  5 23:02:17 2013
@@ -65,6 +65,17 @@
                             );
                         </xsl:if>
 	                </xsl:for-each>
+	                <xsl:for-each select="runtime">
+                        <xsl:if test="@type = 'scalar'">
+                        this.scalarEvaluatorFactory = true;
+                        </xsl:if>
+                        <xsl:if test="@type = 'aggregate'">
+                        this.aggregateEvaluatorFactory = true;
+                        </xsl:if>
+                        <xsl:if test="@type = 'unnesting'">
+                        this.unnestingEvaluatorFactory = true;
+                        </xsl:if>
+                    </xsl:for-each>
 	                }
                 </xsl:if>
                 <xsl:for-each select="runtime">

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/xslt/generate-op-defns.xsl
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/xslt/generate-op-defns.xsl?rev=1520455&r1=1520454&r2=1520455&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/xslt/generate-op-defns.xsl (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/xslt/generate-op-defns.xsl Thu Sep  5 23:02:17 2013
@@ -57,6 +57,17 @@
                             );
                         </xsl:if>
                     </xsl:for-each>
+                    <xsl:for-each select="runtime">
+                        <xsl:if test="@type = 'scalar'">
+                        this.scalarEvaluatorFactory = true;
+                        </xsl:if>
+                        <xsl:if test="@type = 'aggregate'">
+                        this.aggregateEvaluatorFactory = true;
+                        </xsl:if>
+                        <xsl:if test="@type = 'unnesting'">
+                        this.unnestingEvaluatorFactory = true;
+                        </xsl:if>
+                    </xsl:for-each>
                     }
                 </xsl:if>
                 <xsl:for-each select="runtime">