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/08/12 18:52:38 UTC

vxquery git commit: Implement libjn:project and libjn:remove-keys

Repository: vxquery
Updated Branches:
  refs/heads/master 0419d3981 -> 8129616e9


Implement libjn:project and libjn:remove-keys


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

Branch: refs/heads/master
Commit: 8129616e9e868b953e228de24bcb7a08202c3254
Parents: 0419d39
Author: riyafa <ri...@cse.mrt.ac.lk>
Authored: Mon Aug 8 22:25:37 2016 +0530
Committer: Preston Carman <pr...@apache.org>
Committed: Fri Aug 12 11:51:54 2016 -0700

----------------------------------------------------------------------
 .../vxquery/functions/builtin-functions.xml     |  16 ++
 .../AbstractLibjnProjectScalarEvaluator.java    | 160 +++++++++++++++++++
 .../json/LibjnProjectScalarEvaluator.java       |  35 ++++
 .../LibjnProjectScalarEvaluatorFactory.java     |  39 +++++
 .../json/LibjnRemoveKeysScalarEvaluator.java    |  35 ++++
 .../LibjnRemoveKeysScalarEvaluatorFactory.java  |  39 +++++
 .../SimpleObjectUnionScalarEvaluator.java       |   1 -
 .../resources/ExpectedTestResults/project.txt   |  13 ++
 .../ExpectedTestResults/remove_keys.txt         |  14 ++
 .../Queries/XQuery/Json/Libraries/project.xq    |  61 +++++++
 .../XQuery/Json/Libraries/remove_keys.xq        |  60 +++++++
 .../test/resources/cat/LibrariesInJSONiq.xml    |  10 ++
 12 files changed, 482 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/8129616e/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-functions.xml
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-functions.xml b/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-functions.xml
index 93f2cb3..43839f8 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-functions.xml
+++ b/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-functions.xml
@@ -1241,4 +1241,20 @@
         <return type="object()*"/>
         <runtime type="scalar" class="org.apache.vxquery.runtime.functions.json.LibjnDescendantPairsScalarEvaluatorFactory"/>
     </function>
+
+    <!-- libjn:project($sequence as item()*, $keys as xs:string*) as item()* -->
+    <function name="libjn:project">
+        <param name="sequence" type="item()*"/>
+        <param name="keys" type="xs:string*"/>
+        <return type="item()*"/>
+        <runtime type="scalar" class="org.apache.vxquery.runtime.functions.json.LibjnProjectScalarEvaluatorFactory"/>
+    </function>
+
+    <!-- libjn:remove-keys($sequence as item()*, $keys as xs:string*) as item()* -->
+    <function name="libjn:remove-keys">
+        <param name="sequence" type="item()*"/>
+        <param name="keys" type="xs:string*"/>
+        <return type="item()*"/>
+        <runtime type="scalar" class="org.apache.vxquery.runtime.functions.json.LibjnRemoveKeysScalarEvaluatorFactory"/>
+    </function>
 </functions>

http://git-wip-us.apache.org/repos/asf/vxquery/blob/8129616e/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/AbstractLibjnProjectScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/AbstractLibjnProjectScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/AbstractLibjnProjectScalarEvaluator.java
new file mode 100644
index 0000000..d81cc7d
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/AbstractLibjnProjectScalarEvaluator.java
@@ -0,0 +1,160 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.vxquery.runtime.functions.json;
+
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+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;
+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.builders.sequence.SequenceBuilder;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.exceptions.ErrorCode;
+import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator;
+import org.apache.vxquery.runtime.functions.util.FunctionHelper;
+
+import java.io.IOException;
+
+public abstract class AbstractLibjnProjectScalarEvaluator extends AbstractTaggedValueArgumentScalarEvaluator {
+    protected final IHyracksTaskContext ctx;
+    protected final ObjectPointable op;
+    protected final UTF8StringPointable stringKey;
+    protected final ObjectBuilder ob;
+    protected final ArrayBackedValueStorage abvs, abvs1;
+    protected final SequenceBuilder sb;
+    protected final SequencePointable sp1;
+    protected final TaggedValuePointable tvp1;
+
+    public AbstractLibjnProjectScalarEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) {
+        super(args);
+        this.ctx = ctx;
+        stringKey = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
+        ob = new ObjectBuilder();
+        abvs = new ArrayBackedValueStorage();
+        abvs1 = new ArrayBackedValueStorage();
+        sb = new SequenceBuilder();
+        op = (ObjectPointable) ObjectPointable.FACTORY.createPointable();
+        sp1 = (SequencePointable) SequencePointable.FACTORY.createPointable();
+        tvp1 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+    }
+
+    @Override
+    protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
+        TaggedValuePointable sequence = args[0];
+        TaggedValuePointable keys = args[1];
+        if (keys.getTag() != ValueTag.SEQUENCE_TAG && keys.getTag() != ValueTag.XS_STRING_TAG) {
+            throw new SystemException(ErrorCode.FORG0006);
+        }
+        TaggedValuePointable tempTvp = ppool.takeOne(TaggedValuePointable.class);
+        SequencePointable sp = ppool.takeOne(SequencePointable.class);
+        try {
+            abvs1.reset();
+            sb.reset(abvs1);
+            if (sequence.getTag() == ValueTag.SEQUENCE_TAG) {
+                sequence.getValue(sp);
+                for (int i = 0; i < sp.getEntryCount(); ++i) {
+                    sp.getEntry(i, tempTvp);
+                    if (tempTvp.getTag() == ValueTag.OBJECT_TAG) {
+                        tempTvp.getValue(op);
+                        op.getKeys(tempTvp);
+                        addPairs(tempTvp, keys);
+                    } else {
+                        sb.addItem(tempTvp);
+                    }
+                }
+            } else if (sequence.getTag() == ValueTag.OBJECT_TAG) {
+                sequence.getValue(op);
+                addPairs(tempTvp, keys);
+            } else {
+                sb.addItem(sequence);
+            }
+            sb.finish();
+            result.set(abvs1);
+        } catch (IOException e) {
+            throw new SystemException(ErrorCode.SYSE0001, e);
+        } finally {
+            ppool.giveBack(tempTvp);
+            ppool.giveBack(sp);
+        }
+    }
+
+    protected void addPair(TaggedValuePointable tempTvp, TaggedValuePointable tempValue)
+            throws IOException, SystemException {
+        tempTvp.getValue(stringKey);
+        op.getValue(stringKey, tempValue);
+        ob.addItem(stringKey, tempValue);
+    }
+
+    private void addPairs(TaggedValuePointable tvp2, TaggedValuePointable keys) throws IOException, SystemException {
+        op.getKeys(tvp2);
+        if (tvp2.getTag() == ValueTag.XS_STRING_TAG) {
+            if (keyCheck(tvp2, keys)) {
+                abvs.reset();
+                ob.reset(abvs);
+                addPair(tvp2, tvp1);
+                ob.finish();
+                sb.addItem(abvs);
+            }
+        } else if (tvp2.getTag() == ValueTag.SEQUENCE_TAG) {
+            tvp2.getValue(sp1);
+            boolean found = false;
+            for (int j = 0; j < sp1.getEntryCount(); ++j) {
+                sp1.getEntry(j, tvp2);
+                if (keyCheck(tvp2, keys)) {
+                    if (!found) {
+                        abvs.reset();
+                        ob.reset(abvs);
+                        found = true;
+                    }
+                    addPair(tvp2, tvp1);
+                }
+            }
+            if (found) {
+                ob.finish();
+                sb.addItem(abvs);
+            }
+        }
+
+    }
+
+    protected abstract boolean keyCheck(TaggedValuePointable objTvp, TaggedValuePointable keys) throws SystemException;
+
+    protected boolean isKeyFound(TaggedValuePointable tvp, TaggedValuePointable keys) throws SystemException {
+        if (keys.getTag() == ValueTag.SEQUENCE_TAG) {
+            keys.getValue(sp1);
+            for (int i = 0; i < sp1.getEntryCount(); i++) {
+                sp1.getEntry(i, tvp1);
+                if (tvp1.getTag() != ValueTag.XS_STRING_TAG) {
+                    throw new SystemException(ErrorCode.FORG0006);
+                }
+                if (FunctionHelper.arraysEqual(tvp1, tvp)) {
+                    return true;
+                }
+            }
+        } else if (keys.getTag() == ValueTag.XS_STRING_TAG) {
+            if (FunctionHelper.arraysEqual(tvp, keys)) {
+                return true;
+            }
+        }
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/8129616e/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/LibjnProjectScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/LibjnProjectScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/LibjnProjectScalarEvaluator.java
new file mode 100644
index 0000000..171179d
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/LibjnProjectScalarEvaluator.java
@@ -0,0 +1,35 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.vxquery.runtime.functions.json;
+
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.exceptions.SystemException;
+
+public class LibjnProjectScalarEvaluator extends AbstractLibjnProjectScalarEvaluator {
+
+    public LibjnProjectScalarEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) {
+        super(ctx, args);
+    }
+
+    @Override
+    protected boolean keyCheck(TaggedValuePointable objTvp, TaggedValuePointable keys) throws SystemException {
+        return isKeyFound(objTvp, keys);
+    }
+
+}

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

http://git-wip-us.apache.org/repos/asf/vxquery/blob/8129616e/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/LibjnRemoveKeysScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/LibjnRemoveKeysScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/LibjnRemoveKeysScalarEvaluator.java
new file mode 100644
index 0000000..370e535
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/LibjnRemoveKeysScalarEvaluator.java
@@ -0,0 +1,35 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.vxquery.runtime.functions.json;
+
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.exceptions.SystemException;
+
+public class LibjnRemoveKeysScalarEvaluator extends AbstractLibjnProjectScalarEvaluator {
+
+    public LibjnRemoveKeysScalarEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) {
+        super(ctx, args);
+    }
+
+    @Override
+    protected boolean keyCheck(TaggedValuePointable objTvp, TaggedValuePointable keys) throws SystemException {
+        return !isKeyFound(objTvp, keys);
+    }
+
+}

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

http://git-wip-us.apache.org/repos/asf/vxquery/blob/8129616e/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/jsonitem/SimpleObjectUnionScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/jsonitem/SimpleObjectUnionScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/jsonitem/SimpleObjectUnionScalarEvaluator.java
index 7583918..2b13a9f 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/jsonitem/SimpleObjectUnionScalarEvaluator.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/jsonitem/SimpleObjectUnionScalarEvaluator.java
@@ -102,7 +102,6 @@ public class SimpleObjectUnionScalarEvaluator extends AbstractObjectConstructorS
         } else if (tempTvp.getTag() == ValueTag.SEQUENCE_TAG) {
             tempTvp.getValue(sp1);
             for (int j = 0; j < sp1.getEntryCount(); ++j) {
-                key = ppool.takeOne(TaggedValuePointable.class);
                 sp1.getEntry(j, tempTvp);
                 addPair(tempTvp, tempValue);
             }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/8129616e/vxquery-xtest/src/test/resources/ExpectedTestResults/project.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/project.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/project.txt
new file mode 100644
index 0000000..aefe4f5
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/project.txt
@@ -0,0 +1,13 @@
+{"Captain":"Kirk","First Officer":"Spock"}
+[1,2,3,4]
+{"Captain":"Archer"}
+true
+1
+null
+{"Captain":"Archer"}
+true
+1
+null
+true
+1
+null
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/8129616e/vxquery-xtest/src/test/resources/ExpectedTestResults/remove_keys.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/remove_keys.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/remove_keys.txt
new file mode 100644
index 0000000..3fa2a35
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/remove_keys.txt
@@ -0,0 +1,14 @@
+{"Engineer":"Scott"}
+[1,2,3,4]
+{"Engineer":"Trip"}
+true
+1
+null
+{"Engineer":"Trip"}
+true
+1
+null
+{"Captain":"Archer","Engineer":"Trip"}
+true
+1
+null
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/8129616e/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Libraries/project.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Libraries/project.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Libraries/project.xq
new file mode 100644
index 0000000..2e78867
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Libraries/project.xq
@@ -0,0 +1,61 @@
+(: 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. :)
+
+(: JSONiq libjn:project :)
+libjn:project(
+    (
+        {
+            "Captain" : "Kirk",
+            "First Officer" : "Spock",
+            "Engineer" : "Scott"
+        },
+        [ 1, 2, 3, 4 ],
+        {
+            "Captain" : "Archer",
+            "Engineer" : "Trip"
+        },
+        true(),
+        1,
+        jn:null()
+    ),
+    ("Captain", "First Officer", "XQuery Evangelist")
+),
+libjn:project(
+    (
+        {
+            "Captain" : "Archer",
+            "Engineer" : "Trip"
+        },
+        true(),
+        1,
+        jn:null()
+    ),
+    "Captain"
+),
+libjn:project(
+    (
+        {
+            "Captain" : "Archer",
+            "Engineer" : "Trip"
+        },
+        true(),
+        1,
+        jn:null()
+    ),
+    ()
+)
+

http://git-wip-us.apache.org/repos/asf/vxquery/blob/8129616e/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Libraries/remove_keys.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Libraries/remove_keys.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Libraries/remove_keys.xq
new file mode 100644
index 0000000..348e57c
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Libraries/remove_keys.xq
@@ -0,0 +1,60 @@
+(: 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. :)
+
+(: JSONiq libjn:remove-keys :)
+libjn:remove-keys(
+    (
+        {
+            "Captain" : "Kirk",
+            "First Officer" : "Spock",
+            "Engineer" : "Scott"
+        },
+        [ 1, 2, 3, 4 ],
+        {
+            "Captain" : "Archer",
+            "Engineer" : "Trip"
+        },
+        true(),
+        1,
+        jn:null()
+    ),
+    ("Captain", "First Officer", "XQuery Evangelist")
+),
+libjn:remove-keys(
+    (
+        {
+            "Captain" : "Archer",
+            "Engineer" : "Trip"
+        },
+        true(),
+        1,
+        jn:null()
+    ),
+    "Captain"
+),
+libjn:remove-keys(
+    (
+        {
+            "Captain" : "Archer",
+            "Engineer" : "Trip"
+        },
+        true(),
+        1,
+        jn:null()
+    ),
+    ()
+)

http://git-wip-us.apache.org/repos/asf/vxquery/blob/8129616e/vxquery-xtest/src/test/resources/cat/LibrariesInJSONiq.xml
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/cat/LibrariesInJSONiq.xml b/vxquery-xtest/src/test/resources/cat/LibrariesInJSONiq.xml
index fcd0eac..66cab65 100644
--- a/vxquery-xtest/src/test/resources/cat/LibrariesInJSONiq.xml
+++ b/vxquery-xtest/src/test/resources/cat/LibrariesInJSONiq.xml
@@ -56,4 +56,14 @@
         <query name="descendant_pairs" date="2016-07-29"/>
         <output-file compare="Text">descendant_pairs.txt</output-file>
     </test-case>
+   <test-case name="project" FilePath="Json/Libraries/" Creator="Riyafa Abdul Hameed">
+      <description>Json Libraries.</description>
+      <query name="project" date="2016-07-31"/>
+      <output-file compare="Text">project.txt</output-file>
+   </test-case>
+   <test-case name="remove-keys" FilePath="Json/Libraries/" Creator="Riyafa Abdul Hameed">
+      <description>Json Libraries.</description>
+      <query name="remove_keys" date="2016-07-31"/>
+      <output-file compare="Text">remove_keys.txt</output-file>
+   </test-case>
 </test-group>