You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by vi...@apache.org on 2012/06/08 11:33:56 UTC

svn commit: r1347974 - in /incubator/vxquery/branches/vxquery_algebricks/vxquery-core: ./ src/main/java/org/apache/vxquery/compiler/algebricks/ src/main/java/org/apache/vxquery/compiler/jobgen/ src/main/java/org/apache/vxquery/datamodel/ src/main/java/...

Author: vinayakb
Date: Fri Jun  8 09:33:55 2012
New Revision: 1347974

URL: http://svn.apache.org/viewvc?rev=1347974&view=rev
Log:
Updated dependency on latest Algebricks snapshot version. Added builders

Added:
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/AttributeNodeBuilder.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/CommentNodeBuilder.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/DictionaryBuilder.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/ElementNodeBuilder.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/PINodeBuilder.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/TextNodeBuilder.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/base/
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/base/IDMBuilderPool.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/util/GrowableIntArray.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/IEventAcceptor.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/ITreeNodeIdProvider.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/NodeTreeBuildingEventAcceptor.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java
Modified:
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/pom.xml
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/PrinterFactoryProvider.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/compiler/jobgen/ExpressionJobGen.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/NodeTreePointable.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/drivers/VXQuery.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/functions/Function.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeQNames.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryOptimizer.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/pom.xml?rev=1347974&r1=1347973&r2=1347974&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/pom.xml (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/pom.xml Fri Jun  8 09:33:55 2012
@@ -300,7 +300,7 @@
     <dependency>
       <groupId>edu.uci.ics.hyracks</groupId>
       <artifactId>hyracks-algebricks-compiler</artifactId>
-      <version>0.2.0-SNAPSHOT</version>
+      <version>0.2.1-SNAPSHOT</version>
     </dependency>
 
     <dependency>

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/PrinterFactoryProvider.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/PrinterFactoryProvider.java?rev=1347974&r1=1347973&r2=1347974&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/PrinterFactoryProvider.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/PrinterFactoryProvider.java Fri Jun  8 09:33:55 2012
@@ -1,8 +1,8 @@
 package org.apache.vxquery.compiler.algebricks;
 
-import edu.uci.ics.hyracks.algebricks.core.algebra.data.IPrinterFactory;
-import edu.uci.ics.hyracks.algebricks.core.algebra.data.IPrinterFactoryProvider;
-import edu.uci.ics.hyracks.algebricks.core.api.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
+import edu.uci.ics.hyracks.algebricks.data.IPrinterFactoryProvider;
 
 public class PrinterFactoryProvider implements IPrinterFactoryProvider {
     public static final IPrinterFactoryProvider INSTANCE = new PrinterFactoryProvider();

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/compiler/jobgen/ExpressionJobGen.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/compiler/jobgen/ExpressionJobGen.java?rev=1347974&r1=1347973&r2=1347974&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/compiler/jobgen/ExpressionJobGen.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/compiler/jobgen/ExpressionJobGen.java Fri Jun  8 09:33:55 2012
@@ -1,5 +1,6 @@
 package org.apache.vxquery.compiler.jobgen;
 
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
 import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression;
 import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression;
 import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.ILogicalExpressionJobGen;
@@ -7,13 +8,12 @@ import edu.uci.ics.hyracks.algebricks.co
 import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.StatefulFunctionCallExpression;
 import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.UnnestingFunctionCallExpression;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema;
-import edu.uci.ics.hyracks.algebricks.core.algebra.runtime.base.IAggregateFunctionFactory;
-import edu.uci.ics.hyracks.algebricks.core.algebra.runtime.base.IEvaluatorFactory;
-import edu.uci.ics.hyracks.algebricks.core.algebra.runtime.base.IRunningAggregateFunctionFactory;
-import edu.uci.ics.hyracks.algebricks.core.algebra.runtime.base.ISerializableAggregateFunctionFactory;
-import edu.uci.ics.hyracks.algebricks.core.algebra.runtime.base.IUnnestingFunctionFactory;
-import edu.uci.ics.hyracks.algebricks.core.algebra.runtime.jobgen.impl.JobGenContext;
-import edu.uci.ics.hyracks.algebricks.core.api.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenContext;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IAggregateFunctionFactory;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IEvaluatorFactory;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IRunningAggregateFunctionFactory;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ISerializableAggregateFunctionFactory;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IUnnestingFunctionFactory;
 
 public class ExpressionJobGen implements ILogicalExpressionJobGen {
     @Override

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/NodeTreePointable.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/NodeTreePointable.java?rev=1347974&r1=1347973&r2=1347974&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/NodeTreePointable.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/NodeTreePointable.java Fri Jun  8 09:33:55 2012
@@ -1,6 +1,8 @@
 package org.apache.vxquery.datamodel;
 
+import edu.uci.ics.hyracks.data.std.algorithms.BinarySearchAlgorithm;
 import edu.uci.ics.hyracks.data.std.api.AbstractPointable;
+import edu.uci.ics.hyracks.data.std.collections.api.IValueReferenceVector;
 import edu.uci.ics.hyracks.data.std.primitive.BytePointable;
 import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
 import edu.uci.ics.hyracks.data.std.primitive.LongPointable;
@@ -20,6 +22,34 @@ public class NodeTreePointable extends A
     private static final int IDX_PTR_SLOT_SIZE = 4;
     private static final int SORTED_PTR_SLOT_SIZE = 4;
 
+    private final IValueReferenceVector sortedStringVector = new IValueReferenceVector() {
+        @Override
+        public int getSize() {
+            return getDictionaryEntryCount();
+        }
+
+        @Override
+        public byte[] getBytes(int index) {
+            return bytes;
+        }
+
+        @Override
+        public int getStart(int index) {
+            int dataAreaStart = getDictionaryDataAreaStartOffset();
+            int sortedPtrArrayStart = getDictionarySortedPointerArrayOffset();
+            int sortedSlotValue = IntegerPointable
+                    .getInteger(bytes, sortedPtrArrayStart + index * SORTED_PTR_SLOT_SIZE);
+            return dataAreaStart + sortedSlotValue;
+        }
+
+        @Override
+        public int getLength(int index) {
+            return UTF8StringPointable.getUTFLen(bytes, getStart(index)) + 2;
+        }
+    };
+
+    private final BinarySearchAlgorithm binSearch = new BinarySearchAlgorithm();
+
     public boolean nodeIdExists() {
         return (getHeader() & HEADER_NODEID_EXISTS_MASK) != 0;
     }
@@ -53,26 +83,13 @@ public class NodeTreePointable extends A
     }
 
     public int lookupString(UTF8StringPointable key) {
-        int nEntries = getDictionaryEntryCount();
-        int left = 0;
-        int right = nEntries - 1;
-        int sortedPtrArrayStart = getDictionarySortedPointerArrayOffset();
-        int dataAreaStart = getDictionaryDataAreaStartOffset();
-        while (left <= right) {
-            int mid = (left + right) / 2;
-            int sortedSlotValue = IntegerPointable.getInteger(bytes, sortedPtrArrayStart + mid * SORTED_PTR_SLOT_SIZE);
-            int strStart = dataAreaStart + sortedSlotValue;
-            int strLen = UTF8StringPointable.getUTFLen(bytes, strStart);
-            int cmp = key.compareTo(bytes, strStart, strLen + 2);
-            if (cmp > 0) {
-                left = mid + 1;
-            } else if (cmp < 0) {
-                right = mid - 1;
-            } else {
-                return IntegerPointable.getInteger(bytes, strStart + strLen + 2);
-            }
+        boolean found = binSearch.find(sortedStringVector, key);
+        if (!found) {
+            return -1;
         }
-        return -1;
+        int index = binSearch.getIndex();
+        return IntegerPointable.getInteger(bytes,
+                sortedStringVector.getStart(index) + sortedStringVector.getLength(index));
     }
 
     public void getRootNode(TaggedValuePointable node) {

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/AttributeNodeBuilder.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/AttributeNodeBuilder.java?rev=1347974&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/AttributeNodeBuilder.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/AttributeNodeBuilder.java Fri Jun  8 09:33:55 2012
@@ -0,0 +1,5 @@
+package org.apache.vxquery.datamodel.builders;
+
+public class AttributeNodeBuilder {
+
+}

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/CommentNodeBuilder.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/CommentNodeBuilder.java?rev=1347974&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/CommentNodeBuilder.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/CommentNodeBuilder.java Fri Jun  8 09:33:55 2012
@@ -0,0 +1,5 @@
+package org.apache.vxquery.datamodel.builders;
+
+public class CommentNodeBuilder {
+
+}

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/DictionaryBuilder.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/DictionaryBuilder.java?rev=1347974&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/DictionaryBuilder.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/DictionaryBuilder.java Fri Jun  8 09:33:55 2012
@@ -0,0 +1,92 @@
+package org.apache.vxquery.datamodel.builders;
+
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.apache.vxquery.util.GrowableIntArray;
+
+import edu.uci.ics.hyracks.data.std.algorithms.BinarySearchAlgorithm;
+import edu.uci.ics.hyracks.data.std.collections.api.IValueReferenceVector;
+import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
+import edu.uci.ics.hyracks.dataflow.common.comm.io.ByteArrayAccessibleOutputStream;
+
+public class DictionaryBuilder {
+    private final GrowableIntArray stringEndOffsets;
+
+    private final GrowableIntArray sortedSlotIndexes;
+
+    private final ByteArrayAccessibleOutputStream dataBuffer;
+
+    private final DataOutput dataBufferOut;
+
+    private final ByteArrayAccessibleOutputStream tempStringData;
+
+    private final DataOutput tempOut;
+
+    private final UTF8StringPointable tempStringPointable;
+
+    private final IValueReferenceVector sortedStringsVector = new IValueReferenceVector() {
+        @Override
+        public int getStart(int index) {
+            int slot = sortedSlotIndexes.getArray()[index];
+            return slot == 0 ? 0 : stringEndOffsets.getArray()[slot - 1];
+        }
+
+        @Override
+        public int getSize() {
+            return stringEndOffsets.getSize();
+        }
+
+        @Override
+        public int getLength(int index) {
+            return UTF8StringPointable.getUTFLen(dataBuffer.getByteArray(), getStart(index)) + 2;
+        }
+
+        @Override
+        public byte[] getBytes(int index) {
+            return dataBuffer.getByteArray();
+        }
+    };
+
+    private final BinarySearchAlgorithm binSearch = new BinarySearchAlgorithm();
+
+    public DictionaryBuilder() {
+        stringEndOffsets = new GrowableIntArray();
+        sortedSlotIndexes = new GrowableIntArray();
+        dataBuffer = new ByteArrayAccessibleOutputStream();
+        dataBufferOut = new DataOutputStream(dataBuffer);
+        tempStringData = new ByteArrayAccessibleOutputStream();
+        tempOut = new DataOutputStream(tempStringData);
+        tempStringPointable = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
+    }
+
+    public int lookup(String str) {
+        tempStringData.reset();
+        try {
+            tempOut.writeUTF(str);
+        } catch (IOException e) {
+            throw new IllegalStateException(e);
+        }
+        tempStringPointable.set(tempStringData.getByteArray(), 0, tempStringData.size());
+        return lookup(tempStringPointable);
+    }
+
+    public int lookup(UTF8StringPointable str) {
+        boolean found = binSearch.find(sortedStringsVector, str);
+        int index = binSearch.getIndex();
+        if (found) {
+            return sortedSlotIndexes.getArray()[index];
+        }
+        dataBuffer.write(str.getByteArray(), str.getStartOffset(), str.getLength());
+        int slotIndex = stringEndOffsets.getSize();
+        try {
+            dataBufferOut.writeInt(slotIndex);
+        } catch (IOException e) {
+            throw new IllegalStateException(e);
+        }
+        stringEndOffsets.append(dataBuffer.size());
+        sortedSlotIndexes.insert(index, slotIndex);
+        return slotIndex;
+    }
+}
\ No newline at end of file

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/ElementNodeBuilder.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/ElementNodeBuilder.java?rev=1347974&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/ElementNodeBuilder.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/ElementNodeBuilder.java Fri Jun  8 09:33:55 2012
@@ -0,0 +1,37 @@
+package org.apache.vxquery.datamodel.builders;
+
+public class ElementNodeBuilder {
+    private DictionaryBuilder db;
+
+    private int nameUriCode;
+
+    private int nameLocalNameCode;
+
+    private int namePrefixCode;
+
+    private int typeUriCode;
+
+    private int typeLocalNameCode;
+
+    private int typePrefixCode;
+
+    public void reset() {
+        db = null;
+    }
+
+    public void setDictionaryBuilder(DictionaryBuilder db) {
+        this.db = db;
+    }
+
+    public void setName(int uriCode, int localNameCode, int prefixCode) {
+        nameUriCode = uriCode;
+        nameLocalNameCode = localNameCode;
+        namePrefixCode = prefixCode;
+    }
+
+    public void setType(int uriCode, int localNameCode, int prefixCode) {
+        typeUriCode = uriCode;
+        typeLocalNameCode = localNameCode;
+        typePrefixCode = prefixCode;
+    }
+}
\ No newline at end of file

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/PINodeBuilder.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/PINodeBuilder.java?rev=1347974&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/PINodeBuilder.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/PINodeBuilder.java Fri Jun  8 09:33:55 2012
@@ -0,0 +1,5 @@
+package org.apache.vxquery.datamodel.builders;
+
+public class PINodeBuilder {
+
+}

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/TextNodeBuilder.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/TextNodeBuilder.java?rev=1347974&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/TextNodeBuilder.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/TextNodeBuilder.java Fri Jun  8 09:33:55 2012
@@ -0,0 +1,5 @@
+package org.apache.vxquery.datamodel.builders;
+
+public class TextNodeBuilder {
+
+}

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/base/IDMBuilderPool.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/base/IDMBuilderPool.java?rev=1347974&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/base/IDMBuilderPool.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/base/IDMBuilderPool.java Fri Jun  8 09:33:55 2012
@@ -0,0 +1,34 @@
+package org.apache.vxquery.datamodel.builders.base;
+
+import org.apache.vxquery.datamodel.builders.AttributeNodeBuilder;
+import org.apache.vxquery.datamodel.builders.CommentNodeBuilder;
+import org.apache.vxquery.datamodel.builders.DictionaryBuilder;
+import org.apache.vxquery.datamodel.builders.ElementNodeBuilder;
+import org.apache.vxquery.datamodel.builders.PINodeBuilder;
+import org.apache.vxquery.datamodel.builders.TextNodeBuilder;
+
+public interface IDMBuilderPool {
+    public DictionaryBuilder getDictionaryBuilder();
+
+    public void returnDictionaryBuilder(DictionaryBuilder db);
+
+    public ElementNodeBuilder getElementNodeBuilder();
+
+    public void returnElementNodeBuilder(ElementNodeBuilder enb);
+
+    public AttributeNodeBuilder getAttributeNodeBuilder();
+
+    public void returnAttributeNodeBuilder(AttributeNodeBuilder anb);
+
+    public CommentNodeBuilder getCommentNodeBuilder();
+
+    public void returnCommentNodeBuilder(CommentNodeBuilder cnb);
+
+    public TextNodeBuilder getTextNodeBuilder();
+
+    public void returnTextNodeBuilder(TextNodeBuilder tnb);
+
+    public PINodeBuilder getPINodeBuilder();
+
+    public void returnPINodeBuilder(PINodeBuilder pnb);
+}
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/drivers/VXQuery.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/drivers/VXQuery.java?rev=1347974&r1=1347973&r2=1347974&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/drivers/VXQuery.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/drivers/VXQuery.java Fri Jun  8 09:33:55 2012
@@ -40,9 +40,9 @@ import org.kohsuke.args4j.Option;
 import com.thoughtworks.xstream.XStream;
 import com.thoughtworks.xstream.io.xml.DomDriver;
 
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
 import edu.uci.ics.hyracks.algebricks.core.algebra.prettyprint.LogicalOperatorPrettyPrintVisitor;
 import edu.uci.ics.hyracks.algebricks.core.algebra.prettyprint.PlanPrettyPrinter;
-import edu.uci.ics.hyracks.algebricks.core.api.exceptions.AlgebricksException;
 
 public class VXQuery {
     public static void main(String[] args) throws Exception {
@@ -115,12 +115,15 @@ public class VXQuery {
             if (opts.compileOnly) {
                 continue;
             }
-            for (PrologVariable pVar : module.getPrologVariables()) {
-                String fName = opts.bindings.get(pVar.getVariable().getName().getLocalPart());
-                if (fName != null) {
-                    File f = new File(fName);
-                    System.err.println("Binding: " + pVar.getVariable().getName() + " to " + f.getAbsolutePath());
-                    iapi.bindExternalVariable(pVar.getVariable(), f);
+            PrologVariable[] prologVariables = module.getPrologVariables();
+            if (prologVariables != null) {
+                for (PrologVariable pVar : prologVariables) {
+                    String fName = opts.bindings.get(pVar.getVariable().getName().getLocalPart());
+                    if (fName != null) {
+                        File f = new File(fName);
+                        System.err.println("Binding: " + pVar.getVariable().getName() + " to " + f.getAbsolutePath());
+                        iapi.bindExternalVariable(pVar.getVariable(), f);
+                    }
                 }
             }
             OpenableCloseableIterator ri = iapi.execute(module);

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/functions/Function.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/functions/Function.java?rev=1347974&r1=1347973&r2=1347974&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/functions/Function.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/functions/Function.java Fri Jun  8 09:33:55 2012
@@ -62,9 +62,4 @@ public abstract class Function implement
         EXTERNAL,
         UDXQUERY,
     }
-
-    @Override
-    public Object getInfo() {
-        return null;
-    }
 }
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java?rev=1347974&r1=1347973&r2=1347974&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java Fri Jun  8 09:33:55 2012
@@ -2,85 +2,98 @@ package org.apache.vxquery.metadata;
 
 import java.util.List;
 
+import edu.uci.ics.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.common.utils.Pair;
+import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression;
 import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable;
-import edu.uci.ics.hyracks.algebricks.core.algebra.data.IPrinterFactory;
+import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+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.algebra.metadata.IDataSink;
 import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IDataSource;
 import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IDataSourceIndex;
 import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema;
-import edu.uci.ics.hyracks.algebricks.core.algebra.runtime.base.IPushRuntimeFactory;
-import edu.uci.ics.hyracks.algebricks.core.algebra.runtime.jobgen.impl.JobGenContext;
-import edu.uci.ics.hyracks.algebricks.core.api.constraints.AlgebricksPartitionConstraint;
-import edu.uci.ics.hyracks.algebricks.core.api.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.core.utils.Pair;
+import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenContext;
+import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IPushRuntimeFactory;
 import edu.uci.ics.hyracks.api.dataflow.IOperatorDescriptor;
 import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor;
 import edu.uci.ics.hyracks.api.job.JobSpecification;
 
 public class VXQueryMetadataProvider implements IMetadataProvider<String, String> {
     @Override
-    public IDataSource<String> findDataSource(String arg0) throws AlgebricksException {
+    public IDataSource<String> findDataSource(String id) throws AlgebricksException {
         return null;
     }
 
     @Override
-    public IDataSourceIndex<String, String> findDataSourceIndex(String arg0, String arg1) throws AlgebricksException {
+    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getScannerRuntime(IDataSource<String> dataSource,
+            List<LogicalVariable> scanVariables, List<LogicalVariable> projectVariables, boolean projectPushed,
+            JobGenContext context, JobSpecification jobSpec) throws AlgebricksException {
         return null;
     }
 
     @Override
-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getDeleteRuntime(IDataSource<String> arg0,
-            IOperatorSchema arg1, List<LogicalVariable> arg2, LogicalVariable arg3, RecordDescriptor arg4,
-            JobGenContext arg5, JobSpecification arg6) throws AlgebricksException {
-        return null;
+    public boolean scannerOperatorIsLeaf(IDataSource<String> dataSource) {
+        return false;
     }
 
     @Override
-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getIndexDeleteRuntime(
-            IDataSourceIndex<String, String> arg0, IOperatorSchema arg1, List<LogicalVariable> arg2,
-            List<LogicalVariable> arg3, RecordDescriptor arg4, JobGenContext arg5, JobSpecification arg6)
+    public Pair<IPushRuntimeFactory, AlgebricksPartitionConstraint> getWriteFileRuntime(IDataSink sink,
+            int[] printColumns, IPrinterFactory[] printerFactories, RecordDescriptor inputDesc)
             throws AlgebricksException {
         return null;
     }
 
     @Override
-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getIndexInsertRuntime(
-            IDataSourceIndex<String, String> arg0, IOperatorSchema arg1, List<LogicalVariable> arg2,
-            List<LogicalVariable> arg3, RecordDescriptor arg4, JobGenContext arg5, JobSpecification arg6)
-            throws AlgebricksException {
+    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getWriteResultRuntime(
+            IDataSource<String> dataSource, IOperatorSchema propagatedSchema, List<LogicalVariable> keys,
+            LogicalVariable payLoadVar, JobGenContext context, JobSpecification jobSpec) throws AlgebricksException {
+        return null;
+    }
+
+    @Override
+    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getInsertRuntime(IDataSource<String> dataSource,
+            IOperatorSchema propagatedSchema, List<LogicalVariable> keys, LogicalVariable payLoadVar,
+            RecordDescriptor recordDesc, JobGenContext context, JobSpecification jobSpec) throws AlgebricksException {
         return null;
     }
 
     @Override
-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getInsertRuntime(IDataSource<String> arg0,
-            IOperatorSchema arg1, List<LogicalVariable> arg2, LogicalVariable arg3, RecordDescriptor arg4,
-            JobGenContext arg5, JobSpecification arg6) throws AlgebricksException {
+    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getDeleteRuntime(IDataSource<String> dataSource,
+            IOperatorSchema propagatedSchema, List<LogicalVariable> keys, LogicalVariable payLoadVar,
+            RecordDescriptor recordDesc, JobGenContext context, JobSpecification jobSpec) throws AlgebricksException {
         return null;
     }
 
     @Override
-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getScannerRuntime(IDataSource<String> arg0,
-            List<LogicalVariable> arg1, List<LogicalVariable> arg2, boolean arg3, JobGenContext arg4,
-            JobSpecification arg5) throws AlgebricksException {
+    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getIndexInsertRuntime(
+            IDataSourceIndex<String, String> dataSource, IOperatorSchema propagatedSchema,
+            IOperatorSchema[] inputSchemas, IVariableTypeEnvironment typeEnv, List<LogicalVariable> primaryKeys,
+            List<LogicalVariable> secondaryKeys, ILogicalExpression filterExpr, RecordDescriptor recordDesc,
+            JobGenContext context, JobSpecification spec) throws AlgebricksException {
         return null;
     }
 
     @Override
-    public Pair<IPushRuntimeFactory, AlgebricksPartitionConstraint> getWriteFileRuntime(IDataSink arg0, int[] arg1,
-            IPrinterFactory[] arg2, RecordDescriptor arg3) throws AlgebricksException {
+    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getIndexDeleteRuntime(
+            IDataSourceIndex<String, String> dataSource, IOperatorSchema propagatedSchema,
+            IOperatorSchema[] inputSchemas, IVariableTypeEnvironment typeEnv, List<LogicalVariable> primaryKeys,
+            List<LogicalVariable> secondaryKeys, ILogicalExpression filterExpr, RecordDescriptor recordDesc,
+            JobGenContext context, JobSpecification spec) throws AlgebricksException {
         return null;
     }
 
     @Override
-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getWriteResultRuntime(IDataSource<String> arg0,
-            IOperatorSchema arg1, List<LogicalVariable> arg2, LogicalVariable arg3, JobGenContext arg4,
-            JobSpecification arg5) throws AlgebricksException {
+    public IDataSourceIndex<String, String> findDataSourceIndex(String indexId, String dataSourceId)
+            throws AlgebricksException {
         return null;
     }
 
     @Override
-    public boolean scannerOperatorIsLeaf(IDataSource<String> arg0) {
-        return false;
+    public IFunctionInfo lookupFunction(FunctionIdentifier fid) {
+        return null;
     }
 }
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeQNames.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeQNames.java?rev=1347974&r1=1347973&r2=1347974&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeQNames.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeQNames.java Fri Jun  8 09:33:55 2012
@@ -21,6 +21,14 @@ import javax.xml.namespace.QName;
 import org.apache.vxquery.xmlquery.query.XQueryConstants;
 
 public class BuiltinTypeQNames {
+    public static final String UNTYPED_STR = "untyped";
+
+    public static final String ANY_TYPE_STR = "anyType";
+
+    public static final QName XS_ANY_TYPE_QNAME = new QName(XQueryConstants.XS_NSURI, ANY_TYPE_STR,
+            XQueryConstants.XS_PREFIX);
+    public static final QName XS_UNTYPED_QNAME = new QName(XQueryConstants.XS_NSURI, UNTYPED_STR,
+            XQueryConstants.XS_PREFIX);
     public static final QName XS_ANY_ATOMIC_TYPE_QNAME = new QName(XQueryConstants.XS_NSURI, "anyAtomicType",
             XQueryConstants.XS_PREFIX);
     public static final QName XS_ANY_SIMPLE_TYPE_QNAME = new QName(XQueryConstants.XS_NSURI, "anySimpleType",

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/util/GrowableIntArray.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/util/GrowableIntArray.java?rev=1347974&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/util/GrowableIntArray.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/util/GrowableIntArray.java Fri Jun  8 09:33:55 2012
@@ -0,0 +1,68 @@
+package org.apache.vxquery.util;
+
+import java.util.Arrays;
+
+public class GrowableIntArray {
+    private static final int DEFAULT_INITIAL_CAPACITY = 16;
+
+    private static final int DEFAULT_GROWTH = 16;
+
+    private int[] array;
+
+    private int size;
+
+    public GrowableIntArray() {
+        this(DEFAULT_INITIAL_CAPACITY);
+    }
+
+    public GrowableIntArray(int initialCapacity) {
+        array = new int[initialCapacity];
+        size = 0;
+    }
+
+    public void clear() {
+        size = 0;
+    }
+
+    public int[] getArray() {
+        return array;
+    }
+
+    public int getSize() {
+        return size;
+    }
+
+    public void append(int value) {
+        if (array.length <= size) {
+            grow(DEFAULT_GROWTH);
+        }
+        array[size++] = value;
+    }
+
+    public void append(int[] inArray, int start, int length) {
+        if (array.length <= size + length) {
+            int increment = (((size + length - array.length) - 1) / DEFAULT_GROWTH + 1) * DEFAULT_GROWTH;
+            grow(increment);
+        }
+        System.arraycopy(inArray, start, array, size, length);
+        size += length;
+    }
+
+    public void insert(int index, int value) {
+        if (array.length <= size) {
+            grow(DEFAULT_GROWTH);
+        }
+        System.arraycopy(array, index, array, index + 1, size - index);
+        array[index] = value;
+    }
+
+    public void grow(int increment) {
+        if (increment < 0) {
+            throw new IllegalArgumentException(increment + " < 0");
+        }
+        if (increment == 0) {
+            return;
+        }
+        array = Arrays.copyOf(array, array.length + increment);
+    }
+}
\ No newline at end of file

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/IEventAcceptor.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/IEventAcceptor.java?rev=1347974&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/IEventAcceptor.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/IEventAcceptor.java Fri Jun  8 09:33:55 2012
@@ -0,0 +1,46 @@
+/*
+ * 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.xmlparser;
+
+import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.v0datamodel.XDMItem;
+
+public interface IEventAcceptor {
+    public void open() throws SystemException;
+
+    public void startDocument() throws SystemException;
+
+    public void endDocument() throws SystemException;
+
+    public void startElement(String uri, String localName, String prefix) throws SystemException;
+
+    public void endElement() throws SystemException;
+
+    public void namespace(String prefix, String uri) throws SystemException;
+
+    public void attribute(String uri, String localName, String prefix, String stringValue) throws SystemException;
+
+    public void text(char[] chars, int start, int length) throws SystemException;
+
+    public void comment(String content) throws SystemException;
+
+    public void pi(String target, String content) throws SystemException;
+
+    public void item(XDMItem item) throws SystemException;
+
+    public void close();
+}
\ No newline at end of file

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/ITreeNodeIdProvider.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/ITreeNodeIdProvider.java?rev=1347974&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/ITreeNodeIdProvider.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/ITreeNodeIdProvider.java Fri Jun  8 09:33:55 2012
@@ -0,0 +1,5 @@
+package org.apache.vxquery.xmlparser;
+
+public interface ITreeNodeIdProvider {
+    public int getId();
+}
\ No newline at end of file

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/NodeTreeBuildingEventAcceptor.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/NodeTreeBuildingEventAcceptor.java?rev=1347974&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/NodeTreeBuildingEventAcceptor.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/NodeTreeBuildingEventAcceptor.java Fri Jun  8 09:33:55 2012
@@ -0,0 +1,120 @@
+/*
+ * 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.xmlparser;
+
+import java.io.DataOutput;
+import java.util.ArrayList;
+
+import org.apache.vxquery.datamodel.builders.DictionaryBuilder;
+import org.apache.vxquery.datamodel.builders.ElementNodeBuilder;
+import org.apache.vxquery.datamodel.builders.base.IDMBuilderPool;
+import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.types.BuiltinTypeQNames;
+import org.apache.vxquery.v0datamodel.XDMItem;
+import org.apache.vxquery.xmlquery.query.XQueryConstants;
+
+public class NodeTreeBuildingEventAcceptor implements IEventAcceptor {
+    private final IDMBuilderPool dmBuilderPool;
+
+    private final DataOutput out;
+
+    private final boolean createNodeIds;
+
+    private final boolean attachTypes;
+
+    private DictionaryBuilder db;
+
+    private ArrayList<ElementNodeBuilder> enbStack;
+
+    public NodeTreeBuildingEventAcceptor(IDMBuilderPool dmBuilderPool, DataOutput out, boolean createNodeIds,
+            boolean attachTypes, ITreeNodeIdProvider idProvider) {
+        this.dmBuilderPool = dmBuilderPool;
+        this.out = out;
+        this.createNodeIds = createNodeIds;
+        this.attachTypes = attachTypes;
+    }
+
+    @Override
+    public void open() throws SystemException {
+    }
+
+    @Override
+    public void startDocument() throws SystemException {
+        db = dmBuilderPool.getDictionaryBuilder();
+    }
+
+    @Override
+    public void endDocument() throws SystemException {
+        dmBuilderPool.returnDictionaryBuilder(db);
+    }
+
+    @Override
+    public void startElement(String uri, String localName, String prefix) throws SystemException {
+        ElementNodeBuilder enb = dmBuilderPool.getElementNodeBuilder();
+        enb.reset();
+        int uriCode = db.lookup(uri);
+        int localNameCode = db.lookup(localName);
+        int prefixCode = db.lookup(prefix);
+        enb.setName(uriCode, localNameCode, prefixCode);
+        if (attachTypes) {
+            int typeUriCode = db.lookup(XQueryConstants.XS_NSURI);
+            int typeLocalNameCode = db.lookup(BuiltinTypeQNames.UNTYPED_STR);
+            int typePrefixCode = db.lookup(XQueryConstants.XS_PREFIX);
+            enb.setType(typeUriCode, typeLocalNameCode, typePrefixCode);
+        }
+        enbStack.add(enb);
+    }
+
+    @Override
+    public void endElement() throws SystemException {
+        ElementNodeBuilder enb = enbStack.remove(enbStack.size() - 1);
+
+    }
+
+    @Override
+    public void namespace(String prefix, String uri) throws SystemException {
+
+    }
+
+    @Override
+    public void attribute(String uri, String localName, String prefix, String stringValue) throws SystemException {
+
+    }
+
+    @Override
+    public void text(char[] chars, int start, int length) throws SystemException {
+
+    }
+
+    @Override
+    public void comment(String content) throws SystemException {
+
+    }
+
+    @Override
+    public void pi(String target, String content) throws SystemException {
+
+    }
+
+    @Override
+    public void item(XDMItem item) throws SystemException {
+
+    }
+
+    @Override
+    public void close() {
+
+    }
+}
\ No newline at end of file

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java?rev=1347974&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java Fri Jun  8 09:33:55 2012
@@ -0,0 +1,177 @@
+/*
+ * 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.xmlparser;
+
+import org.apache.vxquery.exceptions.SystemException;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+
+public class SAXContentHandler implements ContentHandler, LexicalHandler {
+    private final IEventAcceptor acceptor;
+    private final StringBuilder buffer;
+    private char[] chars;
+    private boolean pendingText;
+
+    public SAXContentHandler(IEventAcceptor acceptor) {
+        this.acceptor = acceptor;
+        buffer = new StringBuilder();
+        pendingText = false;
+    }
+
+    @Override
+    public void characters(char[] ch, int start, int length) throws SAXException {
+        buffer.append(ch, start, length);
+        pendingText = true;
+    }
+
+    @Override
+    public void endDocument() throws SAXException {
+        try {
+            flushText();
+            acceptor.endDocument();
+        } catch (SystemException e) {
+            e.printStackTrace();
+            throw new SAXException(e);
+        }
+    }
+
+    @Override
+    public void endElement(String uri, String localName, String name) throws SAXException {
+        try {
+            flushText();
+            acceptor.endElement();
+        } catch (SystemException e) {
+            e.printStackTrace();
+            throw new SAXException(e);
+        }
+    }
+
+    @Override
+    public void endPrefixMapping(String prefix) throws SAXException {
+    }
+
+    @Override
+    public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
+    }
+
+    @Override
+    public void processingInstruction(String target, String data) throws SAXException {
+        try {
+            flushText();
+            acceptor.pi(target, data);
+        } catch (SystemException e) {
+            e.printStackTrace();
+            throw new SAXException(e);
+        }
+    }
+
+    @Override
+    public void setDocumentLocator(Locator locator) {
+    }
+
+    @Override
+    public void skippedEntity(String name) throws SAXException {
+    }
+
+    @Override
+    public void startDocument() throws SAXException {
+        try {
+            flushText();
+            acceptor.startDocument();
+        } catch (SystemException e) {
+            e.printStackTrace();
+            throw new SAXException(e);
+        }
+    }
+
+    @Override
+    public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException {
+        try {
+            flushText();
+            int idx = name.indexOf(':');
+            String prefix = idx < 0 ? "" : name.substring(0, idx);
+            acceptor.startElement(uri, localName, prefix);
+            final int nAttrs = atts.getLength();
+            for (int i = 0; i < nAttrs; ++i) {
+                String aName = atts.getQName(i);
+                int aIdx = aName.indexOf(':');
+                String aPrefix = aIdx < 0 ? "" : aName.substring(0, aIdx);
+                String aLocalName = atts.getLocalName(i);
+                String aUri = atts.getURI(i);
+                String aValue = atts.getValue(i);
+                acceptor.attribute(aUri, aLocalName, aPrefix, aValue);
+            }
+        } catch (SystemException e) {
+            e.printStackTrace();
+            throw new SAXException(e);
+        }
+    }
+
+    @Override
+    public void startPrefixMapping(String prefix, String uri) throws SAXException {
+    }
+
+    @Override
+    public void comment(char[] ch, int start, int length) throws SAXException {
+        try {
+            flushText();
+            acceptor.comment(String.valueOf(ch, start, length));
+        } catch (SystemException e) {
+            e.printStackTrace();
+            throw new SAXException(e);
+        }
+    }
+
+    private void flushText() throws SystemException {
+        if (pendingText) {
+            int length = buffer.length();
+            if (chars == null || chars.length < length) {
+                chars = new char[length];
+            }
+            buffer.getChars(0, length, chars, 0);
+            acceptor.text(chars, 0, length);
+            buffer.delete(0, length);
+            pendingText = false;
+        }
+    }
+
+    @Override
+    public void endCDATA() throws SAXException {
+    }
+
+    @Override
+    public void endDTD() throws SAXException {
+    }
+
+    @Override
+    public void endEntity(String name) throws SAXException {
+    }
+
+    @Override
+    public void startCDATA() throws SAXException {
+    }
+
+    @Override
+    public void startDTD(String name, String publicId, String systemId) throws SAXException {
+    }
+
+    @Override
+    public void startEntity(String name) throws SAXException {
+    }
+
+}

Added: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java?rev=1347974&view=auto
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java (added)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java Fri Jun  8 09:33:55 2012
@@ -0,0 +1,38 @@
+/*
+ * 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.xmlparser;
+
+import org.apache.vxquery.exceptions.ErrorCode;
+import org.apache.vxquery.exceptions.SystemException;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+public class XMLParser {
+    public static void parseInputSource(InputSource in, IEventAcceptor acceptor) throws SystemException {
+        XMLReader parser;
+        try {
+            parser = XMLReaderFactory.createXMLReader();
+            SAXContentHandler handler = new SAXContentHandler(acceptor);
+            parser.setContentHandler(handler);
+            parser.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
+            acceptor.open();
+            parser.parse(in);
+            acceptor.close();
+        } catch (Exception e) {
+            throw new SystemException(ErrorCode.FODC0002, e, in.getSystemId());
+        }
+    }
+}
\ No newline at end of file

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryOptimizer.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryOptimizer.java?rev=1347974&r1=1347973&r2=1347974&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryOptimizer.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryOptimizer.java Fri Jun  8 09:33:55 2012
@@ -25,6 +25,8 @@ import org.apache.vxquery.exceptions.Err
 import org.apache.vxquery.exceptions.SystemException;
 import org.apache.vxquery.metadata.VXQueryMetadataProvider;
 
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.common.utils.Pair;
 import edu.uci.ics.hyracks.algebricks.compiler.api.HeuristicCompilerFactoryBuilder;
 import edu.uci.ics.hyracks.algebricks.compiler.api.ICompiler;
 import edu.uci.ics.hyracks.algebricks.compiler.api.ICompilerFactory;
@@ -32,14 +34,12 @@ import edu.uci.ics.hyracks.algebricks.co
 import edu.uci.ics.hyracks.algebricks.compiler.rewriter.rulecontrollers.SequentialOnceRuleController;
 import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression;
 import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalPlan;
-import edu.uci.ics.hyracks.algebricks.core.algebra.data.ISerializerDeserializerProvider;
 import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer;
 import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
 import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-import edu.uci.ics.hyracks.algebricks.core.api.exceptions.AlgebricksException;
 import edu.uci.ics.hyracks.algebricks.core.rewriter.base.AbstractRuleController;
 import edu.uci.ics.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule;
-import edu.uci.ics.hyracks.algebricks.core.utils.Pair;
+import edu.uci.ics.hyracks.algebricks.data.ISerializerDeserializerProvider;
 import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
 
 public final class XMLQueryOptimizer {

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java?rev=1347974&r1=1347973&r2=1347974&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java Fri Jun  8 09:33:55 2012
@@ -1010,7 +1010,7 @@ public class XMLQueryTranslator {
                 }
                 case ORDERBY_CLAUSE: {
                     OrderbyClauseNode ocNode = (OrderbyClauseNode) cNode;
-                    List<edu.uci.ics.hyracks.algebricks.core.utils.Pair<OrderOperator.IOrder, Mutable<ILogicalExpression>>> oExprs = new ArrayList<edu.uci.ics.hyracks.algebricks.core.utils.Pair<OrderOperator.IOrder, Mutable<ILogicalExpression>>>();
+                    List<edu.uci.ics.hyracks.algebricks.common.utils.Pair<OrderOperator.IOrder, Mutable<ILogicalExpression>>> oExprs = new ArrayList<edu.uci.ics.hyracks.algebricks.common.utils.Pair<OrderOperator.IOrder, Mutable<ILogicalExpression>>>();
                     List<String> collations = new ArrayList<String>();
                     for (OrderSpecNode osNode : ocNode.getOrderSpec()) {
                         ILogicalExpression oExpr = vre(translateExpression(osNode.getExpression(), tCtx));
@@ -1042,7 +1042,7 @@ public class XMLQueryTranslator {
                         }
                         collations.add(osNode.getCollation());
                         */
-                        oExprs.add(new edu.uci.ics.hyracks.algebricks.core.utils.Pair<OrderOperator.IOrder, Mutable<ILogicalExpression>>(
+                        oExprs.add(new edu.uci.ics.hyracks.algebricks.common.utils.Pair<OrderOperator.IOrder, Mutable<ILogicalExpression>>(
                                 o, mutable(oExpr)));
                     }
                     OrderOperator order = new OrderOperator(oExprs);