You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by pr...@apache.org on 2016/05/25 01:03:17 UTC

[01/11] vxquery git commit: Changes to classes to use UTF8StringPointable length and to use the FuncitonHelper.arrraysEqual method

Repository: vxquery
Updated Branches:
  refs/heads/master d9e8dc254 -> 2e3b83371


Changes to classes to use UTF8StringPointable length and to use the FuncitonHelper.arrraysEqual method


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

Branch: refs/heads/master
Commit: 6527a2861d88b530a9c4220ef077a84012ae4985
Parents: 7d7ab00
Author: riyafa <ri...@gmail.com>
Authored: Tue May 17 12:32:14 2016 +0530
Committer: riyafa <ri...@gmail.com>
Committed: Tue May 17 12:32:14 2016 +0530

----------------------------------------------------------------------
 .../accessors/jsonItem/ObjectPointable.java     | 121 +++++++++++++
 .../builders/jsonItem/ObjectBuilder.java        |  58 ++++++
 .../vxquery/datamodel/values/ValueTag.java      |   1 +
 .../datamodel/AbstractPointableTest.java        |   9 +-
 .../vxquery/datamodel/ObjectByteTest.java       | 181 +++++++++++++++++++
 5 files changed, 369 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/6527a286/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
new file mode 100644
index 0000000..27c2d20
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
@@ -0,0 +1,121 @@
+/*
+ * 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.datamodel.accessors.jsonItem;
+
+import java.io.IOException;
+
+import org.apache.hyracks.api.dataflow.value.ITypeTraits;
+import org.apache.hyracks.data.std.api.AbstractPointable;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.api.IPointableFactory;
+import org.apache.hyracks.data.std.primitive.IntegerPointable;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
+import org.apache.hyracks.data.std.primitive.VoidPointable;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.builders.sequence.SequenceBuilder;
+import org.apache.vxquery.exceptions.ErrorCode;
+import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.runtime.functions.util.FunctionHelper;
+
+public class ObjectPointable extends AbstractPointable {
+    public static final IPointableFactory FACTORY = new IPointableFactory() {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public ITypeTraits getTypeTraits() {
+            return VoidPointable.TYPE_TRAITS;
+        }
+
+        @Override
+        public IPointable createPointable() {
+            return new ObjectPointable();
+        }
+    };
+    private static final int ENTRY_COUNT_SIZE = 4;
+    private static final int SLOT_SIZE = 4;
+    private final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
+    private final UTF8StringPointable key1 = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
+    private final SequenceBuilder sb = new SequenceBuilder();
+
+    private static int getSlotValue(byte[] bytes, int start, int idx) {
+        return IntegerPointable.getInteger(bytes, getSlotArrayOffset(start) + idx * SLOT_SIZE);
+    }
+
+    private static int getEntryCount(byte[] bytes, int start) {
+        return IntegerPointable.getInteger(bytes, start);
+    }
+
+    private static int getKeyLength(byte[] b, int s) {
+        return UTF8StringPointable.getUTFLength(b,s+1) + 3;
+    }
+
+    private static int getSlotArrayOffset(int start) {
+        return start + ENTRY_COUNT_SIZE;
+    }
+
+    private static int getDataAreaOffset(byte[] bytes, int start) {
+        return getSlotArrayOffset(start) + getEntryCount(bytes, start) * SLOT_SIZE;
+    }
+
+    public int getEntryCount() {
+        return getEntryCount(bytes, start);
+    }
+
+    public void getKeys(IPointable result) throws SystemException {
+        try {
+            abvs.reset();
+            sb.reset(abvs);
+            int dataAreaOffset = getDataAreaOffset(bytes, start);
+            int entryCount = getEntryCount();
+            int s;
+            for (int i = 0; i < entryCount; i++) {
+                s = dataAreaOffset + getRelativeEntryStartOffset(i);
+                key1.set(bytes, s, getKeyLength(bytes, s));
+                sb.addItem(key1);
+            }
+            sb.finish();
+            result.set(abvs);
+        } catch (IOException e) {
+            throw new SystemException(ErrorCode.SYSE0001);
+        }
+    }
+
+    public void getValue(TaggedValuePointable key, IPointable pointer) {
+        int dataAreaOffset = getDataAreaOffset(bytes, start);
+        int entryCount = getEntryCount();
+        int s, l;
+        for (int i = 0; i < entryCount; i++) {
+            s = dataAreaOffset + getRelativeEntryStartOffset(i);
+            l = getKeyLength(bytes, s);
+            key1.set(bytes, s, l);
+            if (FunctionHelper.arraysEqual(key1, key)) {
+                pointer.set(bytes, s + l, getEntryLength(i) - l);
+                break;
+            }
+        }
+    }
+
+    private int getRelativeEntryStartOffset(int idx) {
+        return idx == 0 ? 0 : getSlotValue(bytes, start, idx - 1);
+    }
+
+    private int getEntryLength(int idx) {
+        return getSlotValue(bytes, start, idx) - getRelativeEntryStartOffset(idx);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/6527a286/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
new file mode 100644
index 0000000..9432ea2
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
@@ -0,0 +1,58 @@
+/*
+ * 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.datamodel.builders.jsonItem;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.hyracks.data.std.api.IMutableValueStorage;
+import org.apache.hyracks.data.std.api.IValueReference;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.util.GrowableIntArray;
+
+public class ObjectBuilder {
+    private final GrowableIntArray slots = new GrowableIntArray();
+    private final ArrayBackedValueStorage dataArea = new ArrayBackedValueStorage();
+    private IMutableValueStorage mvs;
+
+    public void reset(IMutableValueStorage mvs) {
+        this.mvs = mvs;
+        slots.clear();
+        dataArea.reset();
+    }
+
+    public void addItem(IValueReference key, IValueReference value) throws IOException {
+        dataArea.getDataOutput().write(key.getByteArray(), key.getStartOffset(), key.getLength());
+        dataArea.getDataOutput().write(value.getByteArray(), value.getStartOffset(), value.getLength());
+        slots.append(dataArea.getLength());
+    }
+
+    public void finish() throws IOException {
+        DataOutput out = mvs.getDataOutput();
+        out.write(ValueTag.OBJECT_TAG);
+        int size = slots.getSize();
+        out.writeInt(size);
+        if (size > 0) {
+            int[] slotArray = slots.getArray();
+            for (int i = 0; i < size; ++i) {
+                out.writeInt(slotArray[i]);
+            }
+            out.write(dataArea.getByteArray(), dataArea.getStartOffset(), dataArea.getLength());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/6527a286/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
index e2c89e9..7827fe1 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
@@ -82,6 +82,7 @@ public class ValueTag {
     public static final int COMMENT_NODE_TAG = 105;
     public static final int PI_NODE_TAG = 106;
     public static final int NODE_TREE_TAG = 107;
+    public static final int OBJECT_TAG=109;
 
     public static boolean isAtomic(int tag) {
         return tag < 100;

http://git-wip-us.apache.org/repos/asf/vxquery/blob/6527a286/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
index 9343465..9c2a68b 100644
--- a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
+++ b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
@@ -28,7 +28,9 @@ public class AbstractPointableTest {
 
     protected void getTaggedValuePointable(Object value, IPointable result) throws IOException {
         int start = abvsInput.getLength();
-        if (value instanceof java.lang.Long) {
+        if (value instanceof java.lang.Integer) {
+            writeInteger((Integer) value, abvsInput.getDataOutput());
+        }else if (value instanceof java.lang.Long) {
             writeLong((Long) value, abvsInput.getDataOutput());
         } else if (value instanceof java.lang.Double) {
             writeDouble((Double) value, abvsInput.getDataOutput());
@@ -38,6 +40,11 @@ public class AbstractPointableTest {
         result.set(abvsInput.getByteArray(), start, abvsInput.getLength() - start);
     }
 
+    protected void writeInteger(Integer value, DataOutput dOut) throws IOException {
+        dOut.write(ValueTag.XS_LONG_TAG);
+        dOut.writeLong(value);
+    }
+
     protected void writeLong(Long value, DataOutput dOut) throws IOException {
         dOut.write(ValueTag.XS_LONG_TAG);
         dOut.writeLong(value);

http://git-wip-us.apache.org/repos/asf/vxquery/blob/6527a286/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
new file mode 100644
index 0000000..197cd82
--- /dev/null
+++ b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
@@ -0,0 +1,181 @@
+/*
+ * 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.datamodel;
+
+import java.io.IOException;
+
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.vxquery.datamodel.accessors.SequencePointable;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.accessors.jsonItem.ObjectPointable;
+import org.apache.vxquery.datamodel.builders.jsonItem.ObjectBuilder;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.datamodel.values.XDMConstants;
+import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.runtime.functions.util.FunctionHelper;
+import org.junit.Test;
+
+import junit.framework.Assert;
+
+public class ObjectByteTest extends AbstractPointableTest {
+    ArrayBackedValueStorage abvsResult = new ArrayBackedValueStorage();
+    ObjectBuilder ob = new ObjectBuilder();
+    TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    TaggedValuePointable tvp1 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    TaggedValuePointable tvp2 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    TaggedValuePointable tvp3 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    TaggedValuePointable tvp4 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    TaggedValuePointable tvp5 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    TaggedValuePointable tvp6 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    SequencePointable sp = (SequencePointable) SequencePointable.FACTORY.createPointable();
+    ObjectPointable op = (ObjectPointable) ObjectPointable.FACTORY.createPointable();
+
+    @Test
+    public void testEmptyObject() {
+        // Build test Object
+        abvsResult.reset();
+        try {
+            ob.reset(abvsResult);
+            ob.finish();
+        } catch (IOException e) {
+            Assert.fail("Test failed to write the sequence pointable.");
+        }
+        tvp.set(abvsResult);
+
+        // Check results.
+        if (tvp.getTag() != ValueTag.OBJECT_TAG) {
+            Assert.fail("Type tag is incorrect. Expected: " + ValueTag.OBJECT_TAG + " Got: " + tvp.getTag());
+        }
+        tvp.getValue(op);
+        if (op.getEntryCount() != 0) {
+            Assert.fail("Sequence size is incorrect. Expected: 0 Got: " + op.getEntryCount());
+        }
+    }
+
+    @Test
+    public void testSingleItemObject() {
+        // Build test Object
+        abvsResult.reset();
+        try {
+            ob.reset(abvsResult);
+            getTaggedValuePointable("id", tvp1);
+            getTaggedValuePointable(1, tvp2);
+            ob.addItem(tvp1, tvp2);
+            ob.finish();
+        } catch (IOException e) {
+            Assert.fail("Test failed to write the object pointable.");
+        }
+        tvp.set(abvsResult);
+
+        // Check results.
+        if (tvp.getTag() != ValueTag.OBJECT_TAG) {
+            Assert.fail("Type tag is incorrect. Expected: " + ValueTag.OBJECT_TAG + " Got: " + tvp.getTag());
+        }
+
+        tvp.getValue(op);
+        try {
+            op.getKeys(tvp);
+        } catch (SystemException e) {
+            Assert.fail("Test failed to write the object pointable.");
+        }
+
+        if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
+            Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
+        }
+        if (!FunctionHelper.arraysEqual(tvp, tvp1)) {
+            Assert.fail("Key is incorrect.");
+        }
+
+        op.getValue(tvp1, tvp);
+        if (!FunctionHelper.arraysEqual(tvp, tvp2)) {
+            Assert.fail("Value is incorrect for the given key.");
+        }
+    }
+
+    @Test
+    public void testManyItemObject() {
+        // Build test object
+        try {
+            // Add three items
+            ob.reset(abvsResult);
+            getTaggedValuePointable("name", tvp1);
+            getTaggedValuePointable("A green door", tvp2);
+            ob.addItem(tvp1, tvp2);
+            getTaggedValuePointable("price", tvp3);
+            getTaggedValuePointable(12.5, tvp4);
+            ob.addItem(tvp3, tvp4);
+            getTaggedValuePointable("properties", tvp5);
+            getTaggedValuePointable(100l, tvp6);
+            ob.addItem(tvp5, tvp6);
+            ob.finish();
+        } catch (IOException e) {
+            Assert.fail("Test failed to write the object pointable.");
+        }
+        tvp.set(abvsResult);
+
+        // Check results.
+        if (tvp.getTag() != ValueTag.OBJECT_TAG) {
+            Assert.fail("Type tag is incorrect. Expected: " + ValueTag.SEQUENCE_TAG + " Got: " + tvp.getTag());
+        }
+        tvp.getValue(op);
+        if (op.getEntryCount() != 3) {
+            Assert.fail("Object size is incorrect. Expected: 3 Got: " + op.getEntryCount());
+        }
+
+        //Test keys
+        try {
+            op.getKeys(tvp);
+        } catch (SystemException e) {
+            Assert.fail("Test failed to write the object pointable.");
+        }
+
+        if (tvp.getTag() != ValueTag.SEQUENCE_TAG) {
+            Assert.fail("Sequence tag is incorrect. Expected: " + ValueTag.SEQUENCE_TAG + " Got: " + tvp.getTag());
+        }
+        tvp.getValue(sp);
+        if (sp.getEntryCount() != 3) {
+            Assert.fail("Sequence size is incorrect. Expected: 3 Got: " + sp.getEntryCount());
+        }
+        sp.getEntry(0, tvp);
+        if (!FunctionHelper.arraysEqual(tvp, tvp1)) {
+            Assert.fail("Sequence item one is incorrect. Expected: " + ValueTag.XS_LONG_TAG + " Got: " + tvp.getTag());
+        }
+        sp.getEntry(1, tvp);
+        if (!FunctionHelper.arraysEqual(tvp, tvp3)) {
+            Assert.fail(
+                    "Sequence item two is incorrect. Expected: " + ValueTag.XS_DOUBLE_TAG + " Got: " + tvp.getTag());
+        }
+        sp.getEntry(2, tvp);
+        if (!FunctionHelper.arraysEqual(tvp, tvp5)) {
+            Assert.fail(
+                    "Sequence item three is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
+        }
+
+        //Test values
+        op.getValue(tvp1, tvp);
+        if (!FunctionHelper.arraysEqual(tvp, tvp2)) {
+            Assert.fail("Value is incorrect for the given key.");
+        }
+        op.getValue(tvp3, tvp);
+        if (!FunctionHelper.arraysEqual(tvp, tvp4)) {
+            Assert.fail("Value is incorrect for the given key.");
+        }
+        op.getValue(tvp5, tvp);
+        if (!FunctionHelper.arraysEqual(tvp, tvp6)) {
+            Assert.fail("Value is incorrect for the given key.");
+        }
+    }
+
+}


[08/11] vxquery git commit: Changes to sequence Pointable and retaining old ObjectByteTest

Posted by pr...@apache.org.
Changes to sequence Pointable and retaining old ObjectByteTest


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

Branch: refs/heads/master
Commit: b28fc195a0d49f37c3618e57752764daca2f0c44
Parents: e8afa64
Author: riyafa <ri...@gmail.com>
Authored: Thu May 19 09:02:40 2016 +0530
Committer: riyafa <ri...@gmail.com>
Committed: Thu May 19 09:02:40 2016 +0530

----------------------------------------------------------------------
 .../datamodel/accessors/SequencePointable.java  | 38 ++++++++++----------
 .../vxquery/datamodel/ObjectByteTest.java       | 15 +++++---
 2 files changed, 30 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/b28fc195/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
index d1b7dd8..9ccac0b 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
@@ -24,6 +24,8 @@ import org.apache.hyracks.data.std.primitive.IntegerPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
 
 public class SequencePointable extends AbstractPointable {
+    private static final int ENTRY_COUNT_SIZE = IntegerPointable.TYPE_TRAITS.getFixedLength();
+    private static final int SLOT_SIZE = IntegerPointable.TYPE_TRAITS.getFixedLength();
     public static final IPointableFactory FACTORY = new IPointableFactory() {
         private static final long serialVersionUID = 1L;
 
@@ -37,39 +39,29 @@ public class SequencePointable extends AbstractPointable {
             return new SequencePointable();
         }
     };
-    private static final int ENTRY_COUNT_SIZE = IntegerPointable.TYPE_TRAITS.getFixedLength();
-    private static final int SLOT_SIZE = IntegerPointable.TYPE_TRAITS.getFixedLength();
 
     public static int getSequenceLength(byte[] bytes, int start) {
         int entryCount = getEntryCount(bytes, start);
         return getSlotValue(bytes, start, entryCount - 1) + (getDataAreaOffset(bytes, start) - start);
     }
 
-    private static int getEntryCount(byte[] bytes, int start) {
-        return IntegerPointable.getInteger(bytes, start);
-    }
-
-    private static int getSlotValue(byte[] bytes, int start, int idx) {
-        return IntegerPointable.getInteger(bytes, getSlotArrayOffset(start) + idx * SLOT_SIZE);
-    }
-
-    private static int getSlotArrayOffset(int start) {
-        return start + ENTRY_COUNT_SIZE;
-    }
-
-    private static int getDataAreaOffset(byte[] bytes, int start) {
-        return getSlotArrayOffset(start) + getEntryCount(bytes, start) * SLOT_SIZE;
-    }
-
     public int getEntryCount() {
         return getEntryCount(bytes, start);
     }
 
+    private static int getEntryCount(byte[] bytes, int start) {
+        return IntegerPointable.getInteger(bytes, start);
+    }
+
     public void getEntry(int idx, IPointable pointer) {
         int dataAreaOffset = getDataAreaOffset(bytes, start);
         pointer.set(bytes, dataAreaOffset + getRelativeEntryStartOffset(idx), getEntryLength(idx));
     }
 
+    private static int getSlotValue(byte[] bytes, int start, int idx) {
+        return IntegerPointable.getInteger(bytes, getSlotArrayOffset(start) + idx * SLOT_SIZE);
+    }
+
     private int getRelativeEntryStartOffset(int idx) {
         return idx == 0 ? 0 : getSlotValue(bytes, start, idx - 1);
     }
@@ -77,4 +69,12 @@ public class SequencePointable extends AbstractPointable {
     private int getEntryLength(int idx) {
         return getSlotValue(bytes, start, idx) - getRelativeEntryStartOffset(idx);
     }
-}
+
+    private static int getSlotArrayOffset(int start) {
+        return start + ENTRY_COUNT_SIZE;
+    }
+
+    private static int getDataAreaOffset(byte[] bytes, int start) {
+        return getSlotArrayOffset(start) + getEntryCount(bytes, start) * SLOT_SIZE;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/b28fc195/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
index e55706e..2bf95c1 100644
--- a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
+++ b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
@@ -16,6 +16,7 @@ package org.apache.vxquery.datamodel;
 
 import java.io.IOException;
 
+import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.vxquery.datamodel.accessors.SequencePointable;
@@ -95,7 +96,7 @@ public class ObjectByteTest extends AbstractPointableTest {
         if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
             Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
         }
-        if (tvpKey1.compareTo(tvp) < 0) {
+        if (!compareKeys(tvp, tvpKey1)) {
             Assert.fail("Key is incorrect. Expected: id");
         }
 
@@ -156,21 +157,21 @@ public class ObjectByteTest extends AbstractPointableTest {
         if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
             Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
         }
-        if (tvpKey1.compareTo(tvp) < 0) {
+        if (!compareKeys(tvp, tvpKey1)) {
             Assert.fail("Object key one is incorrect. Expected: name");
         }
         sp.getEntry(1, tvp);
         if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
             Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
         }
-        if (tvpKey2.compareTo(tvp) < 0) {
+        if (!compareKeys(tvp, tvpKey2)) {
             Assert.fail("Object key two is incorrect. Expected: price");
         }
         sp.getEntry(2, tvp);
         if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
             Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
         }
-        if (tvpKey3.compareTo(tvp) < 0) {
+        if (!compareKeys(tvp, tvpKey3)) {
             Assert.fail("Object key three is incorrect. Expected: properties");
         }
 
@@ -252,4 +253,10 @@ public class ObjectByteTest extends AbstractPointableTest {
             Assert.fail("Test failed to write the object pointable.");
         }
     }
+
+    private boolean compareKeys(IPointable tvp1, IPointable tvp2) {
+
+        return FunctionHelper.arraysEqual(tvp1.getByteArray(), tvp1.getStartOffset() + 1, tvp1.getLength() - 1,
+                tvp2.getByteArray(), tvp2.getStartOffset(), tvp2.getLength());
+    }
 }


[03/11] vxquery git commit: Added comments on the object datamodel and further improvements

Posted by pr...@apache.org.
Added comments on the object datamodel and further improvements


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

Branch: refs/heads/master
Commit: 131295d1c87c1cc392683b20d8fa6a89ed6a8b2a
Parents: 18a301e
Author: riyafa <ri...@gmail.com>
Authored: Tue May 17 14:48:20 2016 +0530
Committer: riyafa <ri...@gmail.com>
Committed: Tue May 17 14:48:20 2016 +0530

----------------------------------------------------------------------
 .../accessors/jsonItem/ObjectPointable.java     | 21 ++++++++++++++------
 .../datamodel/AbstractPointableTest.java        |  4 ++--
 .../vxquery/datamodel/ObjectByteTest.java       | 13 +++++++-----
 3 files changed, 25 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/131295d1/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
index b8cf83b..039d8cd 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
@@ -32,6 +32,14 @@ import org.apache.vxquery.exceptions.ErrorCode;
 import org.apache.vxquery.exceptions.SystemException;
 import org.apache.vxquery.runtime.functions.util.FunctionHelper;
 
+/**
+ * The datamodel of the JSON object is represented in this class:
+ * Byte 1: Value tag of object (109)
+ * Byte 2 to 5: number of key-value pairs in the object
+ * Next few bytes: Offsets for each key-value pair in the object in the order appearing in the json data
+ * Next bytes: The keys in the object each followed by the value of the key. Each key is a StringPointable and the value
+ * of the key will be the respective pointable starting with its valuetag.
+ */
 public class ObjectPointable extends AbstractPointable {
     public static final IPointableFactory FACTORY = new IPointableFactory() {
         private static final long serialVersionUID = 1L;
@@ -72,10 +80,6 @@ public class ObjectPointable extends AbstractPointable {
         return getSlotArrayOffset(start) + getEntryCount(bytes, start) * SLOT_SIZE;
     }
 
-    public int getEntryCount() {
-        return getEntryCount(bytes, start);
-    }
-
     public void getKeys(IPointable result) throws SystemException {
         try {
             abvs.reset();
@@ -95,7 +99,7 @@ public class ObjectPointable extends AbstractPointable {
         }
     }
 
-    public void getValue(TaggedValuePointable key, TaggedValuePointable pointer) {
+    public void getValue(TaggedValuePointable key, TaggedValuePointable result) {
         int dataAreaOffset = getDataAreaOffset(bytes, start);
         int entryCount = getEntryCount();
         int s, l;
@@ -104,9 +108,10 @@ public class ObjectPointable extends AbstractPointable {
             l = getKeyLength(bytes, s);
             key1.set(bytes, s, l);
             if (FunctionHelper.arraysEqual(key1, key)) {
-                pointer.set(bytes, s + l, getEntryLength(i) - l);
+                result.set(bytes, s + l, getEntryLength(i) - l);
                 break;
             }
+            //Todo: if no key found return null
         }
     }
 
@@ -118,4 +123,8 @@ public class ObjectPointable extends AbstractPointable {
         return getSlotValue(bytes, start, idx) - getRelativeEntryStartOffset(idx);
     }
 
+    public int getEntryCount() {
+        return getEntryCount(bytes, start);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/131295d1/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
index d186c10..28ef372 100644
--- a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
+++ b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
@@ -41,8 +41,8 @@ public class AbstractPointableTest {
     }
 
     protected void writeInteger(Integer value, DataOutput dOut) throws IOException {
-        dOut.write(ValueTag.XS_LONG_TAG);
-        dOut.writeLong(value);
+        dOut.write(ValueTag.XS_INT_TAG);
+        dOut.writeInt(value);
     }
 
     protected void writeLong(Long value, DataOutput dOut) throws IOException {

http://git-wip-us.apache.org/repos/asf/vxquery/blob/131295d1/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
index 2b2e676..eb29134 100644
--- a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
+++ b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
@@ -129,7 +129,7 @@ public class ObjectByteTest extends AbstractPointableTest {
 
         // Check results.
         if (tvp.getTag() != ValueTag.OBJECT_TAG) {
-            Assert.fail("Type tag is incorrect. Expected: " + ValueTag.SEQUENCE_TAG + " Got: " + tvp.getTag());
+            Assert.fail("Type tag is incorrect. Expected: " + ValueTag.OBJECT_TAG + " Got: " + tvp.getTag());
         }
         tvp.getValue(op);
         if (op.getEntryCount() != 3) {
@@ -144,7 +144,7 @@ public class ObjectByteTest extends AbstractPointableTest {
         }
 
         if (tvp.getTag() != ValueTag.SEQUENCE_TAG) {
-            Assert.fail("Object tag is incorrect. Expected: " + ValueTag.SEQUENCE_TAG + " Got: " + tvp.getTag());
+            Assert.fail("Tag type is incorrect. Expected: " + ValueTag.SEQUENCE_TAG + " Got: " + tvp.getTag());
         }
         tvp.getValue(sp);
         if (sp.getEntryCount() != 3) {
@@ -166,15 +166,18 @@ public class ObjectByteTest extends AbstractPointableTest {
         //Test values
         op.getValue(tvp1, tvp);
         if (!FunctionHelper.arraysEqual(tvp, tvp2)) {
-            Assert.fail("Value is incorrect for the given key. Expected: A green door");
+            Assert.fail("Value is incorrect for the given key. Expected: A green door with valuetag: "
+                    + ValueTag.XS_STRING_TAG + " Got valuetag: " + tvp.getTag());
         }
         op.getValue(tvp3, tvp);
         if (!FunctionHelper.arraysEqual(tvp, tvp4)) {
-            Assert.fail("Value is incorrect for the given key. Expected: 12.5");
+            Assert.fail("Value is incorrect for the given key. Expected: 12.5 with valuetag: " + ValueTag.XS_DOUBLE_TAG
+                    + " Got valuetag: " + tvp.getTag());
         }
         op.getValue(tvp5, tvp);
         if (!FunctionHelper.arraysEqual(tvp, tvp6)) {
-            Assert.fail("Value is incorrect for the given key. Expected: 100");
+            Assert.fail("Value is incorrect for the given key. Expected: 100 with valuetag: " + ValueTag.XS_LONG_TAG
+                    + " Got valuetag: " + tvp.getTag());
         }
     }
 


[11/11] vxquery git commit: JSON object builder, pointable and unit tests.

Posted by pr...@apache.org.
JSON object builder, pointable and unit tests.


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

Branch: refs/heads/master
Commit: 2e3b833713b62d98e7072b1cdf1aa23e2439f9d5
Parents: d9e8dc2 3fd8053
Author: Preston Carman <pr...@apache.org>
Authored: Tue May 24 18:02:52 2016 -0700
Committer: Preston Carman <pr...@apache.org>
Committed: Tue May 24 18:02:52 2016 -0700

----------------------------------------------------------------------
 .../datamodel/accessors/SequencePointable.java  |   6 +-
 .../accessors/jsonItem/ObjectPointable.java     | 124 +++++++++
 .../builders/jsonItem/ObjectBuilder.java        |  66 +++++
 .../builders/sequence/SequenceBuilder.java      |   6 +
 .../vxquery/datamodel/values/ValueTag.java      |   3 +
 .../vxquery/datamodel/values/XDMConstants.java  |  20 +-
 .../vxquery/types/BuiltinTypeConstants.java     |   4 +-
 .../datamodel/AbstractPointableTest.java        |  22 +-
 .../vxquery/datamodel/ObjectByteTest.java       | 264 +++++++++++++++++++
 9 files changed, 501 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/2e3b8337/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/sequence/SequenceBuilder.java
----------------------------------------------------------------------
diff --cc vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/sequence/SequenceBuilder.java
index 5cd31b1,a5ca065..e347818
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/sequence/SequenceBuilder.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/sequence/SequenceBuilder.java
@@@ -42,7 -42,14 +42,13 @@@ public class SequenceBuilder implement
          slots.append(dataArea.getLength());
      }
  
+     public void addItem(int tagValue, IValueReference p) throws IOException {
+         dataArea.getDataOutput().write(tagValue);
+         dataArea.getDataOutput().write(p.getByteArray(), p.getStartOffset(), p.getLength());
+         slots.append(dataArea.getLength());
+     }
+ 
      public void finish() throws IOException {
 -        DataOutput out = mvs.getDataOutput();
          if (slots.getSize() != 1) {
              out.write(ValueTag.SEQUENCE_TAG);
              int size = slots.getSize();

http://git-wip-us.apache.org/repos/asf/vxquery/blob/2e3b8337/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
----------------------------------------------------------------------
diff --cc vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
index d2c8a9b,5600283..2e4d5c7
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
@@@ -82,7 -84,7 +84,8 @@@ public class ValueTag 
      public static final int COMMENT_NODE_TAG = 105;
      public static final int PI_NODE_TAG = 106;
      public static final int NODE_TREE_TAG = 107;
 +    public static final int ARRAY_TAG = 108;
+     public static final int OBJECT_TAG = 109;
  
      public static boolean isAtomic(int tag) {
          return tag < 100;

http://git-wip-us.apache.org/repos/asf/vxquery/blob/2e3b8337/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
----------------------------------------------------------------------


[07/11] vxquery git commit: Use comapareTo method of string pointable

Posted by pr...@apache.org.
Use comapareTo method of string pointable


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

Branch: refs/heads/master
Commit: e8afa6464d1857d3ad0f24980ec1a93963f33eb2
Parents: 98cc0f8
Author: riyafa <ri...@gmail.com>
Authored: Thu May 19 08:39:08 2016 +0530
Committer: riyafa <ri...@gmail.com>
Committed: Thu May 19 08:39:08 2016 +0530

----------------------------------------------------------------------
 .../org/apache/vxquery/datamodel/ObjectByteTest.java  | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/e8afa646/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
index 41694e8..e55706e 100644
--- a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
+++ b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
@@ -16,7 +16,6 @@ package org.apache.vxquery.datamodel;
 
 import java.io.IOException;
 
-import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.vxquery.datamodel.accessors.SequencePointable;
@@ -96,7 +95,7 @@ public class ObjectByteTest extends AbstractPointableTest {
         if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
             Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
         }
-        if (!compareKeys(tvp, tvpKey1)) {
+        if (tvpKey1.compareTo(tvp) < 0) {
             Assert.fail("Key is incorrect. Expected: id");
         }
 
@@ -157,21 +156,21 @@ public class ObjectByteTest extends AbstractPointableTest {
         if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
             Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
         }
-        if (!compareKeys(tvp, tvpKey1)) {
+        if (tvpKey1.compareTo(tvp) < 0) {
             Assert.fail("Object key one is incorrect. Expected: name");
         }
         sp.getEntry(1, tvp);
         if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
             Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
         }
-        if (!compareKeys(tvp, tvpKey2)) {
+        if (tvpKey2.compareTo(tvp) < 0) {
             Assert.fail("Object key two is incorrect. Expected: price");
         }
         sp.getEntry(2, tvp);
         if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
             Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
         }
-        if (!compareKeys(tvp, tvpKey3)) {
+        if (tvpKey3.compareTo(tvp) < 0) {
             Assert.fail("Object key three is incorrect. Expected: properties");
         }
 
@@ -253,9 +252,4 @@ public class ObjectByteTest extends AbstractPointableTest {
             Assert.fail("Test failed to write the object pointable.");
         }
     }
-
-    public boolean compareKeys(IPointable tvp1, IPointable tvp2) {
-        return FunctionHelper.arraysEqual(tvp1.getByteArray(), tvp1.getStartOffset() + 1, tvp1.getLength() - 1,
-                tvp2.getByteArray(), tvp2.getStartOffset(), tvp2.getLength());
-    }
 }


[05/11] vxquery git commit: Changes made: Remove all notions of tags out of the object pointable and builder Changed SLOT_SIZE constant The getValue method of pointable returns boolean Define JS_NULL_CONSTANT

Posted by pr...@apache.org.
Changes made:
Remove all notions of tags out of the object pointable and builder
Changed SLOT_SIZE constant
The getValue method of pointable returns boolean
Define JS_NULL_CONSTANT


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

Branch: refs/heads/master
Commit: 5ec28cba8a7eb83dcfac12c0d455c0c1574d03e7
Parents: a0f01bd
Author: riyafa <ri...@gmail.com>
Authored: Thu May 19 05:51:05 2016 +0530
Committer: riyafa <ri...@gmail.com>
Committed: Thu May 19 05:51:05 2016 +0530

----------------------------------------------------------------------
 .../datamodel/accessors/SequencePointable.java  | 36 ++++----
 .../accessors/jsonItem/ObjectPointable.java     | 73 +++++-----------
 .../builders/jsonItem/ObjectBuilder.java        |  5 +-
 .../vxquery/datamodel/values/ValueTag.java      |  2 +-
 .../vxquery/datamodel/values/XDMConstants.java  | 20 +++--
 .../vxquery/types/BuiltinTypeConstants.java     |  2 +-
 .../datamodel/AbstractPointableTest.java        | 22 ++++-
 .../vxquery/datamodel/ObjectByteTest.java       | 89 +++++++++-----------
 8 files changed, 115 insertions(+), 134 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
index 0aa66f7..d1b7dd8 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
@@ -24,8 +24,6 @@ import org.apache.hyracks.data.std.primitive.IntegerPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
 
 public class SequencePointable extends AbstractPointable {
-    private static final int ENTRY_COUNT_SIZE = 4;
-    private static final int SLOT_SIZE = 4;
     public static final IPointableFactory FACTORY = new IPointableFactory() {
         private static final long serialVersionUID = 1L;
 
@@ -39,29 +37,39 @@ public class SequencePointable extends AbstractPointable {
             return new SequencePointable();
         }
     };
+    private static final int ENTRY_COUNT_SIZE = IntegerPointable.TYPE_TRAITS.getFixedLength();
+    private static final int SLOT_SIZE = IntegerPointable.TYPE_TRAITS.getFixedLength();
 
     public static int getSequenceLength(byte[] bytes, int start) {
         int entryCount = getEntryCount(bytes, start);
         return getSlotValue(bytes, start, entryCount - 1) + (getDataAreaOffset(bytes, start) - start);
     }
 
-    public int getEntryCount() {
-        return getEntryCount(bytes, start);
-    }
-
     private static int getEntryCount(byte[] bytes, int start) {
         return IntegerPointable.getInteger(bytes, start);
     }
 
+    private static int getSlotValue(byte[] bytes, int start, int idx) {
+        return IntegerPointable.getInteger(bytes, getSlotArrayOffset(start) + idx * SLOT_SIZE);
+    }
+
+    private static int getSlotArrayOffset(int start) {
+        return start + ENTRY_COUNT_SIZE;
+    }
+
+    private static int getDataAreaOffset(byte[] bytes, int start) {
+        return getSlotArrayOffset(start) + getEntryCount(bytes, start) * SLOT_SIZE;
+    }
+
+    public int getEntryCount() {
+        return getEntryCount(bytes, start);
+    }
+
     public void getEntry(int idx, IPointable pointer) {
         int dataAreaOffset = getDataAreaOffset(bytes, start);
         pointer.set(bytes, dataAreaOffset + getRelativeEntryStartOffset(idx), getEntryLength(idx));
     }
 
-    private static int getSlotValue(byte[] bytes, int start, int idx) {
-        return IntegerPointable.getInteger(bytes, getSlotArrayOffset(start) + idx * SLOT_SIZE);
-    }
-
     private int getRelativeEntryStartOffset(int idx) {
         return idx == 0 ? 0 : getSlotValue(bytes, start, idx - 1);
     }
@@ -69,12 +77,4 @@ public class SequencePointable extends AbstractPointable {
     private int getEntryLength(int idx) {
         return getSlotValue(bytes, start, idx) - getRelativeEntryStartOffset(idx);
     }
-
-    private static int getSlotArrayOffset(int start) {
-        return start + ENTRY_COUNT_SIZE;
-    }
-
-    private static int getDataAreaOffset(byte[] bytes, int start) {
-        return getSlotArrayOffset(start) + getEntryCount(bytes, start) * SLOT_SIZE;
-    }
 }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
index 5b2e264..3aadee3 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
@@ -16,7 +16,6 @@
  */
 package org.apache.vxquery.datamodel.accessors.jsonItem;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.hyracks.api.dataflow.value.ITypeTraits;
@@ -27,13 +26,8 @@ import org.apache.hyracks.data.std.primitive.IntegerPointable;
 import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
-import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
-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.datamodel.builders.sequence.SequenceBuilder;
 import org.apache.vxquery.runtime.functions.util.FunctionHelper;
-import org.apache.vxquery.util.GrowableIntArray;
 
 /**
  * The datamodel of the JSON object is represented in this class:
@@ -58,10 +52,10 @@ public class ObjectPointable extends AbstractPointable {
         }
     };
     private static final int ENTRY_COUNT_SIZE = IntegerPointable.TYPE_TRAITS.getFixedLength();
-    private static final int SLOT_SIZE = 4;
+    private static final int SLOT_SIZE = IntegerPointable.TYPE_TRAITS.getFixedLength();
     private final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
-    private final GrowableIntArray slots = new GrowableIntArray();
-    private final ArrayBackedValueStorage dataArea = new ArrayBackedValueStorage();
+    private final SequenceBuilder sb = new SequenceBuilder();
+    private final UTF8StringPointable key1 = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
 
     private static int getSlotValue(byte[] bytes, int start, int idx) {
         return IntegerPointable.getInteger(bytes, getSlotArrayOffset(start) + idx * SLOT_SIZE);
@@ -83,61 +77,34 @@ public class ObjectPointable extends AbstractPointable {
         return getSlotArrayOffset(start) + getEntryCount(bytes, start) * SLOT_SIZE;
     }
 
-    public void getKeys(IPointable result) throws SystemException {
-        try {
-            abvs.reset();
-            slots.clear();
-            dataArea.reset();
-            int dataAreaOffset = getDataAreaOffset(bytes, start);
-            int entryCount = getEntryCount();
-            int s;
-            for (int i = 0; i < entryCount; i++) {
-                s = dataAreaOffset + getRelativeEntryStartOffset(i);
-                dataArea.getDataOutput().write(ValueTag.XS_STRING_TAG);
-                dataArea.getDataOutput().write(bytes, s, getKeyLength(bytes, s));
-                slots.append(dataArea.getLength());
-            }
-            finishSequenceBuild();
-            result.set(abvs);
-        } catch (IOException e) {
-            throw new SystemException(ErrorCode.SYSE0001);
-        }
-    }
-
-    private void finishSequenceBuild() throws IOException {
-        DataOutput out = abvs.getDataOutput();
-        if (slots.getSize() != 1) {
-            out.write(ValueTag.SEQUENCE_TAG);
-            int size = slots.getSize();
-            out.writeInt(size);
-            if (size > 0) {
-                int[] slotArray = slots.getArray();
-                for (int i = 0; i < size; ++i) {
-                    out.writeInt(slotArray[i]);
-                }
-                out.write(dataArea.getByteArray(), dataArea.getStartOffset(), dataArea.getLength());
-            }
-        } else {
-            out.write(dataArea.getByteArray(), dataArea.getStartOffset(), dataArea.getLength());
+    public void getKeys(IPointable result) throws IOException {
+        abvs.reset();
+        sb.reset(abvs);
+        int dataAreaOffset = getDataAreaOffset(bytes, start);
+        int entryCount = getEntryCount();
+        int s;
+        for (int i = 0; i < entryCount; i++) {
+            s = dataAreaOffset + getRelativeEntryStartOffset(i);
+            key1.set(bytes, s, getKeyLength(bytes, s));
+            sb.addItem(key1);
         }
+        sb.finish();
+        result.set(abvs);
     }
 
-    public void getValue(TaggedValuePointable key, TaggedValuePointable result) throws SystemException {
+    public boolean getValue(UTF8StringPointable key, IPointable result) {
         int dataAreaOffset = getDataAreaOffset(bytes, start);
         int entryCount = getEntryCount();
         int s, l, i;
         for (i = 0; i < entryCount; i++) {
             s = dataAreaOffset + getRelativeEntryStartOffset(i);
             l = getKeyLength(bytes, s);
-            if (FunctionHelper.arraysEqual(bytes, s, l, key.getByteArray(), key.getStartOffset() + 1,
-                    key.getLength() - 1)) {
+            if (FunctionHelper.arraysEqual(bytes, s, l, key.getByteArray(), key.getStartOffset(), key.getLength())) {
                 result.set(bytes, s + l, getEntryLength(i) - l);
-                return;
+                return true;
             }
         }
-        if (entryCount == 0 || i == entryCount) {
-            XDMConstants.setFalse(result);
-        }
+        return false;
     }
 
     private int getRelativeEntryStartOffset(int idx) {

http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
index 8f49198..f4b7649 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 
 import org.apache.hyracks.data.std.api.IMutableValueStorage;
 import org.apache.hyracks.data.std.api.IValueReference;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.vxquery.datamodel.builders.base.AbstractBuilder;
 import org.apache.vxquery.datamodel.builders.base.IBuilder;
@@ -43,8 +44,8 @@ public class ObjectBuilder extends AbstractBuilder implements IBuilder {
         return ValueTag.OBJECT_TAG;
     }
 
-    public void addItem(IValueReference key, IValueReference value) throws IOException {
-        dataArea.getDataOutput().write(key.getByteArray(), key.getStartOffset() + 1, key.getLength() - 1);
+    public void addItem(UTF8StringPointable key, IValueReference value) throws IOException {
+        dataArea.getDataOutput().write(key.getByteArray(), key.getStartOffset(), key.getLength());
         dataArea.getDataOutput().write(value.getByteArray(), value.getStartOffset(), value.getLength());
         slots.append(dataArea.getLength());
     }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
index 1f6ddc7..5600283 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
@@ -74,7 +74,7 @@ public class ValueTag {
     public static final int XS_NMTOKENS_TAG = BuiltinTypeConstants.XS_NMTOKENS_TYPE_ID;
     public static final int XS_ENTITIES_TAG = BuiltinTypeConstants.XS_ENTITIES_TYPE_ID;
 
-    public static final int JS_NULL_TAG = BuiltinTypeConstants.JS_NULL_ID;
+    public static final int JS_NULL_TAG = BuiltinTypeConstants.JS_NULL_TYPE_ID;
 
     public static final int SEQUENCE_TAG = 100;
     public static final int DOCUMENT_NODE_TAG = 101;

http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/XDMConstants.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/XDMConstants.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/XDMConstants.java
index bc058c7..3dc7e9e 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/XDMConstants.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/XDMConstants.java
@@ -19,11 +19,10 @@ package org.apache.vxquery.datamodel.values;
 import java.io.IOException;
 import java.util.Arrays;
 
-import org.apache.vxquery.datamodel.builders.sequence.SequenceBuilder;
-
 import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.BooleanPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.vxquery.datamodel.builders.sequence.SequenceBuilder;
 
 public class XDMConstants {
     private static final byte[] BOOLEAN_TRUE_CONSTANT;
@@ -34,6 +33,8 @@ public class XDMConstants {
 
     private static final byte[] EMPTY_STRING;
 
+    private static final byte[] JS_NULL_CONSTANT;
+
     static {
         BOOLEAN_TRUE_CONSTANT = new byte[2];
         BOOLEAN_TRUE_CONSTANT[0] = ValueTag.XS_BOOLEAN_TAG;
@@ -52,11 +53,17 @@ public class XDMConstants {
             throw new RuntimeException(e);
         }
         EMPTY_SEQUENCE = Arrays.copyOf(abvs.getByteArray(), abvs.getLength());
-        
+
         EMPTY_STRING = new byte[3];
         EMPTY_STRING[0] = ValueTag.XS_STRING_TAG;
         EMPTY_STRING[1] = 0;
         EMPTY_STRING[2] = 0;
+
+        JS_NULL_CONSTANT = new byte[1];
+        JS_NULL_CONSTANT[0] = ValueTag.JS_NULL_TAG;
+    }
+
+    private XDMConstants() {
     }
 
     public static void setTrue(IPointable p) {
@@ -75,10 +82,11 @@ public class XDMConstants {
         set(p, EMPTY_STRING);
     }
 
-    private static void set(IPointable p, byte[] array) {
-        p.set(array, 0, array.length);
+    public static void setJsNull(IPointable p) {
+        set(p, JS_NULL_CONSTANT);
     }
 
-    private XDMConstants() {
+    private static void set(IPointable p, byte[] array) {
+        p.set(array, 0, array.length);
     }
 }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java b/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java
index 79894a9..5ac51ec 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java
@@ -72,7 +72,7 @@ public class BuiltinTypeConstants {
     public static final int XS_NMTOKENS_TYPE_ID = 50;
     public static final int XS_ENTITIES_TYPE_ID = 51;
 
-    public static final int JS_NULL_ID = 52;
+    public static final int JS_NULL_TYPE_ID = 52;
 
     public static final int BUILTIN_TYPE_COUNT = 53;
 }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
index 28ef372..7360703 100644
--- a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
+++ b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
@@ -25,6 +25,7 @@ import org.apache.vxquery.datamodel.values.ValueTag;
 public class AbstractPointableTest {
     private final ArrayBackedValueStorage abvsInput = new ArrayBackedValueStorage();
     private final StringValueBuilder svb = new StringValueBuilder();
+    private boolean includeTag = true;
 
     protected void getTaggedValuePointable(Object value, IPointable result) throws IOException {
         int start = abvsInput.getLength();
@@ -40,23 +41,36 @@ public class AbstractPointableTest {
         result.set(abvsInput.getByteArray(), start, abvsInput.getLength() - start);
     }
 
+    protected void getTaggedValuePointable(Object value, boolean includeTag, IPointable result) throws IOException {
+        this.includeTag = includeTag;
+        getTaggedValuePointable(value, result);
+    }
+
     protected void writeInteger(Integer value, DataOutput dOut) throws IOException {
-        dOut.write(ValueTag.XS_INT_TAG);
+        if (includeTag) {
+            dOut.write(ValueTag.XS_INT_TAG);
+        }
         dOut.writeInt(value);
     }
 
     protected void writeLong(Long value, DataOutput dOut) throws IOException {
-        dOut.write(ValueTag.XS_LONG_TAG);
+        if (includeTag) {
+            dOut.write(ValueTag.XS_LONG_TAG);
+        }
         dOut.writeLong(value);
     }
 
     protected void writeDouble(Double value, DataOutput dOut) throws IOException {
-        dOut.write(ValueTag.XS_DOUBLE_TAG);
+        if (includeTag) {
+            dOut.write(ValueTag.XS_DOUBLE_TAG);
+        }
         dOut.writeDouble(value);
     }
 
     protected void writeString(String value, DataOutput dOut) throws IOException {
-        dOut.write(ValueTag.XS_STRING_TAG);
+        if (includeTag) {
+            dOut.write(ValueTag.XS_STRING_TAG);
+        }
         svb.write(value, dOut);
     }
 

http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
index fd9310f..ff05c24 100644
--- a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
+++ b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
@@ -16,14 +16,13 @@ package org.apache.vxquery.datamodel;
 
 import java.io.IOException;
 
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.vxquery.datamodel.accessors.SequencePointable;
 import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
 import org.apache.vxquery.datamodel.accessors.jsonItem.ObjectPointable;
 import org.apache.vxquery.datamodel.builders.jsonItem.ObjectBuilder;
 import org.apache.vxquery.datamodel.values.ValueTag;
-import org.apache.vxquery.datamodel.values.XDMConstants;
-import org.apache.vxquery.exceptions.SystemException;
 import org.apache.vxquery.runtime.functions.util.FunctionHelper;
 import org.junit.Test;
 
@@ -33,11 +32,11 @@ public class ObjectByteTest extends AbstractPointableTest {
     private ArrayBackedValueStorage abvsResult = new ArrayBackedValueStorage();
     private ObjectBuilder ob = new ObjectBuilder();
     private TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
-    private TaggedValuePointable tvpKey1 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    private UTF8StringPointable tvpKey1 = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
     private TaggedValuePointable tvpValue1 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
-    private TaggedValuePointable tvpKey2 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    private UTF8StringPointable tvpKey2 = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
     private TaggedValuePointable tvpValue2 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
-    private TaggedValuePointable tvpKey3 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    private UTF8StringPointable tvpKey3 = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
     private TaggedValuePointable tvpValue3 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
     private SequencePointable sp = (SequencePointable) SequencePointable.FACTORY.createPointable();
     private ObjectPointable op = (ObjectPointable) ObjectPointable.FACTORY.createPointable();
@@ -70,7 +69,7 @@ public class ObjectByteTest extends AbstractPointableTest {
         abvsResult.reset();
         try {
             ob.reset(abvsResult);
-            getTaggedValuePointable("id", tvpKey1);
+            getTaggedValuePointable("id", false, tvpKey1);
             getTaggedValuePointable(1, tvpValue1);
             ob.addItem(tvpKey1, tvpValue1);
             ob.finish();
@@ -90,23 +89,20 @@ public class ObjectByteTest extends AbstractPointableTest {
         }
         try {
             op.getKeys(tvp);
-        } catch (SystemException e) {
+        } catch (IOException e) {
             Assert.fail("Test failed to write the object pointable.");
         }
 
-        if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
-            Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
-        }
         if (!FunctionHelper.arraysEqual(tvp, tvpKey1)) {
             Assert.fail("Key is incorrect. Expected: id");
         }
-        try {
-            op.getValue(tvpKey1, tvp);
-        } catch (SystemException e) {
-            Assert.fail("Test failed to write the object pointable.");
+
+        if (!op.getValue(tvpKey1, tvp)) {
+            Assert.fail("Value not found for the given key:id");
         }
         if (!FunctionHelper.arraysEqual(tvp, tvpValue1)) {
-            Assert.fail("Value is incorrect for the given key.");
+            Assert.fail("Value is incorrect for the given key. Expected: 1 with valuetag: " + ValueTag.XS_INT_TAG
+                    + " Got valuetag: " + tvp.getTag());
         }
     }
 
@@ -116,13 +112,13 @@ public class ObjectByteTest extends AbstractPointableTest {
         try {
             // Add three items
             ob.reset(abvsResult);
-            getTaggedValuePointable("name", tvpKey1);
+            getTaggedValuePointable("name", false, tvpKey1);
             getTaggedValuePointable("A green door", tvpValue1);
             ob.addItem(tvpKey1, tvpValue1);
-            getTaggedValuePointable("price", tvpKey2);
+            getTaggedValuePointable("price", false, tvpKey2);
             getTaggedValuePointable(12.5, tvpValue2);
             ob.addItem(tvpKey2, tvpValue2);
-            getTaggedValuePointable("properties", tvpKey3);
+            getTaggedValuePointable("properties", false, tvpKey3);
             getTaggedValuePointable(100L, tvpValue3);
             ob.addItem(tvpKey3, tvpValue3);
             ob.finish();
@@ -143,7 +139,7 @@ public class ObjectByteTest extends AbstractPointableTest {
         //Test keys
         try {
             op.getKeys(tvp);
-        } catch (SystemException e) {
+        } catch (IOException e) {
             Assert.fail("Test failed to write the object pointable.");
         }
 
@@ -168,28 +164,24 @@ public class ObjectByteTest extends AbstractPointableTest {
         }
 
         //Test values
-        try {
-            op.getValue(tvpKey1, tvp);
-        } catch (SystemException e) {
-            Assert.fail("Test failed to write the object pointable.");
+        if (!op.getValue(tvpKey1, tvp)) {
+            Assert.fail("Value not found for the given key: name");
         }
         if (!FunctionHelper.arraysEqual(tvp, tvpValue1)) {
             Assert.fail("Value is incorrect for the given key. Expected: A green door with valuetag: "
                     + ValueTag.XS_STRING_TAG + " Got valuetag: " + tvp.getTag());
         }
-        try {
-            op.getValue(tvpKey2, tvp);
-        } catch (SystemException e) {
-            Assert.fail("Test failed to write the object pointable.");
+
+        if (!op.getValue(tvpKey2, tvp)) {
+            Assert.fail("Value not found for the given key: price");
         }
         if (!FunctionHelper.arraysEqual(tvp, tvpValue2)) {
             Assert.fail("Value is incorrect for the given key. Expected: 12.5 with valuetag: " + ValueTag.XS_DOUBLE_TAG
                     + " Got valuetag: " + tvp.getTag());
         }
-        try {
-            op.getValue(tvpKey3, tvp);
-        } catch (SystemException e) {
-            Assert.fail("Test failed to write the object pointable.");
+
+        if (!op.getValue(tvpKey3, tvp)) {
+            Assert.fail("Value not found for the given key: properties");
         }
         if (!FunctionHelper.arraysEqual(tvp, tvpValue3)) {
             Assert.fail("Value is incorrect for the given key. Expected: 100 with valuetag: " + ValueTag.XS_LONG_TAG
@@ -210,25 +202,23 @@ public class ObjectByteTest extends AbstractPointableTest {
         tvp.set(abvsResult);
         tvp.getValue(op);
         try {
-            getTaggedValuePointable("key", tvpKey1);
-            op.getValue(tvpKey1, tvpValue1);
-        } catch (IOException | SystemException e) {
+            getTaggedValuePointable("key", false, tvpKey1);
+            if (op.getValue(tvpKey1, tvp)) {
+                Assert.fail("key not in object. Expected: false Got: true");
+            }
+        } catch (IOException e) {
             Assert.fail("Test failed to write the object pointable.");
         }
-        XDMConstants.setFalse(tvp);
-        if (!FunctionHelper.arraysEqual(tvp, tvpValue1)) {
-            Assert.fail("Value is incorrect for the given key. Expected: false with valuetag: "
-                    + ValueTag.XS_BOOLEAN_TAG + " Got valuetag: " + tvp.getTag());
-        }
 
         // Build test object
         try {
             // Add two items
+            abvsResult.reset();
             ob.reset(abvsResult);
-            getTaggedValuePointable("name", tvpKey1);
+            getTaggedValuePointable("name", false, tvpKey1);
             getTaggedValuePointable("A green door", tvpValue1);
             ob.addItem(tvpKey1, tvpValue1);
-            getTaggedValuePointable("price", tvpKey2);
+            getTaggedValuePointable("price", false, tvpKey2);
             getTaggedValuePointable(12.5, tvpValue2);
             ob.addItem(tvpKey2, tvpValue2);
             ob.finish();
@@ -239,15 +229,16 @@ public class ObjectByteTest extends AbstractPointableTest {
         tvp.set(abvsResult);
         tvp.getValue(op);
         try {
-            getTaggedValuePointable("key", tvpKey3);
-            op.getValue(tvpKey3, tvpValue3);
-        } catch (IOException | SystemException e) {
+            getTaggedValuePointable("key", false, tvpKey3);
+            if (op.getValue(tvpKey3, tvp)) {
+                Assert.fail("key not in object. Expected: false Got: true");
+            }
+
+            if (!op.getValue(tvpKey1, tvp)) {
+                Assert.fail("key in object. Expected: true Got: false");
+            }
+        } catch (IOException e) {
             Assert.fail("Test failed to write the object pointable.");
         }
-        XDMConstants.setFalse(tvp);
-        if (!FunctionHelper.arraysEqual(tvp, tvpValue3)) {
-            Assert.fail("Value is incorrect for the given key. Expected: false with valuetag: "
-                    + ValueTag.XS_BOOLEAN_TAG + " Got valuetag: " + tvp.getTag());
-        }
     }
 }


[02/11] vxquery git commit: Further changes to the test class and the formatting. And getValues method returns a taggedvaluepointable

Posted by pr...@apache.org.
Further changes to the test class and the formatting. And getValues method returns a taggedvaluepointable


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

Branch: refs/heads/master
Commit: 18a301e982f6f20be310708fa31b1021608515a5
Parents: 6527a28
Author: riyafa <ri...@gmail.com>
Authored: Tue May 17 12:53:58 2016 +0530
Committer: riyafa <ri...@gmail.com>
Committed: Tue May 17 12:53:58 2016 +0530

----------------------------------------------------------------------
 .../accessors/jsonItem/ObjectPointable.java     |  4 +--
 .../vxquery/datamodel/values/ValueTag.java      |  2 +-
 .../datamodel/AbstractPointableTest.java        |  2 +-
 .../vxquery/datamodel/ObjectByteTest.java       | 28 ++++++++++----------
 4 files changed, 18 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/18a301e9/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
index 27c2d20..b8cf83b 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
@@ -61,7 +61,7 @@ public class ObjectPointable extends AbstractPointable {
     }
 
     private static int getKeyLength(byte[] b, int s) {
-        return UTF8StringPointable.getUTFLength(b,s+1) + 3;
+        return UTF8StringPointable.getUTFLength(b, s + 1) + 3;
     }
 
     private static int getSlotArrayOffset(int start) {
@@ -95,7 +95,7 @@ public class ObjectPointable extends AbstractPointable {
         }
     }
 
-    public void getValue(TaggedValuePointable key, IPointable pointer) {
+    public void getValue(TaggedValuePointable key, TaggedValuePointable pointer) {
         int dataAreaOffset = getDataAreaOffset(bytes, start);
         int entryCount = getEntryCount();
         int s, l;

http://git-wip-us.apache.org/repos/asf/vxquery/blob/18a301e9/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
index 7827fe1..c464bc5 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
@@ -82,7 +82,7 @@ public class ValueTag {
     public static final int COMMENT_NODE_TAG = 105;
     public static final int PI_NODE_TAG = 106;
     public static final int NODE_TREE_TAG = 107;
-    public static final int OBJECT_TAG=109;
+    public static final int OBJECT_TAG = 109;
 
     public static boolean isAtomic(int tag) {
         return tag < 100;

http://git-wip-us.apache.org/repos/asf/vxquery/blob/18a301e9/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
index 9c2a68b..d186c10 100644
--- a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
+++ b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
@@ -30,7 +30,7 @@ public class AbstractPointableTest {
         int start = abvsInput.getLength();
         if (value instanceof java.lang.Integer) {
             writeInteger((Integer) value, abvsInput.getDataOutput());
-        }else if (value instanceof java.lang.Long) {
+        } else if (value instanceof java.lang.Long) {
             writeLong((Long) value, abvsInput.getDataOutput());
         } else if (value instanceof java.lang.Double) {
             writeDouble((Double) value, abvsInput.getDataOutput());

http://git-wip-us.apache.org/repos/asf/vxquery/blob/18a301e9/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
index 197cd82..2b2e676 100644
--- a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
+++ b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
@@ -22,7 +22,6 @@ import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
 import org.apache.vxquery.datamodel.accessors.jsonItem.ObjectPointable;
 import org.apache.vxquery.datamodel.builders.jsonItem.ObjectBuilder;
 import org.apache.vxquery.datamodel.values.ValueTag;
-import org.apache.vxquery.datamodel.values.XDMConstants;
 import org.apache.vxquery.exceptions.SystemException;
 import org.apache.vxquery.runtime.functions.util.FunctionHelper;
 import org.junit.Test;
@@ -50,7 +49,7 @@ public class ObjectByteTest extends AbstractPointableTest {
             ob.reset(abvsResult);
             ob.finish();
         } catch (IOException e) {
-            Assert.fail("Test failed to write the sequence pointable.");
+            Assert.fail("Test failed to write the Object pointable.");
         }
         tvp.set(abvsResult);
 
@@ -60,7 +59,7 @@ public class ObjectByteTest extends AbstractPointableTest {
         }
         tvp.getValue(op);
         if (op.getEntryCount() != 0) {
-            Assert.fail("Sequence size is incorrect. Expected: 0 Got: " + op.getEntryCount());
+            Assert.fail("Object size is incorrect. Expected: 0 Got: " + op.getEntryCount());
         }
     }
 
@@ -85,6 +84,9 @@ public class ObjectByteTest extends AbstractPointableTest {
         }
 
         tvp.getValue(op);
+        if (op.getEntryCount() != 1) {
+            Assert.fail("Object size is incorrect. Expected: 1 Got: " + op.getEntryCount());
+        }
         try {
             op.getKeys(tvp);
         } catch (SystemException e) {
@@ -95,7 +97,7 @@ public class ObjectByteTest extends AbstractPointableTest {
             Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
         }
         if (!FunctionHelper.arraysEqual(tvp, tvp1)) {
-            Assert.fail("Key is incorrect.");
+            Assert.fail("Key is incorrect. Expected: id");
         }
 
         op.getValue(tvp1, tvp);
@@ -142,39 +144,37 @@ public class ObjectByteTest extends AbstractPointableTest {
         }
 
         if (tvp.getTag() != ValueTag.SEQUENCE_TAG) {
-            Assert.fail("Sequence tag is incorrect. Expected: " + ValueTag.SEQUENCE_TAG + " Got: " + tvp.getTag());
+            Assert.fail("Object tag is incorrect. Expected: " + ValueTag.SEQUENCE_TAG + " Got: " + tvp.getTag());
         }
         tvp.getValue(sp);
         if (sp.getEntryCount() != 3) {
-            Assert.fail("Sequence size is incorrect. Expected: 3 Got: " + sp.getEntryCount());
+            Assert.fail("Object size is incorrect. Expected: 3 Got: " + sp.getEntryCount());
         }
         sp.getEntry(0, tvp);
         if (!FunctionHelper.arraysEqual(tvp, tvp1)) {
-            Assert.fail("Sequence item one is incorrect. Expected: " + ValueTag.XS_LONG_TAG + " Got: " + tvp.getTag());
+            Assert.fail("Object key one is incorrect. Expected: name");
         }
         sp.getEntry(1, tvp);
         if (!FunctionHelper.arraysEqual(tvp, tvp3)) {
-            Assert.fail(
-                    "Sequence item two is incorrect. Expected: " + ValueTag.XS_DOUBLE_TAG + " Got: " + tvp.getTag());
+            Assert.fail("Object key two is incorrect. Expected: price");
         }
         sp.getEntry(2, tvp);
         if (!FunctionHelper.arraysEqual(tvp, tvp5)) {
-            Assert.fail(
-                    "Sequence item three is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
+            Assert.fail("Object key three is incorrect. Expected: properties");
         }
 
         //Test values
         op.getValue(tvp1, tvp);
         if (!FunctionHelper.arraysEqual(tvp, tvp2)) {
-            Assert.fail("Value is incorrect for the given key.");
+            Assert.fail("Value is incorrect for the given key. Expected: A green door");
         }
         op.getValue(tvp3, tvp);
         if (!FunctionHelper.arraysEqual(tvp, tvp4)) {
-            Assert.fail("Value is incorrect for the given key.");
+            Assert.fail("Value is incorrect for the given key. Expected: 12.5");
         }
         op.getValue(tvp5, tvp);
         if (!FunctionHelper.arraysEqual(tvp, tvp6)) {
-            Assert.fail("Value is incorrect for the given key.");
+            Assert.fail("Value is incorrect for the given key. Expected: 100");
         }
     }
 


[04/11] vxquery git commit: Changes in this commit: ENTRY_COUNT_SIZE takes its size from IntegerPointable Removed string tag for key and custom built it Return false for the getValue if value for the given key don't exist Changed the pointable names in t

Posted by pr...@apache.org.
Changes in this commit:
ENTRY_COUNT_SIZE takes its size from IntegerPointable
Removed string tag for key and custom built it
Return false for the getValue if value for the given key don't exist
Changed the pointable names in the tests
Added js:null


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

Branch: refs/heads/master
Commit: a0f01bd0c4e60c73ebab1720bafb17f79aee8231
Parents: 131295d
Author: riyafa <ri...@gmail.com>
Authored: Wed May 18 12:15:21 2016 +0530
Committer: riyafa <ri...@gmail.com>
Committed: Wed May 18 12:15:21 2016 +0530

----------------------------------------------------------------------
 .../accessors/jsonItem/ObjectPointable.java     |  57 +++++---
 .../builders/jsonItem/ObjectBuilder.java        |  11 +-
 .../vxquery/datamodel/values/ValueTag.java      |   2 +
 .../vxquery/types/BuiltinTypeConstants.java     |   4 +-
 .../vxquery/datamodel/ObjectByteTest.java       | 141 ++++++++++++++-----
 5 files changed, 160 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/a0f01bd0/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
index 039d8cd..5b2e264 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
@@ -16,6 +16,7 @@
  */
 package org.apache.vxquery.datamodel.accessors.jsonItem;
 
+import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.hyracks.api.dataflow.value.ITypeTraits;
@@ -27,10 +28,12 @@ import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
-import org.apache.vxquery.datamodel.builders.sequence.SequenceBuilder;
+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.util.FunctionHelper;
+import org.apache.vxquery.util.GrowableIntArray;
 
 /**
  * The datamodel of the JSON object is represented in this class:
@@ -54,11 +57,11 @@ public class ObjectPointable extends AbstractPointable {
             return new ObjectPointable();
         }
     };
-    private static final int ENTRY_COUNT_SIZE = 4;
+    private static final int ENTRY_COUNT_SIZE = IntegerPointable.TYPE_TRAITS.getFixedLength();
     private static final int SLOT_SIZE = 4;
     private final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
-    private final UTF8StringPointable key1 = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
-    private final SequenceBuilder sb = new SequenceBuilder();
+    private final GrowableIntArray slots = new GrowableIntArray();
+    private final ArrayBackedValueStorage dataArea = new ArrayBackedValueStorage();
 
     private static int getSlotValue(byte[] bytes, int start, int idx) {
         return IntegerPointable.getInteger(bytes, getSlotArrayOffset(start) + idx * SLOT_SIZE);
@@ -69,7 +72,7 @@ public class ObjectPointable extends AbstractPointable {
     }
 
     private static int getKeyLength(byte[] b, int s) {
-        return UTF8StringPointable.getUTFLength(b, s + 1) + 3;
+        return UTF8StringPointable.getUTFLength(b, s) + 2;
     }
 
     private static int getSlotArrayOffset(int start) {
@@ -83,35 +86,57 @@ public class ObjectPointable extends AbstractPointable {
     public void getKeys(IPointable result) throws SystemException {
         try {
             abvs.reset();
-            sb.reset(abvs);
+            slots.clear();
+            dataArea.reset();
             int dataAreaOffset = getDataAreaOffset(bytes, start);
             int entryCount = getEntryCount();
             int s;
             for (int i = 0; i < entryCount; i++) {
                 s = dataAreaOffset + getRelativeEntryStartOffset(i);
-                key1.set(bytes, s, getKeyLength(bytes, s));
-                sb.addItem(key1);
+                dataArea.getDataOutput().write(ValueTag.XS_STRING_TAG);
+                dataArea.getDataOutput().write(bytes, s, getKeyLength(bytes, s));
+                slots.append(dataArea.getLength());
             }
-            sb.finish();
+            finishSequenceBuild();
             result.set(abvs);
         } catch (IOException e) {
             throw new SystemException(ErrorCode.SYSE0001);
         }
     }
 
-    public void getValue(TaggedValuePointable key, TaggedValuePointable result) {
+    private void finishSequenceBuild() throws IOException {
+        DataOutput out = abvs.getDataOutput();
+        if (slots.getSize() != 1) {
+            out.write(ValueTag.SEQUENCE_TAG);
+            int size = slots.getSize();
+            out.writeInt(size);
+            if (size > 0) {
+                int[] slotArray = slots.getArray();
+                for (int i = 0; i < size; ++i) {
+                    out.writeInt(slotArray[i]);
+                }
+                out.write(dataArea.getByteArray(), dataArea.getStartOffset(), dataArea.getLength());
+            }
+        } else {
+            out.write(dataArea.getByteArray(), dataArea.getStartOffset(), dataArea.getLength());
+        }
+    }
+
+    public void getValue(TaggedValuePointable key, TaggedValuePointable result) throws SystemException {
         int dataAreaOffset = getDataAreaOffset(bytes, start);
         int entryCount = getEntryCount();
-        int s, l;
-        for (int i = 0; i < entryCount; i++) {
+        int s, l, i;
+        for (i = 0; i < entryCount; i++) {
             s = dataAreaOffset + getRelativeEntryStartOffset(i);
             l = getKeyLength(bytes, s);
-            key1.set(bytes, s, l);
-            if (FunctionHelper.arraysEqual(key1, key)) {
+            if (FunctionHelper.arraysEqual(bytes, s, l, key.getByteArray(), key.getStartOffset() + 1,
+                    key.getLength() - 1)) {
                 result.set(bytes, s + l, getEntryLength(i) - l);
-                break;
+                return;
             }
-            //Todo: if no key found return null
+        }
+        if (entryCount == 0 || i == entryCount) {
+            XDMConstants.setFalse(result);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/vxquery/blob/a0f01bd0/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
index 9432ea2..8f49198 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
@@ -22,10 +22,12 @@ import java.io.IOException;
 import org.apache.hyracks.data.std.api.IMutableValueStorage;
 import org.apache.hyracks.data.std.api.IValueReference;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.vxquery.datamodel.builders.base.AbstractBuilder;
+import org.apache.vxquery.datamodel.builders.base.IBuilder;
 import org.apache.vxquery.datamodel.values.ValueTag;
 import org.apache.vxquery.util.GrowableIntArray;
 
-public class ObjectBuilder {
+public class ObjectBuilder extends AbstractBuilder implements IBuilder {
     private final GrowableIntArray slots = new GrowableIntArray();
     private final ArrayBackedValueStorage dataArea = new ArrayBackedValueStorage();
     private IMutableValueStorage mvs;
@@ -36,8 +38,13 @@ public class ObjectBuilder {
         dataArea.reset();
     }
 
+    @Override
+    public int getValueTag() {
+        return ValueTag.OBJECT_TAG;
+    }
+
     public void addItem(IValueReference key, IValueReference value) throws IOException {
-        dataArea.getDataOutput().write(key.getByteArray(), key.getStartOffset(), key.getLength());
+        dataArea.getDataOutput().write(key.getByteArray(), key.getStartOffset() + 1, key.getLength() - 1);
         dataArea.getDataOutput().write(value.getByteArray(), value.getStartOffset(), value.getLength());
         slots.append(dataArea.getLength());
     }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/a0f01bd0/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
index c464bc5..1f6ddc7 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
@@ -74,6 +74,8 @@ public class ValueTag {
     public static final int XS_NMTOKENS_TAG = BuiltinTypeConstants.XS_NMTOKENS_TYPE_ID;
     public static final int XS_ENTITIES_TAG = BuiltinTypeConstants.XS_ENTITIES_TYPE_ID;
 
+    public static final int JS_NULL_TAG = BuiltinTypeConstants.JS_NULL_ID;
+
     public static final int SEQUENCE_TAG = 100;
     public static final int DOCUMENT_NODE_TAG = 101;
     public static final int ELEMENT_NODE_TAG = 102;

http://git-wip-us.apache.org/repos/asf/vxquery/blob/a0f01bd0/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java b/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java
index eefebcc..79894a9 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java
@@ -72,5 +72,7 @@ public class BuiltinTypeConstants {
     public static final int XS_NMTOKENS_TYPE_ID = 50;
     public static final int XS_ENTITIES_TYPE_ID = 51;
 
-    public static final int BUILTIN_TYPE_COUNT = 52;
+    public static final int JS_NULL_ID = 52;
+
+    public static final int BUILTIN_TYPE_COUNT = 53;
 }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/a0f01bd0/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
index eb29134..fd9310f 100644
--- a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
+++ b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
@@ -22,6 +22,7 @@ import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
 import org.apache.vxquery.datamodel.accessors.jsonItem.ObjectPointable;
 import org.apache.vxquery.datamodel.builders.jsonItem.ObjectBuilder;
 import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.datamodel.values.XDMConstants;
 import org.apache.vxquery.exceptions.SystemException;
 import org.apache.vxquery.runtime.functions.util.FunctionHelper;
 import org.junit.Test;
@@ -29,17 +30,17 @@ import org.junit.Test;
 import junit.framework.Assert;
 
 public class ObjectByteTest extends AbstractPointableTest {
-    ArrayBackedValueStorage abvsResult = new ArrayBackedValueStorage();
-    ObjectBuilder ob = new ObjectBuilder();
-    TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
-    TaggedValuePointable tvp1 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
-    TaggedValuePointable tvp2 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
-    TaggedValuePointable tvp3 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
-    TaggedValuePointable tvp4 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
-    TaggedValuePointable tvp5 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
-    TaggedValuePointable tvp6 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
-    SequencePointable sp = (SequencePointable) SequencePointable.FACTORY.createPointable();
-    ObjectPointable op = (ObjectPointable) ObjectPointable.FACTORY.createPointable();
+    private ArrayBackedValueStorage abvsResult = new ArrayBackedValueStorage();
+    private ObjectBuilder ob = new ObjectBuilder();
+    private TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    private TaggedValuePointable tvpKey1 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    private TaggedValuePointable tvpValue1 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    private TaggedValuePointable tvpKey2 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    private TaggedValuePointable tvpValue2 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    private TaggedValuePointable tvpKey3 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    private TaggedValuePointable tvpValue3 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    private SequencePointable sp = (SequencePointable) SequencePointable.FACTORY.createPointable();
+    private ObjectPointable op = (ObjectPointable) ObjectPointable.FACTORY.createPointable();
 
     @Test
     public void testEmptyObject() {
@@ -69,9 +70,9 @@ public class ObjectByteTest extends AbstractPointableTest {
         abvsResult.reset();
         try {
             ob.reset(abvsResult);
-            getTaggedValuePointable("id", tvp1);
-            getTaggedValuePointable(1, tvp2);
-            ob.addItem(tvp1, tvp2);
+            getTaggedValuePointable("id", tvpKey1);
+            getTaggedValuePointable(1, tvpValue1);
+            ob.addItem(tvpKey1, tvpValue1);
             ob.finish();
         } catch (IOException e) {
             Assert.fail("Test failed to write the object pointable.");
@@ -96,12 +97,15 @@ public class ObjectByteTest extends AbstractPointableTest {
         if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
             Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
         }
-        if (!FunctionHelper.arraysEqual(tvp, tvp1)) {
+        if (!FunctionHelper.arraysEqual(tvp, tvpKey1)) {
             Assert.fail("Key is incorrect. Expected: id");
         }
-
-        op.getValue(tvp1, tvp);
-        if (!FunctionHelper.arraysEqual(tvp, tvp2)) {
+        try {
+            op.getValue(tvpKey1, tvp);
+        } catch (SystemException e) {
+            Assert.fail("Test failed to write the object pointable.");
+        }
+        if (!FunctionHelper.arraysEqual(tvp, tvpValue1)) {
             Assert.fail("Value is incorrect for the given key.");
         }
     }
@@ -112,15 +116,15 @@ public class ObjectByteTest extends AbstractPointableTest {
         try {
             // Add three items
             ob.reset(abvsResult);
-            getTaggedValuePointable("name", tvp1);
-            getTaggedValuePointable("A green door", tvp2);
-            ob.addItem(tvp1, tvp2);
-            getTaggedValuePointable("price", tvp3);
-            getTaggedValuePointable(12.5, tvp4);
-            ob.addItem(tvp3, tvp4);
-            getTaggedValuePointable("properties", tvp5);
-            getTaggedValuePointable(100l, tvp6);
-            ob.addItem(tvp5, tvp6);
+            getTaggedValuePointable("name", tvpKey1);
+            getTaggedValuePointable("A green door", tvpValue1);
+            ob.addItem(tvpKey1, tvpValue1);
+            getTaggedValuePointable("price", tvpKey2);
+            getTaggedValuePointable(12.5, tvpValue2);
+            ob.addItem(tvpKey2, tvpValue2);
+            getTaggedValuePointable("properties", tvpKey3);
+            getTaggedValuePointable(100L, tvpValue3);
+            ob.addItem(tvpKey3, tvpValue3);
             ob.finish();
         } catch (IOException e) {
             Assert.fail("Test failed to write the object pointable.");
@@ -151,34 +155,99 @@ public class ObjectByteTest extends AbstractPointableTest {
             Assert.fail("Object size is incorrect. Expected: 3 Got: " + sp.getEntryCount());
         }
         sp.getEntry(0, tvp);
-        if (!FunctionHelper.arraysEqual(tvp, tvp1)) {
+        if (!FunctionHelper.arraysEqual(tvp, tvpKey1)) {
             Assert.fail("Object key one is incorrect. Expected: name");
         }
         sp.getEntry(1, tvp);
-        if (!FunctionHelper.arraysEqual(tvp, tvp3)) {
+        if (!FunctionHelper.arraysEqual(tvp, tvpKey2)) {
             Assert.fail("Object key two is incorrect. Expected: price");
         }
         sp.getEntry(2, tvp);
-        if (!FunctionHelper.arraysEqual(tvp, tvp5)) {
+        if (!FunctionHelper.arraysEqual(tvp, tvpKey3)) {
             Assert.fail("Object key three is incorrect. Expected: properties");
         }
 
         //Test values
-        op.getValue(tvp1, tvp);
-        if (!FunctionHelper.arraysEqual(tvp, tvp2)) {
+        try {
+            op.getValue(tvpKey1, tvp);
+        } catch (SystemException e) {
+            Assert.fail("Test failed to write the object pointable.");
+        }
+        if (!FunctionHelper.arraysEqual(tvp, tvpValue1)) {
             Assert.fail("Value is incorrect for the given key. Expected: A green door with valuetag: "
                     + ValueTag.XS_STRING_TAG + " Got valuetag: " + tvp.getTag());
         }
-        op.getValue(tvp3, tvp);
-        if (!FunctionHelper.arraysEqual(tvp, tvp4)) {
+        try {
+            op.getValue(tvpKey2, tvp);
+        } catch (SystemException e) {
+            Assert.fail("Test failed to write the object pointable.");
+        }
+        if (!FunctionHelper.arraysEqual(tvp, tvpValue2)) {
             Assert.fail("Value is incorrect for the given key. Expected: 12.5 with valuetag: " + ValueTag.XS_DOUBLE_TAG
                     + " Got valuetag: " + tvp.getTag());
         }
-        op.getValue(tvp5, tvp);
-        if (!FunctionHelper.arraysEqual(tvp, tvp6)) {
+        try {
+            op.getValue(tvpKey3, tvp);
+        } catch (SystemException e) {
+            Assert.fail("Test failed to write the object pointable.");
+        }
+        if (!FunctionHelper.arraysEqual(tvp, tvpValue3)) {
             Assert.fail("Value is incorrect for the given key. Expected: 100 with valuetag: " + ValueTag.XS_LONG_TAG
                     + " Got valuetag: " + tvp.getTag());
         }
     }
 
+    @Test
+    public void testItemNotExistObject() {
+        // Build empty test Object
+        abvsResult.reset();
+        try {
+            ob.reset(abvsResult);
+            ob.finish();
+        } catch (IOException e) {
+            Assert.fail("Test failed to write the Object pointable.");
+        }
+        tvp.set(abvsResult);
+        tvp.getValue(op);
+        try {
+            getTaggedValuePointable("key", tvpKey1);
+            op.getValue(tvpKey1, tvpValue1);
+        } catch (IOException | SystemException e) {
+            Assert.fail("Test failed to write the object pointable.");
+        }
+        XDMConstants.setFalse(tvp);
+        if (!FunctionHelper.arraysEqual(tvp, tvpValue1)) {
+            Assert.fail("Value is incorrect for the given key. Expected: false with valuetag: "
+                    + ValueTag.XS_BOOLEAN_TAG + " Got valuetag: " + tvp.getTag());
+        }
+
+        // Build test object
+        try {
+            // Add two items
+            ob.reset(abvsResult);
+            getTaggedValuePointable("name", tvpKey1);
+            getTaggedValuePointable("A green door", tvpValue1);
+            ob.addItem(tvpKey1, tvpValue1);
+            getTaggedValuePointable("price", tvpKey2);
+            getTaggedValuePointable(12.5, tvpValue2);
+            ob.addItem(tvpKey2, tvpValue2);
+            ob.finish();
+        } catch (IOException e) {
+            Assert.fail("Test failed to write the object pointable.");
+        }
+
+        tvp.set(abvsResult);
+        tvp.getValue(op);
+        try {
+            getTaggedValuePointable("key", tvpKey3);
+            op.getValue(tvpKey3, tvpValue3);
+        } catch (IOException | SystemException e) {
+            Assert.fail("Test failed to write the object pointable.");
+        }
+        XDMConstants.setFalse(tvp);
+        if (!FunctionHelper.arraysEqual(tvp, tvpValue3)) {
+            Assert.fail("Value is incorrect for the given key. Expected: false with valuetag: "
+                    + ValueTag.XS_BOOLEAN_TAG + " Got valuetag: " + tvp.getTag());
+        }
+    }
 }


[06/11] vxquery git commit: Include the string pointable tags when returning the sequence pointable in getKeys method

Posted by pr...@apache.org.
Include the string pointable tags when returning the sequence pointable in getKeys method


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

Branch: refs/heads/master
Commit: 98cc0f89d52358d24fa015903ca53c6818567755
Parents: 5ec28cb
Author: riyafa <ri...@gmail.com>
Authored: Thu May 19 06:38:02 2016 +0530
Committer: riyafa <ri...@gmail.com>
Committed: Thu May 19 06:38:02 2016 +0530

----------------------------------------------------------------------
 .../accessors/jsonItem/ObjectPointable.java     | 14 +++++-----
 .../builders/sequence/SequenceBuilder.java      |  6 +++++
 .../vxquery/datamodel/ObjectByteTest.java       | 27 ++++++++++++++++----
 3 files changed, 36 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/98cc0f89/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
index 3aadee3..953a8fa 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
@@ -27,6 +27,7 @@ import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.vxquery.datamodel.builders.sequence.SequenceBuilder;
+import org.apache.vxquery.datamodel.values.ValueTag;
 import org.apache.vxquery.runtime.functions.util.FunctionHelper;
 
 /**
@@ -86,7 +87,7 @@ public class ObjectPointable extends AbstractPointable {
         for (int i = 0; i < entryCount; i++) {
             s = dataAreaOffset + getRelativeEntryStartOffset(i);
             key1.set(bytes, s, getKeyLength(bytes, s));
-            sb.addItem(key1);
+            sb.addItem(ValueTag.XS_STRING_TAG, key1);
         }
         sb.finish();
         result.set(abvs);
@@ -95,12 +96,13 @@ public class ObjectPointable extends AbstractPointable {
     public boolean getValue(UTF8StringPointable key, IPointable result) {
         int dataAreaOffset = getDataAreaOffset(bytes, start);
         int entryCount = getEntryCount();
-        int s, l, i;
+        int start, length, i;
         for (i = 0; i < entryCount; i++) {
-            s = dataAreaOffset + getRelativeEntryStartOffset(i);
-            l = getKeyLength(bytes, s);
-            if (FunctionHelper.arraysEqual(bytes, s, l, key.getByteArray(), key.getStartOffset(), key.getLength())) {
-                result.set(bytes, s + l, getEntryLength(i) - l);
+            start = dataAreaOffset + getRelativeEntryStartOffset(i);
+            length = getKeyLength(bytes, start);
+            if (FunctionHelper.arraysEqual(bytes, start, length, key.getByteArray(), key.getStartOffset(),
+                    key.getLength())) {
+                result.set(bytes, start + length, getEntryLength(i) - length);
                 return true;
             }
         }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/98cc0f89/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/sequence/SequenceBuilder.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/sequence/SequenceBuilder.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/sequence/SequenceBuilder.java
index fbea148..a5ca065 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/sequence/SequenceBuilder.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/sequence/SequenceBuilder.java
@@ -42,6 +42,12 @@ public class SequenceBuilder implements IBuilder {
         slots.append(dataArea.getLength());
     }
 
+    public void addItem(int tagValue, IValueReference p) throws IOException {
+        dataArea.getDataOutput().write(tagValue);
+        dataArea.getDataOutput().write(p.getByteArray(), p.getStartOffset(), p.getLength());
+        slots.append(dataArea.getLength());
+    }
+
     public void finish() throws IOException {
         DataOutput out = mvs.getDataOutput();
         if (slots.getSize() != 1) {

http://git-wip-us.apache.org/repos/asf/vxquery/blob/98cc0f89/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
index ff05c24..41694e8 100644
--- a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
+++ b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
@@ -16,6 +16,7 @@ package org.apache.vxquery.datamodel;
 
 import java.io.IOException;
 
+import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.vxquery.datamodel.accessors.SequencePointable;
@@ -92,8 +93,10 @@ public class ObjectByteTest extends AbstractPointableTest {
         } catch (IOException e) {
             Assert.fail("Test failed to write the object pointable.");
         }
-
-        if (!FunctionHelper.arraysEqual(tvp, tvpKey1)) {
+        if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
+            Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
+        }
+        if (!compareKeys(tvp, tvpKey1)) {
             Assert.fail("Key is incorrect. Expected: id");
         }
 
@@ -151,15 +154,24 @@ public class ObjectByteTest extends AbstractPointableTest {
             Assert.fail("Object size is incorrect. Expected: 3 Got: " + sp.getEntryCount());
         }
         sp.getEntry(0, tvp);
-        if (!FunctionHelper.arraysEqual(tvp, tvpKey1)) {
+        if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
+            Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
+        }
+        if (!compareKeys(tvp, tvpKey1)) {
             Assert.fail("Object key one is incorrect. Expected: name");
         }
         sp.getEntry(1, tvp);
-        if (!FunctionHelper.arraysEqual(tvp, tvpKey2)) {
+        if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
+            Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
+        }
+        if (!compareKeys(tvp, tvpKey2)) {
             Assert.fail("Object key two is incorrect. Expected: price");
         }
         sp.getEntry(2, tvp);
-        if (!FunctionHelper.arraysEqual(tvp, tvpKey3)) {
+        if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
+            Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
+        }
+        if (!compareKeys(tvp, tvpKey3)) {
             Assert.fail("Object key three is incorrect. Expected: properties");
         }
 
@@ -241,4 +253,9 @@ public class ObjectByteTest extends AbstractPointableTest {
             Assert.fail("Test failed to write the object pointable.");
         }
     }
+
+    public boolean compareKeys(IPointable tvp1, IPointable tvp2) {
+        return FunctionHelper.arraysEqual(tvp1.getByteArray(), tvp1.getStartOffset() + 1, tvp1.getLength() - 1,
+                tvp2.getByteArray(), tvp2.getStartOffset(), tvp2.getLength());
+    }
 }


[09/11] vxquery git commit: Changes for the last two comments: Restored the SequencePointable with only two changes Modified compareKeys() class

Posted by pr...@apache.org.
Changes for the last two comments:
Restored the SequencePointable with only two changes
Modified compareKeys() class


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

Branch: refs/heads/master
Commit: 98dc04fd5e9ec8b2044db88349b1db59d0234b7c
Parents: b28fc19
Author: riyafa <ri...@gmail.com>
Authored: Thu May 19 10:12:11 2016 +0530
Committer: riyafa <ri...@gmail.com>
Committed: Thu May 19 10:12:11 2016 +0530

----------------------------------------------------------------------
 .../vxquery/datamodel/accessors/SequencePointable.java    |  2 +-
 .../java/org/apache/vxquery/datamodel/ObjectByteTest.java | 10 ++++++----
 2 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/98dc04fd/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
index 9ccac0b..561ef8b 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
@@ -77,4 +77,4 @@ public class SequencePointable extends AbstractPointable {
     private static int getDataAreaOffset(byte[] bytes, int start) {
         return getSlotArrayOffset(start) + getEntryCount(bytes, start) * SLOT_SIZE;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/98dc04fd/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
index 2bf95c1..4bdb503 100644
--- a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
+++ b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
@@ -18,6 +18,7 @@ import java.io.IOException;
 
 import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
+import org.apache.hyracks.data.std.primitive.VoidPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.vxquery.datamodel.accessors.SequencePointable;
 import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
@@ -41,6 +42,7 @@ public class ObjectByteTest extends AbstractPointableTest {
     private TaggedValuePointable tvpValue3 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
     private SequencePointable sp = (SequencePointable) SequencePointable.FACTORY.createPointable();
     private ObjectPointable op = (ObjectPointable) ObjectPointable.FACTORY.createPointable();
+    private IPointable vp = VoidPointable.FACTORY.createPointable();
 
     @Test
     public void testEmptyObject() {
@@ -254,9 +256,9 @@ public class ObjectByteTest extends AbstractPointableTest {
         }
     }
 
-    private boolean compareKeys(IPointable tvp1, IPointable tvp2) {
-
-        return FunctionHelper.arraysEqual(tvp1.getByteArray(), tvp1.getStartOffset() + 1, tvp1.getLength() - 1,
-                tvp2.getByteArray(), tvp2.getStartOffset(), tvp2.getLength());
+    private boolean compareKeys(TaggedValuePointable tvp1, IPointable tvp2) {
+        tvp1.getValue(vp);
+        return FunctionHelper.arraysEqual(vp.getByteArray(), vp.getStartOffset(), vp.getLength(), tvp2.getByteArray(),
+                tvp2.getStartOffset(), tvp2.getLength());
     }
 }


[10/11] vxquery git commit: Sequecepointable restored

Posted by pr...@apache.org.
Sequecepointable restored


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

Branch: refs/heads/master
Commit: 3fd80538919f83868a81f2966f76539ab64f4720
Parents: 98dc04f
Author: riyafa <ri...@gmail.com>
Authored: Thu May 19 10:18:21 2016 +0530
Committer: riyafa <ri...@gmail.com>
Committed: Thu May 19 10:18:21 2016 +0530

----------------------------------------------------------------------
 .../org/apache/vxquery/datamodel/accessors/SequencePointable.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/3fd80538/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
index 561ef8b..9ccac0b 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
@@ -77,4 +77,4 @@ public class SequencePointable extends AbstractPointable {
     private static int getDataAreaOffset(byte[] bytes, int start) {
         return getSlotArrayOffset(start) + getEntryCount(bytes, start) * SLOT_SIZE;
     }
-}
+}
\ No newline at end of file