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/07/01 14:58:12 UTC
vxquery git commit: Implement object navigation Implement jdm:keys,
jn:keys and jn:null and extend jdm:values with test cases
Repository: vxquery
Updated Branches:
refs/heads/master 9f458dcb2 -> f79a1218a
Implement object navigation
Implement jdm:keys, jn:keys and jn:null and extend jdm:values with test cases
Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/f79a1218
Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/f79a1218
Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/f79a1218
Branch: refs/heads/master
Commit: f79a1218a4c504a8003516e8ad70e28bb7647f88
Parents: 9f458dc
Author: riyafa <ri...@gmail.com>
Authored: Thu Jun 30 21:40:56 2016 +0530
Committer: riyafa <ri...@gmail.com>
Committed: Fri Jul 1 12:38:27 2016 +0530
----------------------------------------------------------------------
.../vxquery/context/RootStaticContextImpl.java | 3 +
.../vxquery/functions/builtin-functions.xml | 47 ++++---
.../vxquery/functions/builtin-operators.xml | 10 +-
.../functions/json/JnKeysScalarEvaluator.java | 121 +++++++++++++++++++
.../json/JnKeysScalarEvaluatorFactory.java | 39 ++++++
.../functions/json/JnNullScalarEvaluator.java | 42 +++++++
.../json/JnNullScalarEvaluatorFactory.java | 39 ++++++
.../functions/json/KeysScalarEvaluator.java | 56 +++++++++
.../json/KeysScalarEvaluatorFactory.java | 39 ++++++
.../functions/json/ValueScalarEvaluator.java | 37 +++++-
.../xmlquery/translator/XMLQueryTranslator.java | 55 ++++-----
.../Json/Functions/jn_keys1.txt | 3 +
.../Json/Functions/jn_keys2.txt | 2 +
.../Object/Navigation/q01_object_navigation.txt | 1 +
.../Object/Navigation/q02_object_navigation.txt | 1 +
.../Object/Navigation/q03_object_navigation.txt | 1 +
.../Object/Navigation/q04_object_navigation.txt | 2 +
.../Object/Navigation/q05_object_navigation.txt | 0
.../Object/Navigation/q06_object_navigation.txt | 0
.../Object/Navigation/q07_object_navigation.txt | 0
.../Queries/XQuery/Json/Functions/jn_keys1.xq | 22 ++++
.../Queries/XQuery/Json/Functions/jn_keys2.xq | 23 ++++
.../Object/Navigation/q01_object_navigation.xq | 20 +++
.../Object/Navigation/q02_object_navigation.xq | 21 ++++
.../Object/Navigation/q03_object_navigation.xq | 26 ++++
.../Object/Navigation/q04_object_navigation.xq | 20 +++
.../Object/Navigation/q05_object_navigation.xq | 20 +++
.../Object/Navigation/q06_object_navigation.xq | 20 +++
.../Object/Navigation/q07_object_navigation.xq | 20 +++
.../src/test/resources/VXQueryCatalog.xml | 70 ++++++-----
.../test/resources/cat/FunctionsInJSONiq.xml | 10 ++
.../cat/JsonObjectNavigationQueries.xml | 59 +++++++++
32 files changed, 751 insertions(+), 78 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-core/src/main/java/org/apache/vxquery/context/RootStaticContextImpl.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/context/RootStaticContextImpl.java b/vxquery-core/src/main/java/org/apache/vxquery/context/RootStaticContextImpl.java
index cd80824..8c695e2 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/context/RootStaticContextImpl.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/context/RootStaticContextImpl.java
@@ -46,6 +46,9 @@ public final class RootStaticContextImpl extends StaticContextImpl {
INSTANCE.registerNamespaceUri(XQueryConstants.XSI_PREFIX, XQueryConstants.XSI_NSURI);
INSTANCE.registerNamespaceUri(XQueryConstants.FN_PREFIX, XQueryConstants.FN_NSURI);
INSTANCE.registerNamespaceUri(XQueryConstants.LOCAL_PREFIX, XQueryConstants.LOCAL_NSURI);
+ INSTANCE.registerNamespaceUri(XQueryConstants.JS_PREFIX, XQueryConstants.JS_NSURI);
+ INSTANCE.registerNamespaceUri(XQueryConstants.JN_PREFIX, XQueryConstants.JN_NSURI);
+ INSTANCE.registerNamespaceUri(XQueryConstants.JDM_PREFIX, XQueryConstants.JDM_NSURI);
INSTANCE.setBaseUri(".");
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/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 870ab75..67f3957 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
@@ -22,7 +22,7 @@
<return type="xsext:numeric?"/>
<runtime type="scalar" class="org.apache.vxquery.runtime.functions.numeric.FnAbsScalarEvaluatorFactory"/>
</function>
-
+
<!-- fn:adjust-date-to-timezone( $arg as xs:date?) as xs:date? -->
<function name="fn:adjust-date-to-timezone">
<param name="arg" type="xs:date?"/>
@@ -100,7 +100,7 @@
<return type="xsext:numeric?"/>
<runtime type="scalar" class="org.apache.vxquery.runtime.functions.numeric.FnCeilingScalarEvaluatorFactory"/>
</function>
-
+
<!-- fn:codepoint-equal($comparand1 as xs:string?, $comparand2 as xs:string?) as xs:boolean? -->
<function name="fn:codepoint-equal">
<param name="comparand1" type="xs:string?"/>
@@ -108,31 +108,31 @@
<return type="xs:boolean?"/>
<runtime type="scalar" class="org.apache.vxquery.runtime.functions.strings.FnCodepointEqualEvaluatorFactory"/>
</function>
-
+
<!-- fn:codepoints-to-string( $arg as xs:integer*) as xs:string -->
<function name="fn:codepoints-to-string">
<param name="arg" type="xs:integer*"/>
<return type="xs:string"/>
<runtime type="scalar" class="org.apache.vxquery.runtime.functions.strings.FnCodepointsToStringEvaluatorFactory"/>
</function>
-
+
<!-- fn:collection() as node()* -->
<function name="fn:collection">
<return type="node()*"/>
</function>
-
+
<!-- fn:collection($arg as xs:string?) as node()* -->
<function name="fn:collection">
<param name="arg" type="xs:string?"/>
<return type="node()*"/>
<!-- Collection operator is added during the rewrite rules phase. -->
</function>
-
+
<!-- fn:build-index-on-collection($arg as xs:string?, $indexFolder as xs:string?) as node()* -->
<function name="fn:build-index-on-collection">
<param name="collection-folder" type="xs:string?"/>
<param name="index-folder" type="xs:string?"/>
- <return type="node()*"/>
+ <return type="node()*"/>
<runtime type="scalar" class="org.apache.vxquery.runtime.functions.index.IndexConstructorScalarEvaluatorFactory"/>
</function>
@@ -143,13 +143,13 @@
<runtime type="scalar"
class="org.apache.vxquery.runtime.functions.index.IndexUpdaterEvaluatorFactory"/>
</function>
-
+
<!-- fn:collection-from-index($indexfolder as xs:string?, $elementpath as xs:string?) as node()* -->
<function name="fn:collection-from-index">
<param name="index-folder" type="xs:string?"/>
<param name="element-path" type="xs:string?"/>
- <return type="node()*"/>
- <runtime type="unnesting" class="org.apache.vxquery.runtime.functions.index.CollectionFromIndexUnnestingEvaluatorFactory"/>
+ <return type="node()*"/>
+ <runtime type="unnesting" class="org.apache.vxquery.runtime.functions.index.CollectionFromIndexUnnestingEvaluatorFactory"/>
<property type="DocumentOrder" class="org.apache.vxquery.compiler.rewriter.rules.propagationpolicies.InputPropertyPropagationPolicy">
<argument value="0"/>
</property>
@@ -157,7 +157,7 @@
<argument value="0"/>
</property>
</function>
-
+
<!-- fn:collection-with-tag($arg1 as xs:string?, $arg2 as xs:string?) as node()* -->
<function name="fn:collection-with-tag">
<param name="arg1" type="xs:string?"/>
@@ -165,7 +165,7 @@
<return type="node()*"/>
<!-- CollectionWithTag operator is added during the rewrite rules phase. -->
</function>
-
+
<!-- fn:compare($comparand1 as xs:string?, $comparand2 as xs:string?) as xs:integer? -->
<function name="fn:compare">
<param name="comparand1" type="xs:string?"/>
@@ -173,7 +173,7 @@
<return type="xs:integer?"/>
<runtime type="scalar" class="org.apache.vxquery.runtime.functions.strings.FnCompareEvaluatorFactory"/>
</function>
-
+
<!-- fn:compare($comparand1 as xs:string?, $comparand2 as xs:string?, $collation as xs:string) as xs:integer? -->
<function name="fn:compare">
<param name="comparand1" type="xs:string?"/>
@@ -182,7 +182,7 @@
<return type="xs:integer?"/>
<runtime type="scalar" class="org.apache.vxquery.runtime.functions.strings.FnCompareEvaluatorFactory"/>
</function>
-
+
<!-- fn:concat($arg1 as xs:anyAtomicType?, $arg2 as xs:anyAtomicType?, ...) as xs:string -->
<function name="fn:concat" varargs="true">
<param name="arg1" type="xs:anyAtomicType?"/>
@@ -190,7 +190,7 @@
<return type="xs:string"/>
<runtime type="scalar" class="org.apache.vxquery.runtime.functions.strings.FnConcatEvaluatorFactory"/>
</function>
-
+
<!-- fn:contains($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean -->
<function name="fn:contains">
<param name="arg1" type="xs:string?"/>
@@ -198,7 +198,7 @@
<return type="xs:boolean"/>
<runtime type="scalar" class="org.apache.vxquery.runtime.functions.strings.FnContainsEvaluatorFactory"/>
</function>
-
+
<!-- fn:contains($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean -->
<function name="fn:contains">
<param name="arg1" type="xs:string?"/>
@@ -245,7 +245,7 @@
<argument value="0"/>
</property>
</function>
-
+
<!-- fn:size($expr as item()*) as xs:anyAtomicType* -->
<function name="fn:size">
<param name="expr" type="item()*"/>
@@ -1148,4 +1148,17 @@
<argument value="0"/>
</property>
</function>
+
+ <!-- jn:keys($arg as item()*) as xs:string* -->
+ <function name="jn:keys">
+ <param name="arg" type="item()*"/>
+ <return type="xs:string*"/>
+ <runtime type="scalar" class="org.apache.vxquery.runtime.functions.json.JnKeysScalarEvaluatorFactory"/>
+ </function>
+
+ <!-- jn:null() as js:null -->
+ <function name="jn:null">
+ <return type="xs:string*"/>
+ <runtime type="scalar" class="org.apache.vxquery.runtime.functions.json.JnNullScalarEvaluatorFactory"/>
+ </function>
</functions>
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml b/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
index 877208c..028efda 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
+++ b/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
@@ -648,13 +648,19 @@
</operator>
<!-- opext:value($expr as xs:item(), $arg as xs:anyAtomicType?) as item() -->
- <operator name="opext:value">
- <param name="expr" type="item()"/>
+ <operator name="jdm:value">
+ <param name="expr" type="json-item()"/>
<param name="argExpr" type="xs:anyAtomicType"/>
<return type="item()"/>
<runtime type="scalar" class="org.apache.vxquery.runtime.functions.json.ValueScalarEvaluatorFactory"/>
</operator>
+ <operator name="jdm:keys">
+ <param name="expr" type="json-item()"/>
+ <return type="item()"/>
+ <runtime type="scalar" class="org.apache.vxquery.runtime.functions.json.KeysScalarEvaluatorFactory"/>
+ </operator>
+
<!-- opext:subtract($arg1 as xs:anyAtomicType?, $arg2 as xs:anyAtomicType?) as xs:anyAtomicType? -->
<operator name="opext:subtract">
<param name="arg1" type="xs:anyAtomicType?"/>
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnKeysScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnKeysScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnKeysScalarEvaluator.java
new file mode 100644
index 0000000..4b093eb
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnKeysScalarEvaluator.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.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.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.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.base.AbstractTaggedValueArgumentScalarEvaluator;
+import org.apache.vxquery.runtime.functions.util.FunctionHelper;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class JnKeysScalarEvaluator extends AbstractTaggedValueArgumentScalarEvaluator {
+ protected final IHyracksTaskContext ctx;
+ private final SequencePointable sp1, sp2;
+ private final SequenceBuilder sb;
+ private final ArrayBackedValueStorage abvs;
+ private List<TaggedValuePointable> pointables;
+
+ public JnKeysScalarEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) {
+ super(args);
+ this.ctx = ctx;
+ sp1 = (SequencePointable) SequencePointable.FACTORY.createPointable();
+ sp2 = (SequencePointable) SequencePointable.FACTORY.createPointable();
+ sb = new SequenceBuilder();
+ abvs = new ArrayBackedValueStorage();
+ pointables = new ArrayList<>();
+ }
+
+ @Override
+ protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
+ TaggedValuePointable tvp1 = args[0];
+ ObjectPointable op;
+ pointables.clear();
+ if (tvp1.getTag() == ValueTag.SEQUENCE_TAG) {
+ TaggedValuePointable temptvp = ppool.takeOne(TaggedValuePointable.class);
+ try {
+ tvp1.getValue(sp1);
+ int size1 = sp1.getEntryCount();
+ int size2;
+ for (int i = 0; i < size1; i++) {
+ sp1.getEntry(i, temptvp);
+ if (temptvp.getTag() == ValueTag.OBJECT_TAG) {
+ op = (ObjectPointable) ObjectPointable.FACTORY.createPointable();
+ temptvp.getValue(op);
+ op.getKeys(temptvp);
+ temptvp.getValue(sp2);
+ size2 = sp2.getEntryCount();
+ for (int j = 0; j < size2; j++) {
+ TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY
+ .createPointable();
+ sp2.getEntry(j, tvp);
+ pointables.add(tvp);
+ }
+ }
+ }
+ removeDuplicates(pointables);
+ abvs.reset();
+ sb.reset(abvs);
+ for (TaggedValuePointable tvp : pointables) {
+ sb.addItem(tvp);
+ }
+ sb.finish();
+ result.set(abvs);
+ } catch (IOException e) {
+ throw new SystemException(ErrorCode.SYSE0001, e);
+ } finally {
+ ppool.giveBack(temptvp);
+ }
+ } else if (tvp1.getTag() == ValueTag.OBJECT_TAG) {
+ try {
+ op = (ObjectPointable) ObjectPointable.FACTORY.createPointable();
+ tvp1.getValue(op);
+ op.getKeys(result);
+ } catch (IOException e) {
+ throw new SystemException(ErrorCode.SYSE0001, e);
+ }
+ } else {
+ XDMConstants.setEmptySequence(result);
+ }
+ }
+
+ private void removeDuplicates(List<TaggedValuePointable> pointables) {
+ int size = pointables.size();
+ for (int i = 0; i < size - 1; i++) {
+ for (int j = i + 1; j < size; j++) {
+ if (!FunctionHelper.arraysEqual(pointables.get(j), pointables.get(i))) {
+ continue;
+ }
+ pointables.remove(j);
+ j--;
+ size--;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnKeysScalarEvaluatorFactory.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnKeysScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnKeysScalarEvaluatorFactory.java
new file mode 100644
index 0000000..f45299b
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnKeysScalarEvaluatorFactory.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 JnKeysScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory {
+
+ private static final long serialVersionUID = 1L;
+
+ public JnKeysScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+ super(args);
+ }
+
+ @Override
+ protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
+ throws AlgebricksException {
+ return new JnKeysScalarEvaluator(ctx, args);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnNullScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnNullScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnNullScalarEvaluator.java
new file mode 100644
index 0000000..772f30a
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnNullScalarEvaluator.java
@@ -0,0 +1,42 @@
+/*
+* 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.util.ArrayBackedValueStorage;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.values.XDMConstants;
+import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator;
+
+public class JnNullScalarEvaluator extends AbstractTaggedValueArgumentScalarEvaluator {
+ protected final IHyracksTaskContext ctx;
+ private final ArrayBackedValueStorage abvs;
+
+ public JnNullScalarEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) {
+ super(args);
+ this.ctx = ctx;
+ abvs = new ArrayBackedValueStorage();
+ }
+
+ @Override
+ protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
+ XDMConstants.setJsNull(result);
+ }
+}
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnNullScalarEvaluatorFactory.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnNullScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnNullScalarEvaluatorFactory.java
new file mode 100644
index 0000000..e042370
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnNullScalarEvaluatorFactory.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 JnNullScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory {
+
+ private static final long serialVersionUID = 1L;
+
+ public JnNullScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+ super(args);
+ }
+
+ @Override
+ protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
+ throws AlgebricksException {
+ return new JnNullScalarEvaluator(ctx, args);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluator.java
new file mode 100644
index 0000000..ad58cb3
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluator.java
@@ -0,0 +1,56 @@
+/*
+* 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.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.accessors.jsonitem.ObjectPointable;
+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 java.io.IOException;
+
+public class KeysScalarEvaluator extends AbstractTaggedValueArgumentScalarEvaluator {
+ protected final IHyracksTaskContext ctx;
+ private final ObjectPointable op;
+
+ public KeysScalarEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) {
+ super(args);
+ this.ctx = ctx;
+ op = (ObjectPointable) ObjectPointable.FACTORY.createPointable();
+ }
+
+ @Override
+ protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
+ TaggedValuePointable tvp1 = args[0];
+ if (!(tvp1.getTag() == ValueTag.OBJECT_TAG)) {
+ throw new SystemException(ErrorCode.FORG0006);
+ }
+ try {
+ tvp1.getValue(op);
+ op.getKeys(result);
+ } catch (IOException e) {
+ throw new SystemException(ErrorCode.SYSE0001, e);
+
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluatorFactory.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluatorFactory.java
new file mode 100644
index 0000000..30bf850
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluatorFactory.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 KeysScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory {
+
+ private static final long serialVersionUID = 1L;
+
+ public KeysScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+ super(args);
+ }
+
+ @Override
+ protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
+ throws AlgebricksException {
+ return new KeysScalarEvaluator(ctx, args);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/ValueScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/ValueScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/ValueScalarEvaluator.java
index d7e3e51..6ef53dc 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/ValueScalarEvaluator.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/ValueScalarEvaluator.java
@@ -23,9 +23,11 @@ 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.LongPointable;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
import org.apache.vxquery.datamodel.accessors.jsonitem.ArrayPointable;
+import org.apache.vxquery.datamodel.accessors.jsonitem.ObjectPointable;
import org.apache.vxquery.datamodel.builders.sequence.SequenceBuilder;
import org.apache.vxquery.datamodel.values.ValueTag;
import org.apache.vxquery.datamodel.values.XDMConstants;
@@ -38,16 +40,20 @@ public class ValueScalarEvaluator extends AbstractTaggedValueArgumentScalarEvalu
private final ArrayBackedValueStorage mvs;
private final ArrayPointable ap;
private final LongPointable lp;
- private final SequenceBuilder ab;
+ private final SequenceBuilder sb;
+ private final ObjectPointable op;
+ private final UTF8StringPointable sp;
protected DataOutput out;
public ValueScalarEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) {
super(args);
this.ctx = ctx;
ap = (ArrayPointable) ArrayPointable.FACTORY.createPointable();
+ op = (ObjectPointable) ObjectPointable.FACTORY.createPointable();
+ sp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
lp = (LongPointable) LongPointable.FACTORY.createPointable();
mvs = new ArrayBackedValueStorage();
- ab = new SequenceBuilder();
+ sb = new SequenceBuilder();
}
@Override
@@ -64,7 +70,7 @@ public class ValueScalarEvaluator extends AbstractTaggedValueArgumentScalarEvalu
TaggedValuePointable tempTvp = ppool.takeOne(TaggedValuePointable.class);
mvs.reset();
try {
- ab.reset(mvs);
+ sb.reset(mvs);
tvp1.getValue(ap);
tvp2.getValue(lp);
if ((int) lp.getLong() > ap.getEntryCount()) {
@@ -72,14 +78,35 @@ public class ValueScalarEvaluator extends AbstractTaggedValueArgumentScalarEvalu
return;
}
ap.getEntry((int) lp.getLong() - 1, tempTvp);
- ab.addItem(ap.getEntryCount() != 0 ? tempTvp : tvp1);
- ab.finish();
+ sb.addItem(ap.getEntryCount() != 0 ? tempTvp : tvp1);
+ sb.finish();
result.set(mvs);
} catch (IOException e) {
throw new SystemException(ErrorCode.SYSE0001, e);
} finally {
ppool.giveBack(tempTvp);
}
+ } else if (tvp1.getTag() == ValueTag.OBJECT_TAG) {
+ if (tvp2.getTag() != ValueTag.XS_STRING_TAG) {
+ throw new SystemException(ErrorCode.FORG0006);
+ }
+ TaggedValuePointable tempTvp = ppool.takeOne(TaggedValuePointable.class);
+ try {
+ mvs.reset();
+ sb.reset(mvs);
+ tvp1.getValue(op);
+ tvp2.getValue(sp);
+ if (op.getValue(sp, tempTvp)) {
+ sb.addItem(tempTvp);
+ }
+ sb.finish();
+ result.set(mvs);
+ } catch (IOException e) {
+ throw new SystemException(ErrorCode.SYSE0001, e);
+
+ } finally {
+ ppool.giveBack(tempTvp);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
index 8ae5828..2e10d85 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
@@ -767,35 +767,35 @@ public class XMLQueryTranslator {
return translateQuantifiedExprNode(tCtx, qeNode);
}
- /*
- case TYPESWITCH_EXPRESSION: {
- TypeswitchExprNode teNode = (TypeswitchExprNode) value;
- Expression sExpr = translateExpression(teNode.getSwitchExpr());
- ForLetVariable tVar = new ForLetVariable(VarTag.LET, createVarName(), sExpr);
- tVar.setDeclaredStaticType(SequenceType.create(AnyItemType.INSTANCE, Quantifier.QUANT_STAR));
+ /*
+ case TYPESWITCH_EXPRESSION: {
+ TypeswitchExprNode teNode = (TypeswitchExprNode) value;
+ Expression sExpr = translateExpression(teNode.getSwitchExpr());
+ ForLetVariable tVar = new ForLetVariable(VarTag.LET, createVarName(), sExpr);
+ tVar.setDeclaredStaticType(SequenceType.create(AnyItemType.INSTANCE, Quantifier.QUANT_STAR));
+ pushVariableScope();
+ varScope.registerVariable(tVar);
+ List<TypeswitchExpression.Case> cases = new ArrayList<TypeswitchExpression.Case>();
+ for (CaseClauseNode ccNode : teNode.getCaseClauses()) {
+ SequenceType type = createSequenceType(ccNode.getType());
+ ForLetVariable caseVar = null;
pushVariableScope();
- varScope.registerVariable(tVar);
- List<TypeswitchExpression.Case> cases = new ArrayList<TypeswitchExpression.Case>();
- for (CaseClauseNode ccNode : teNode.getCaseClauses()) {
- SequenceType type = createSequenceType(ccNode.getType());
- ForLetVariable caseVar = null;
- pushVariableScope();
- if (ccNode.getCaseVar() != null) {
- caseVar = new ForLetVariable(VarTag.LET, createQName(ccNode.getCaseVar()), new TreatExpression(
- currCtx, new VariableReferenceExpression(currCtx, tVar), type));
- caseVar.setDeclaredStaticType(type);
- varScope.registerVariable(caseVar);
- }
- Expression cExpr = translateExpression(ccNode.getValueExpr());
- TypeswitchExpression.Case c = new TypeswitchExpression.Case(caseVar, type, cExpr);
- cases.add(c);
- popVariableScope();
+ if (ccNode.getCaseVar() != null) {
+ caseVar = new ForLetVariable(VarTag.LET, createQName(ccNode.getCaseVar()), new TreatExpression(
+ currCtx, new VariableReferenceExpression(currCtx, tVar), type));
+ caseVar.setDeclaredStaticType(type);
+ varScope.registerVariable(caseVar);
}
- Expression dExpr = translateExpression(teNode.getDefaultClause());
+ Expression cExpr = translateExpression(ccNode.getValueExpr());
+ TypeswitchExpression.Case c = new TypeswitchExpression.Case(caseVar, type, cExpr);
+ cases.add(c);
popVariableScope();
- return new TypeswitchExpression(currCtx, tVar, cases, dExpr);
}
- */
+ Expression dExpr = translateExpression(teNode.getDefaultClause());
+ popVariableScope();
+ return new TypeswitchExpression(currCtx, tVar, cases, dExpr);
+ }
+ */
case COMPUTED_TEXT_CONSTRUCTOR: {
ComputedTextConstructorNode cNode = (ComputedTextConstructorNode) value;
@@ -1558,8 +1558,9 @@ public class XMLQueryTranslator {
ctxExpr = sfce(BuiltinOperators.VALUE, ctxExpr, argument);
}
}
- if (arguments.size() == 0)
- ctxExpr = expr;
+ if (arguments.size() == 0) {
+ ctxExpr = sfce(BuiltinOperators.KEYS, expr);
+ }
} else {
predicates = postfixNode.getArgs();
ctxExpr = expr;
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_keys1.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_keys1.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_keys1.txt
new file mode 100644
index 0000000..1c943a9
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_keys1.txt
@@ -0,0 +1,3 @@
+a
+b
+c
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_keys2.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_keys2.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_keys2.txt
new file mode 100644
index 0000000..6b17f11
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_keys2.txt
@@ -0,0 +1,2 @@
+blue
+fuchsia
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q01_object_navigation.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q01_object_navigation.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q01_object_navigation.txt
new file mode 100644
index 0000000..f5ac3db
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q01_object_navigation.txt
@@ -0,0 +1 @@
+blue
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q02_object_navigation.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q02_object_navigation.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q02_object_navigation.txt
new file mode 100644
index 0000000..181f563
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q02_object_navigation.txt
@@ -0,0 +1 @@
+{"eyes":"blue","hair":"brown"}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q03_object_navigation.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q03_object_navigation.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q03_object_navigation.txt
new file mode 100644
index 0000000..d800886
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q03_object_navigation.txt
@@ -0,0 +1 @@
+123
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q04_object_navigation.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q04_object_navigation.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q04_object_navigation.txt
new file mode 100644
index 0000000..4a20599
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q04_object_navigation.txt
@@ -0,0 +1,2 @@
+eyes
+hair
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q05_object_navigation.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q05_object_navigation.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q05_object_navigation.txt
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q06_object_navigation.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q06_object_navigation.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q06_object_navigation.txt
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q07_object_navigation.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q07_object_navigation.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/Navigation/q07_object_navigation.txt
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_keys1.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_keys1.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_keys1.xq
new file mode 100644
index 0000000..f45e307
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_keys1.xq
@@ -0,0 +1,22 @@
+(: 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 fn:data :)
+(
+ let $seq := ("foo", [ 1, 2, 3 ], { "a" : 1, "b" : 2 }, { "a" : 3, "c" : 4 })
+ return jn:keys($seq)
+)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_keys2.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_keys2.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_keys2.xq
new file mode 100644
index 0000000..9c58a1c
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_keys2.xq
@@ -0,0 +1,23 @@
+(: 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 fn:data :)
+(
+ let $map := { "eyes" : "blue", "hair" : "fuchsia" }
+ for $key in jn:keys($map)
+ return $map($key)
+)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q01_object_navigation.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q01_object_navigation.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q01_object_navigation.xq
new file mode 100644
index 0000000..9e048ae
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q01_object_navigation.xq
@@ -0,0 +1,20 @@
+(: 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. :)
+
+(: Json Object Navigation :)
+let $map := { "eyes" : "blue", "hair" : "fuchsia" }
+return $map("eyes")
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q02_object_navigation.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q02_object_navigation.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q02_object_navigation.xq
new file mode 100644
index 0000000..d8cea0b
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q02_object_navigation.xq
@@ -0,0 +1,21 @@
+(: 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. :)
+
+(: Json Object Navigation :)
+let $x := { "eyes" : "blue", "hair" : "fuchsia" }
+let $y := { "eyes" : "brown", "hair" : "brown" }
+return { "eyes" : $x("eyes"), "hair" : $y("hair") }
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q03_object_navigation.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q03_object_navigation.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q03_object_navigation.xq
new file mode 100644
index 0000000..a099be1
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q03_object_navigation.xq
@@ -0,0 +1,26 @@
+(: 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. :)
+
+(: Json Object Navigation :)
+let $object := {
+ "object1": {
+ "more": "object",
+ "number": 123
+ }
+ }
+
+return $object("object1")("number")
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q04_object_navigation.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q04_object_navigation.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q04_object_navigation.xq
new file mode 100644
index 0000000..dfb5e7c
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q04_object_navigation.xq
@@ -0,0 +1,20 @@
+(: 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. :)
+
+(: Json Object Navigation :)
+let $map := { "eyes" : "blue", "hair" : "fuchsia" }
+return $map()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q05_object_navigation.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q05_object_navigation.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q05_object_navigation.xq
new file mode 100644
index 0000000..b3253c7
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q05_object_navigation.xq
@@ -0,0 +1,20 @@
+(: 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. :)
+
+(: Json Object Navigation :)
+let $map := {}
+return $map()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q06_object_navigation.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q06_object_navigation.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q06_object_navigation.xq
new file mode 100644
index 0000000..1dd0ced
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q06_object_navigation.xq
@@ -0,0 +1,20 @@
+(: 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. :)
+
+(: Json Object Navigation :)
+let $map := {}
+return $map("key")
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q07_object_navigation.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q07_object_navigation.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q07_object_navigation.xq
new file mode 100644
index 0000000..048f573
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/Navigation/q07_object_navigation.xq
@@ -0,0 +1,20 @@
+(: 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. :)
+
+(: Json Object Navigation :)
+let $map := { "eyes" : "blue", "hair" : "fuchsia" }
+return $map("key")
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/VXQueryCatalog.xml b/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
index bf2728b..da8b22f 100644
--- a/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
+++ b/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
@@ -47,6 +47,8 @@
<!ENTITY JsonArrayQueries SYSTEM "cat/JsonArrayQueries.xml">
<!ENTITY JsonObjectQueries SYSTEM "cat/JsonObjectQueries.xml">
<!ENTITY FunctionsInJSONiq SYSTEM "cat/FunctionsInJSONiq.xml">
+<!ENTITY JsonObjectNavigationQueries SYSTEM "cat/JsonObjectNavigationQueries.xml">
+<!ENTITY JsonArrayNavigationQueries SYSTEM "cat/JsonArrayNavigationQueries.xml">
]>
<test-suite xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog"
@@ -67,33 +69,34 @@
</description>
</test-suite-info>
<sources>
- <source ID="VXQueryCatalog" FileName="VXQueryCatalog.xml" Creator="VXQuery team">
- <description last-mod="2014-04-02">VXQuery Test Suite Catalog</description>
- </source>
- <source ID="ghcnd" FileName="TestSources/ghcnd" Creator="Preston Carman">
- <description last-mod="2014-04-02">Collection of files</description>
- </source>
- <source ID="ghcnd_half_1" FileName="TestSources/ghcnd/half_1" Creator="Preston Carman">
- <description last-mod="2014-04-02">Collection of files</description>
- </source>
- <source ID="ghcnd_half_2" FileName="TestSources/ghcnd/half_2" Creator="Preston Carman">
- <description last-mod="2014-04-02">Collection of files</description>
- </source>
- <source ID="ghcnd_quarter_1" FileName="TestSources/ghcnd/half_1/quarter_1" Creator="Preston Carman">
- <description last-mod="2014-04-02">Collection of files</description>
- </source>
- <source ID="ghcnd_quarter_2" FileName="TestSources/ghcnd/half_1/quarter_2" Creator="Preston Carman">
- <description last-mod="2014-04-02">Collection of files</description>
- </source>
- <source ID="ghcnd_quarter_3" FileName="TestSources/ghcnd/half_2/quarter_3" Creator="Preston Carman">
- <description last-mod="2014-04-02">Collection of files</description>
- </source>
- <source ID="ghcnd_quarter_4" FileName="TestSources/ghcnd/half_2/quarter_4" Creator="Preston Carman">
- <description last-mod="2014-04-02">Collection of files</description>
- </source>
- <source ID="station_xml_file" FileName="TestSources/ghcnd/half_1/quarter_1/stations/US000000001.xml" Creator="Shivani Mall">
- <description last-mod="2015-06-26">File</description>
- </source>
+ <source ID="VXQueryCatalog" FileName="VXQueryCatalog.xml" Creator="VXQuery team">
+ <description last-mod="2014-04-02">VXQuery Test Suite Catalog</description>
+ </source>
+ <source ID="ghcnd" FileName="TestSources/ghcnd" Creator="Preston Carman">
+ <description last-mod="2014-04-02">Collection of files</description>
+ </source>
+ <source ID="ghcnd_half_1" FileName="TestSources/ghcnd/half_1" Creator="Preston Carman">
+ <description last-mod="2014-04-02">Collection of files</description>
+ </source>
+ <source ID="ghcnd_half_2" FileName="TestSources/ghcnd/half_2" Creator="Preston Carman">
+ <description last-mod="2014-04-02">Collection of files</description>
+ </source>
+ <source ID="ghcnd_quarter_1" FileName="TestSources/ghcnd/half_1/quarter_1" Creator="Preston Carman">
+ <description last-mod="2014-04-02">Collection of files</description>
+ </source>
+ <source ID="ghcnd_quarter_2" FileName="TestSources/ghcnd/half_1/quarter_2" Creator="Preston Carman">
+ <description last-mod="2014-04-02">Collection of files</description>
+ </source>
+ <source ID="ghcnd_quarter_3" FileName="TestSources/ghcnd/half_2/quarter_3" Creator="Preston Carman">
+ <description last-mod="2014-04-02">Collection of files</description>
+ </source>
+ <source ID="ghcnd_quarter_4" FileName="TestSources/ghcnd/half_2/quarter_4" Creator="Preston Carman">
+ <description last-mod="2014-04-02">Collection of files</description>
+ </source>
+ <source ID="station_xml_file" FileName="TestSources/ghcnd/half_1/quarter_1/stations/US000000001.xml"
+ Creator="Shivani Mall">
+ <description last-mod="2015-06-26">File</description>
+ </source>
</sources>
<test-group name="SingleQuery" featureOwner="Preston Carman">
<GroupInfo>
@@ -253,4 +256,17 @@
&FunctionsInJSONiq;
</test-group>
</test-group>
+ <test-group name="JsonNavigation" featureOwner="Riyafa Abdul Hameed">
+ <GroupInfo>
+ <title>Json navigation queries</title>
+ <description>Json navigation tests</description>
+ </GroupInfo>
+ <test-group name="JsonNavigationTesting" featureOwner="Riyafa Abdul Hameed">
+ <GroupInfo>
+ <title>Json navigation tests</title>
+ </GroupInfo>
+ &JsonObjectNavigationQueries;
+ &JsonArrayNavigationQueries;
+ </test-group>
+ </test-group>
</test-suite>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/cat/FunctionsInJSONiq.xml
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/cat/FunctionsInJSONiq.xml b/vxquery-xtest/src/test/resources/cat/FunctionsInJSONiq.xml
index 34f1237..e8aface 100644
--- a/vxquery-xtest/src/test/resources/cat/FunctionsInJSONiq.xml
+++ b/vxquery-xtest/src/test/resources/cat/FunctionsInJSONiq.xml
@@ -61,4 +61,14 @@
<query name="cast" date="2016-06-23"/>
<output-file compare="Text">cast.txt</output-file>
</test-case>
+ <test-case name="functions-in-jsoniq-jn_keys" FilePath="Json/Functions/" Creator="Riyafa Abdul Hameed">
+ <description>Query for cast for JSON null</description>
+ <query name="jn_keys1" date="2016-06-26"/>
+ <output-file compare="Text">jn_keys1.txt</output-file>
+ </test-case>
+ <test-case name="functions-in-jsoniq-jn_keys" FilePath="Json/Functions/" Creator="Riyafa Abdul Hameed">
+ <description>Query for cast for JSON null</description>
+ <query name="jn_keys2" date="2016-06-26"/>
+ <output-file compare="Text">jn_keys2.txt</output-file>
+ </test-case>
</test-group>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/vxquery/blob/f79a1218/vxquery-xtest/src/test/resources/cat/JsonObjectNavigationQueries.xml
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/cat/JsonObjectNavigationQueries.xml b/vxquery-xtest/src/test/resources/cat/JsonObjectNavigationQueries.xml
new file mode 100644
index 0000000..0fe4447
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/cat/JsonObjectNavigationQueries.xml
@@ -0,0 +1,59 @@
+<!--
+ 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.
+-->
+
+<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog" name="JsonObjectNavigationQueries"
+ featureOwner="VXQuery">
+ <GroupInfo>
+ <title>Json Object Navigation</title>
+ <description/>
+ </GroupInfo>
+ <test-case name="json-object-navigation-q01" FilePath="Json/Object/Navigation" Creator="Riyafa Abdul Hameed">
+ <description>Navigate through an object.</description>
+ <query name="q01_object_navigation" date="2016-06-25"/>
+ <output-file compare="Text">q01_object_navigation.txt</output-file>
+ </test-case>
+ <test-case name="json-object-navigation-q02" FilePath="Json/Object/Navigation" Creator="Riyafa Abdul Hameed">
+ <description>Navigate through an object.</description>
+ <query name="q02_object_navigation" date="2016-06-25"/>
+ <output-file compare="Text">q02_object_navigation.txt</output-file>
+ </test-case>
+ <test-case name="json-object-navigation-q03" FilePath="Json/Object/Navigation" Creator="Riyafa Abdul Hameed">
+ <description>Size of an object.</description>
+ <query name="q03_object_navigation" date="2016-06-25"/>
+ <output-file compare="Text">q03_object_navigation.txt</output-file>
+ </test-case>
+ <test-case name="json-object-navigation-q04" FilePath="Json/Object/Navigation" Creator="Riyafa Abdul Hameed">
+ <description>Navigate through an empty object.</description>
+ <query name="q04_object_navigation" date="2016-06-25"/>
+ <output-file compare="Text">q04_object_navigation.txt</output-file>
+ </test-case>
+ <test-case name="json-object-navigation-q05" FilePath="Json/Object/Navigation" Creator="Riyafa Abdul Hameed">
+ <description>Ask for an index out of the object size.</description>
+ <query name="q05_object_navigation" date="2016-06-25"/>
+ <output-file compare="Text">q05_object_navigation.txt</output-file>
+ </test-case>
+ <test-case name="json-object-navigation-q06" FilePath="Json/Object/Navigation" Creator="Riyafa Abdul Hameed">
+ <description>Ask for an index out of the object size.</description>
+ <query name="q06_object_navigation" date="2016-06-25"/>
+ <output-file compare="Text">q06_object_navigation.txt</output-file>
+ </test-case>
+ <test-case name="json-object-navigation-q07" FilePath="Json/Object/Navigation" Creator="Riyafa Abdul Hameed">
+ <description>Ask for an index out of the object size.</description>
+ <query name="q07_object_navigation" date="2016-06-25"/>
+ <output-file compare="Text">q07_object_navigation.txt</output-file>
+ </test-case>
+</test-group>