Repository: vxquery
Updated Branches:
  refs/heads/master da09ce8b8 -> 9abe3e9f0


http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionDataSource.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionDataSource.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionDataSource.java
index 5c2867f..d17a1a9 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionDataSource.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionDataSource.java
@@ -113,4 +113,8 @@ public class VXQueryCollectionDataSource implements 
IDataSource<String> {
         return childSeq;
     }
 
+    @Override
+    public String toString() {
+        return "VXQueryCollectionDataSource [collectionName=" + collectionName 
+ ", childSeq=" + childSeq + "]";
+    }
 }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
index bc92ffc..0599ea9 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
@@ -130,14 +130,6 @@ public class VXQueryMetadataProvider implements 
IMetadataProvider<String, String
     }
 
     @Override
-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> 
getInsertRuntime(IDataSource<String> dataSource,
-            IOperatorSchema propagatedSchema, IVariableTypeEnvironment 
typeEnv, List<LogicalVariable> keys,
-            LogicalVariable payLoadVar, List<LogicalVariable> 
additionalNonKeyFields, RecordDescriptor recordDesc,
-            JobGenContext context, JobSpecification jobSpec) throws 
AlgebricksException {
-        return null;
-    }
-
-    @Override
     public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> 
getDeleteRuntime(IDataSource<String> dataSource,
             IOperatorSchema propagatedSchema, IVariableTypeEnvironment 
typeEnv, List<LogicalVariable> keys,
             LogicalVariable payLoadVar, List<LogicalVariable> 
additionalNonKeyFields, RecordDescriptor recordDesc,
@@ -146,16 +138,6 @@ public class VXQueryMetadataProvider implements 
IMetadataProvider<String, String
     }
 
     @Override
-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> 
getIndexInsertRuntime(
-            IDataSourceIndex<String, String> dataSource, IOperatorSchema 
propagatedSchema,
-            IOperatorSchema[] inputSchemas, IVariableTypeEnvironment typeEnv, 
List<LogicalVariable> primaryKeys,
-            List<LogicalVariable> secondaryKeys, List<LogicalVariable> 
additionalNonKeyFields,
-            ILogicalExpression filterExpr, RecordDescriptor recordDesc, 
JobGenContext context, JobSpecification spec)
-            throws AlgebricksException {
-        return null;
-    }
-
-    @Override
     public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> 
getIndexDeleteRuntime(
             IDataSourceIndex<String, String> dataSource, IOperatorSchema 
propagatedSchema,
             IOperatorSchema[] inputSchemas, IVariableTypeEnvironment typeEnv, 
List<LogicalVariable> primaryKeys,
@@ -208,4 +190,31 @@ public class VXQueryMetadataProvider implements 
IMetadataProvider<String, String
         return new Pair<IOperatorDescriptor, 
AlgebricksPartitionConstraint>(resultWriter, null);
     }
 
+    @Override
+    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> 
getInsertRuntime(IDataSource<String> dataSource,
+            IOperatorSchema propagatedSchema, IVariableTypeEnvironment 
typeEnv, List<LogicalVariable> keys,
+            LogicalVariable payLoadVar, List<LogicalVariable> 
additionalNonKeyFields, RecordDescriptor recordDesc,
+            JobGenContext context, JobSpecification jobSpec, boolean bulkload) 
throws AlgebricksException {
+        return null;
+    }
+
+    @Override
+    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> 
getIndexInsertRuntime(
+            IDataSourceIndex<String, String> dataSource, IOperatorSchema 
propagatedSchema,
+            IOperatorSchema[] inputSchemas, IVariableTypeEnvironment typeEnv, 
List<LogicalVariable> primaryKeys,
+            List<LogicalVariable> secondaryKeys, List<LogicalVariable> 
additionalNonKeyFields,
+            ILogicalExpression filterExpr, RecordDescriptor recordDesc, 
JobGenContext context, JobSpecification spec,
+            boolean bulkload) throws AlgebricksException {
+        return null;
+    }
+
+    @Override
+    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> 
getTokenizerRuntime(
+            IDataSourceIndex<String, String> dataSource, IOperatorSchema 
propagatedSchema,
+            IOperatorSchema[] inputSchemas, IVariableTypeEnvironment typeEnv, 
List<LogicalVariable> primaryKeys,
+            List<LogicalVariable> secondaryKeys, ILogicalExpression 
filterExpr, RecordDescriptor recordDesc,
+            JobGenContext context, JobSpecification spec, boolean bulkload) 
throws AlgebricksException {
+        return null;
+    }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractChildPathStep.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractChildPathStep.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractChildPathStep.java
deleted file mode 100644
index 2668719..0000000
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractChildPathStep.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.vxquery.runtime.functions.step;
-
-import java.io.IOException;
-
-import org.apache.vxquery.context.DynamicContext;
-import org.apache.vxquery.datamodel.accessors.PointablePool;
-import org.apache.vxquery.datamodel.accessors.SequencePointable;
-import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
-import org.apache.vxquery.datamodel.accessors.nodes.DocumentNodePointable;
-import org.apache.vxquery.datamodel.accessors.nodes.ElementNodePointable;
-import org.apache.vxquery.datamodel.accessors.nodes.NodeTreePointable;
-import org.apache.vxquery.datamodel.builders.nodes.NodeSubTreeBuilder;
-import org.apache.vxquery.datamodel.values.ValueTag;
-import org.apache.vxquery.datamodel.values.XDMConstants;
-
-import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
-import edu.uci.ics.hyracks.data.std.api.IPointable;
-import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
-
-public abstract class AbstractChildPathStep {
-    protected final DynamicContext dCtx;
-    protected final PointablePool pp;
-    private final ArrayBackedValueStorage nodeAbvs = new 
ArrayBackedValueStorage();
-    protected final NodeTreePointable ntp = (NodeTreePointable) 
NodeTreePointable.FACTORY.createPointable();
-    private final DocumentNodePointable dnp = (DocumentNodePointable) 
DocumentNodePointable.FACTORY.createPointable();
-    private final ElementNodePointable enp = (ElementNodePointable) 
ElementNodePointable.FACTORY.createPointable();
-    private final NodeSubTreeBuilder nstb = new NodeSubTreeBuilder();
-
-    public AbstractChildPathStep(IHyracksTaskContext ctx, PointablePool pp) {
-        dCtx = (DynamicContext) ctx.getJobletContext().getGlobalJobData();
-        this.pp = pp;
-    }
-
-    protected void getSequence(TaggedValuePointable tvp, SequencePointable 
seqp) {
-        switch (tvp.getTag()) {
-            case ValueTag.DOCUMENT_NODE_TAG:
-                tvp.getValue(dnp);
-                dnp.getContent(ntp, seqp);
-                return;
-
-            case ValueTag.ELEMENT_NODE_TAG:
-                tvp.getValue(enp);
-                if (enp.childrenChunkExists()) {
-                    enp.getChildrenSequence(ntp, seqp);
-                    return;
-                }
-        }
-        XDMConstants.setEmptySequence(seqp);
-    }
-
-    protected void setNodeToResult(TaggedValuePointable tvpItem, IPointable 
result) throws IOException {
-        nodeAbvs.reset();
-        nstb.reset(nodeAbvs);
-        nstb.setChildNode(ntp, tvpItem);
-        nstb.finish();
-        result.set(nodeAbvs.getByteArray(), nodeAbvs.getStartOffset(), 
nodeAbvs.getLength());
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractDescendantPathStepScalarEvaluator.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractDescendantPathStepScalarEvaluator.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractDescendantPathStepScalarEvaluator.java
index 6c5f18f..3322f90 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractDescendantPathStepScalarEvaluator.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractDescendantPathStepScalarEvaluator.java
@@ -23,7 +23,6 @@ import 
org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
 import org.apache.vxquery.datamodel.accessors.nodes.DocumentNodePointable;
 import org.apache.vxquery.datamodel.accessors.nodes.ElementNodePointable;
 import org.apache.vxquery.datamodel.values.ValueTag;
-import org.apache.vxquery.datamodel.values.XDMConstants;
 import org.apache.vxquery.exceptions.ErrorCode;
 import org.apache.vxquery.exceptions.SystemException;
 
@@ -79,9 +78,7 @@ public abstract class 
AbstractDescendantPathStepScalarEvaluator extends Abstract
                     seqp.getEntry(i, itemTvp);
                     // Only search element nodes.
                     if (itemTvp.getTag() == ValueTag.ELEMENT_NODE_TAG) {
-                        if (matches()) {
-                            appendNodeToResult();
-                        }
+                        appendNodeToResult();
                         // Now check this elements children.
                         TaggedValuePointable tvpTemp = (TaggedValuePointable) 
TaggedValuePointable.FACTORY
                                 .createPointable();

http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractForwardAxisPathStep.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractForwardAxisPathStep.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractForwardAxisPathStep.java
new file mode 100644
index 0000000..e4d25cf
--- /dev/null
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractForwardAxisPathStep.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.vxquery.runtime.functions.step;
+
+import java.io.IOException;
+
+import org.apache.vxquery.context.DynamicContext;
+import org.apache.vxquery.datamodel.accessors.PointablePool;
+import org.apache.vxquery.datamodel.accessors.SequencePointable;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.DocumentNodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.ElementNodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.NodeTreePointable;
+import org.apache.vxquery.datamodel.builders.nodes.NodeSubTreeBuilder;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.datamodel.values.XDMConstants;
+
+import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+
+public abstract class AbstractForwardAxisPathStep {
+    protected final DynamicContext dCtx;
+    protected final PointablePool pp;
+    protected final NodeTreePointable ntp = (NodeTreePointable) 
NodeTreePointable.FACTORY.createPointable();
+    private final ArrayBackedValueStorage nodeAbvs = new 
ArrayBackedValueStorage();
+    private final DocumentNodePointable dnp = (DocumentNodePointable) 
DocumentNodePointable.FACTORY.createPointable();
+    private final ElementNodePointable enp = (ElementNodePointable) 
ElementNodePointable.FACTORY.createPointable();
+    private final NodeSubTreeBuilder nstb = new NodeSubTreeBuilder();
+
+    public AbstractForwardAxisPathStep(IHyracksTaskContext ctx, PointablePool 
pp) {
+        dCtx = (DynamicContext) ctx.getJobletContext().getGlobalJobData();
+        this.pp = pp;
+    }
+
+    protected void getSequence(TaggedValuePointable tvp, SequencePointable 
seqp) {
+        switch (tvp.getTag()) {
+            case ValueTag.DOCUMENT_NODE_TAG:
+                tvp.getValue(dnp);
+                dnp.getContent(ntp, seqp);
+                return;
+
+            case ValueTag.ELEMENT_NODE_TAG:
+                tvp.getValue(enp);
+                if (enp.childrenChunkExists()) {
+                    enp.getChildrenSequence(ntp, seqp);
+                    return;
+                }
+        }
+        XDMConstants.setEmptySequence(seqp);
+    }
+
+    protected void setNodeToResult(TaggedValuePointable tvpItem, IPointable 
result) throws IOException {
+        nodeAbvs.reset();
+        nstb.reset(nodeAbvs);
+        nstb.setChildNode(ntp, tvpItem);
+        nstb.finish();
+        result.set(nodeAbvs.getByteArray(), nodeAbvs.getStartOffset(), 
nodeAbvs.getLength());
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepOperatorDescriptor.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepOperatorDescriptor.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepOperatorDescriptor.java
index 1edf0f5..125623c 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepOperatorDescriptor.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepOperatorDescriptor.java
@@ -23,12 +23,7 @@ import java.util.List;
 import org.apache.vxquery.datamodel.accessors.PointablePool;
 import org.apache.vxquery.datamodel.accessors.SequencePointable;
 import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
-import org.apache.vxquery.datamodel.accessors.nodes.DocumentNodePointable;
-import org.apache.vxquery.datamodel.accessors.nodes.ElementNodePointable;
-import org.apache.vxquery.datamodel.accessors.nodes.NodeTreePointable;
-import org.apache.vxquery.datamodel.builders.nodes.NodeSubTreeBuilder;
 import org.apache.vxquery.datamodel.values.ValueTag;
-import org.apache.vxquery.datamodel.values.XDMConstants;
 import org.apache.vxquery.exceptions.ErrorCode;
 import org.apache.vxquery.exceptions.SystemException;
 import org.apache.vxquery.runtime.functions.step.NodeTestFilter.INodeFilter;
@@ -37,40 +32,17 @@ import org.apache.vxquery.types.SequenceType;
 import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
 import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
 import edu.uci.ics.hyracks.data.std.api.IPointable;
-import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
 
-public class ChildPathStepOperatorDescriptor extends AbstractChildPathStep {
+public class ChildPathStepOperatorDescriptor extends 
AbstractForwardAxisPathStep {
     private List<INodeFilter> filter = new ArrayList<INodeFilter>();
     private int[] indexSequence;
-    private final ArrayBackedValueStorage nodeAbvs = new 
ArrayBackedValueStorage();
-    protected final NodeTreePointable ntp = (NodeTreePointable) 
NodeTreePointable.FACTORY.createPointable();
     private final TaggedValuePointable tvpItem = (TaggedValuePointable) 
TaggedValuePointable.FACTORY.createPointable();
-    private final DocumentNodePointable dnp = (DocumentNodePointable) 
DocumentNodePointable.FACTORY.createPointable();
-    private final ElementNodePointable enp = (ElementNodePointable) 
ElementNodePointable.FACTORY.createPointable();
     private final TaggedValuePointable tvpStep = (TaggedValuePointable) 
TaggedValuePointable.FACTORY.createPointable();
-    private final NodeSubTreeBuilder nstb = new NodeSubTreeBuilder();
 
     public ChildPathStepOperatorDescriptor(IHyracksTaskContext ctx, 
PointablePool pp) {
         super(ctx, pp);
     }
 
-    protected void getSequence(TaggedValuePointable tvp, SequencePointable 
seqp) {
-        switch (tvp.getTag()) {
-            case ValueTag.DOCUMENT_NODE_TAG:
-                tvp.getValue(dnp);
-                dnp.getContent(ntp, seqp);
-                return;
-
-            case ValueTag.ELEMENT_NODE_TAG:
-                tvp.getValue(enp);
-                if (enp.childrenChunkExists()) {
-                    enp.getChildrenSequence(ntp, seqp);
-                    return;
-                }
-        }
-        XDMConstants.setEmptySequence(seqp);
-    }
-
     public void init(TaggedValuePointable tvp, List<Integer> typeCodes) throws 
SystemException {
         indexSequence = new int[typeCodes.size()];
         for (int i = 0; i < typeCodes.size(); ++i) {
@@ -91,14 +63,6 @@ public class ChildPathStepOperatorDescriptor extends 
AbstractChildPathStep {
         }
     }
 
-    protected void setNodeToResult(TaggedValuePointable tvpItem, IPointable 
result) throws IOException {
-        nodeAbvs.reset();
-        nstb.reset(nodeAbvs);
-        nstb.setChildNode(ntp, tvpItem);
-        nstb.finish();
-        result.set(nodeAbvs.getByteArray(), nodeAbvs.getStartOffset(), 
nodeAbvs.getLength());
-    }
-
     /**
      * Single node tree input.
      * Requirement: "ntp" must be the node tree.

http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnesting.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnesting.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnesting.java
index 1e93ce3..ea65066 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnesting.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnesting.java
@@ -32,7 +32,7 @@ import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
 import edu.uci.ics.hyracks.data.std.api.IPointable;
 import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
 
-public class ChildPathStepUnnesting extends AbstractChildPathStep {
+public class ChildPathStepUnnesting extends AbstractForwardAxisPathStep {
     private int indexSeqArgs;
     private int seqArgsLength;
     private int indexSequence;
@@ -83,6 +83,7 @@ public class ChildPathStepUnnesting extends 
AbstractChildPathStep {
                 if (stepNodeTree(tvpStep, 0, result)) {
                     return true;
                 }
+                indexSeqArgs++;
             }
         } else {
             // Single node tree input.

http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepScalarEvaluator.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepScalarEvaluator.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepScalarEvaluator.java
index 203877a..5572166 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepScalarEvaluator.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepScalarEvaluator.java
@@ -95,16 +95,13 @@ public class DescendantOrSelfPathStepScalarEvaluator 
extends AbstractDescendantP
                 throw new SystemException(ErrorCode.SYSE0001);
         }
         itemTvp.set(rootTVP);
-        if (matches()) {
-            try {
-                appendNodeToResult();
-            } catch (IOException e) {
-                throw new SystemException(ErrorCode.SYSE0001, e);
-            }
+        try {
+            appendNodeToResult();
+        } catch (IOException e) {
+            throw new SystemException(ErrorCode.SYSE0001, e);
         }
 
         // Solve for descendants.
-        setNodeTest(SequenceType.create(ElementType.ANYELEMENT, 
Quantifier.QUANT_ONE));
         searchSubtree(rootTVP);
     }
 

http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnesting.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnesting.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnesting.java
new file mode 100644
index 0000000..57ab9e7
--- /dev/null
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnesting.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.vxquery.runtime.functions.step;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.vxquery.datamodel.accessors.PointablePool;
+import org.apache.vxquery.datamodel.accessors.SequencePointable;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.exceptions.ErrorCode;
+import org.apache.vxquery.exceptions.SystemException;
+
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+
+public class DescendantOrSelfPathStepUnnesting extends 
AbstractForwardAxisPathStep {
+    private boolean testSelf;
+    private int indexSeqArgs;
+    private int seqArgsLength;
+    private List<Integer> indexSequence = new ArrayList<Integer>();
+    private List<Boolean> checkSelf = new ArrayList<Boolean>();
+
+    private final SequencePointable seqNtp = (SequencePointable) 
SequencePointable.FACTORY.createPointable();
+    private final TaggedValuePointable tvpItem = (TaggedValuePointable) 
TaggedValuePointable.FACTORY.createPointable();
+    private final TaggedValuePointable tvpNtp = (TaggedValuePointable) 
TaggedValuePointable.FACTORY.createPointable();
+    private final TaggedValuePointable tvpStep = (TaggedValuePointable) 
TaggedValuePointable.FACTORY.createPointable();
+
+    public DescendantOrSelfPathStepUnnesting(IHyracksTaskContext ctx, 
PointablePool pp, boolean testSelf) {
+        super(ctx, pp);
+        this.testSelf = testSelf;
+    }
+
+    protected void init(TaggedValuePointable[] args) throws SystemException {
+        checkSelf.add(true);
+        indexSeqArgs = 0;
+        indexSequence.add(0);
+
+        // Check the argument passed in as sequence or node tree.
+        if (args[0].getTag() == ValueTag.SEQUENCE_TAG) {
+            args[0].getValue(seqNtp);
+            seqArgsLength = seqNtp.getEntryCount();
+        } else if (args[0].getTag() == ValueTag.NODE_TREE_TAG) {
+            args[0].getValue(ntp);
+            seqArgsLength = -1;
+        } else {
+            throw new SystemException(ErrorCode.SYSE0001);
+        }
+    }
+
+    public boolean step(IPointable result) throws AlgebricksException {
+        if (seqArgsLength > 0) {
+            while (indexSeqArgs < seqArgsLength) {
+                seqNtp.getEntry(indexSeqArgs, tvpNtp);
+                if (tvpNtp.getTag() != ValueTag.NODE_TREE_TAG) {
+                    String description = ErrorCode.SYSE0001 + ": " + 
ErrorCode.SYSE0001.getDescription();
+                    throw new AlgebricksException(description);
+                }
+                tvpNtp.getValue(ntp);
+                ntp.getRootNode(tvpStep);
+                if (processNodeTree(tvpStep, result)) {
+                    return true;
+                }
+                // Next node tree in sequence.
+                indexSeqArgs++;
+                checkSelf.set(0, true);
+            }
+        } else {
+            // Single node tree input.
+            ntp.getRootNode(tvpStep);
+            if (processNodeTree(tvpStep, result)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private boolean processNodeTree(TaggedValuePointable rootTVP, IPointable 
result) throws AlgebricksException {
+        if (testSelf && checkSelf.get(0)) {
+            checkSelf.set(0, false);
+            tvpItem.set(rootTVP);
+            try {
+                setNodeToResult(tvpItem, result);
+                return true;
+            } catch (IOException e) {
+                String description = ErrorCode.SYSE0001 + ": " + 
ErrorCode.SYSE0001.getDescription();
+                throw new AlgebricksException(description);
+            }
+        }
+
+        // Solve for descendants.
+        return stepNodeTree(rootTVP, 0, result);
+    }
+
+    /**
+     * Search through all tree children and children's children.
+     * 
+     * @param nodePointable
+     * @throws SystemException
+     */
+    protected boolean stepNodeTree(TaggedValuePointable tvpInput, int level, 
IPointable result)
+            throws AlgebricksException {
+        // Set up next level tracking.
+        if (level + 1 >= indexSequence.size()) {
+            indexSequence.add(0);
+        }
+        if (level + 1 >= checkSelf.size()) {
+            checkSelf.add(true);
+        }
+
+        SequencePointable seqItem = pp.takeOne(SequencePointable.class);
+        try {
+            getSequence(tvpInput, seqItem);
+            int seqLength = seqItem.getEntryCount();
+            while (indexSequence.get(level) < seqLength) {
+                // Get the next item
+                seqItem.getEntry(indexSequence.get(level), tvpItem);
+
+                // Check current node
+                if (checkSelf.get(level)) {
+                    checkSelf.set(level, false);
+                    setNodeToResult(tvpItem, result);
+                    return true;
+                }
+                // Check children nodes
+                if (level + 1 < indexSequence.size()) {
+                    if (level + 1 < checkSelf.size()) {
+                        checkSelf.set(level + 1, true);
+                    }
+                    if (stepNodeTree(tvpItem, level + 1, result)) {
+                        return true;
+                    }
+                }
+                indexSequence.set(level, indexSequence.get(level) + 1);
+            }
+            // Reset for next node tree.
+            if (level == 0) {
+                indexSequence.set(level, 0);
+            } else {
+                indexSequence.remove(level);
+            }
+            return false;
+        } catch (IOException e) {
+            String description = ErrorCode.SYSE0001 + ": " + 
ErrorCode.SYSE0001.getDescription();
+            throw new AlgebricksException(description);
+        } finally {
+            pp.giveBack(seqItem);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnestingEvaluator.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnestingEvaluator.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnestingEvaluator.java
new file mode 100644
index 0000000..9c0eb40
--- /dev/null
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnestingEvaluator.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.vxquery.runtime.functions.step;
+
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.exceptions.SystemException;
+import 
org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentUnnestingEvaluator;
+
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+
+public class DescendantOrSelfPathStepUnnestingEvaluator extends 
AbstractTaggedValueArgumentUnnestingEvaluator {
+    final DescendantOrSelfPathStepUnnesting descendantOrSelfPathStep;
+
+    public DescendantOrSelfPathStepUnnestingEvaluator(IHyracksTaskContext ctx, 
IScalarEvaluator[] args) {
+        super(args);
+        descendantOrSelfPathStep = new DescendantOrSelfPathStepUnnesting(ctx, 
ppool, true);
+    }
+
+    public boolean step(IPointable result) throws AlgebricksException {
+        return descendantOrSelfPathStep.step(result);
+    }
+
+    @Override
+    protected void init(TaggedValuePointable[] args) throws SystemException {
+        descendantOrSelfPathStep.init(args);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnestingEvaluatorFactory.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnestingEvaluatorFactory.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnestingEvaluatorFactory.java
new file mode 100644
index 0000000..10e2f3d
--- /dev/null
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantOrSelfPathStepUnnestingEvaluatorFactory.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.vxquery.runtime.functions.step;
+
+import 
org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentUnnestingEvaluatorFactory;
+
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IUnnestingEvaluator;
+import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+
+public class DescendantOrSelfPathStepUnnestingEvaluatorFactory extends
+        AbstractTaggedValueArgumentUnnestingEvaluatorFactory {
+    private static final long serialVersionUID = 1L;
+
+    public 
DescendantOrSelfPathStepUnnestingEvaluatorFactory(IScalarEvaluatorFactory[] 
args) {
+        super(args);
+    }
+
+    @Override
+    protected IUnnestingEvaluator createEvaluator(IHyracksTaskContext ctx, 
IScalarEvaluator[] args)
+            throws AlgebricksException {
+        return new DescendantOrSelfPathStepUnnestingEvaluator(ctx, args);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantPathStepScalarEvaluator.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantPathStepScalarEvaluator.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantPathStepScalarEvaluator.java
index c2876f8..c415f33 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantPathStepScalarEvaluator.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantPathStepScalarEvaluator.java
@@ -22,9 +22,6 @@ import 
org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
 import org.apache.vxquery.datamodel.values.ValueTag;
 import org.apache.vxquery.exceptions.ErrorCode;
 import org.apache.vxquery.exceptions.SystemException;
-import org.apache.vxquery.types.ElementType;
-import org.apache.vxquery.types.Quantifier;
-import org.apache.vxquery.types.SequenceType;
 
 import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
@@ -56,7 +53,6 @@ public class DescendantPathStepScalarEvaluator extends 
AbstractDescendantPathSte
             ntp.getRootNode(rootTVP);
 
             // Solve for descendants.
-            setNodeTest(SequenceType.create(ElementType.ANYELEMENT, 
Quantifier.QUANT_ONE));
             searchSubtree(rootTVP);
 
             seqb.finish();

http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantPathStepUnnestingEvaluator.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantPathStepUnnestingEvaluator.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantPathStepUnnestingEvaluator.java
new file mode 100644
index 0000000..25455e8
--- /dev/null
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantPathStepUnnestingEvaluator.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.vxquery.runtime.functions.step;
+
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.exceptions.SystemException;
+import 
org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentUnnestingEvaluator;
+
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+
+public class DescendantPathStepUnnestingEvaluator extends 
AbstractTaggedValueArgumentUnnestingEvaluator {
+    final DescendantOrSelfPathStepUnnesting descendantPathStep;
+
+    public DescendantPathStepUnnestingEvaluator(IHyracksTaskContext ctx, 
IScalarEvaluator[] args) {
+        super(args);
+        descendantPathStep = new DescendantOrSelfPathStepUnnesting(ctx, ppool, 
false);
+    }
+
+    public boolean step(IPointable result) throws AlgebricksException {
+        return descendantPathStep.step(result);
+    }
+
+    @Override
+    protected void init(TaggedValuePointable[] args) throws SystemException {
+        descendantPathStep.init(args);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantPathStepUnnestingEvaluatorFactory.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantPathStepUnnestingEvaluatorFactory.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantPathStepUnnestingEvaluatorFactory.java
new file mode 100644
index 0000000..357ab42
--- /dev/null
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/DescendantPathStepUnnestingEvaluatorFactory.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.vxquery.runtime.functions.step;
+
+import 
org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentUnnestingEvaluatorFactory;
+
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IUnnestingEvaluator;
+import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+
+public class DescendantPathStepUnnestingEvaluatorFactory extends 
AbstractTaggedValueArgumentUnnestingEvaluatorFactory {
+    private static final long serialVersionUID = 1L;
+
+    public 
DescendantPathStepUnnestingEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+        super(args);
+    }
+
+    @Override
+    protected IUnnestingEvaluator createEvaluator(IHyracksTaskContext ctx, 
IScalarEvaluator[] args)
+            throws AlgebricksException {
+        return new DescendantPathStepUnnestingEvaluator(ctx, args);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/strings/UTF8StringCharacterIterator.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/strings/UTF8StringCharacterIterator.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/strings/UTF8StringCharacterIterator.java
index 4cce5db..7e93469 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/strings/UTF8StringCharacterIterator.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/strings/UTF8StringCharacterIterator.java
@@ -42,7 +42,7 @@ public class UTF8StringCharacterIterator implements 
ICharacterIterator {
         if (byteOffset < stringp.getLength()) {
             c = stringp.charAt(byteOffset);
             if (LOGGER.isLoggable(Level.FINE)) {
-                LOGGER.fine("  UTF8StringCharacterIterator char[" + byteOffset 
+ "] = " + c);
+                LOGGER.finer("  UTF8StringCharacterIterator char[" + 
byteOffset + "] = " + c);
             }
             // Increment cursor
             if ((c >= 0x0001) && (c <= 0x007F)) {
@@ -54,7 +54,7 @@ public class UTF8StringCharacterIterator implements 
ICharacterIterator {
             }
         }
         if (LOGGER.isLoggable(Level.FINE)) {
-            LOGGER.fine("  END UTF8StringCharacterIterator char[" + byteOffset 
+ "] = " + c);
+            LOGGER.finer("  END UTF8StringCharacterIterator char[" + 
byteOffset + "] = " + c);
         }
         return (char) c;
     }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/99ba4dbf/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
index 3cdc492..44f2179 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
@@ -113,7 +113,7 @@ public class XMLQueryCompiler {
                 });
         builder.getPhysicalOptimizationConfig().setFrameSize(this.frameSize);
         if (joinHashSize > 0) {
-            
builder.getPhysicalOptimizationConfig().setMaxFramesHybridHash(joinHashSize);
+            
builder.getPhysicalOptimizationConfig().setMaxFramesHybridHash(joinHashSize/this.frameSize);
         }
         builder.setLogicalRewrites(buildDefaultLogicalRewrites());
         builder.setPhysicalRewrites(buildDefaultPhysicalRewrites());

Reply via email to