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/29 00:21:30 UTC
vxquery git commit: Updating libjn:descendant-arrays
Repository: vxquery
Updated Branches:
refs/heads/master b6f0f7d74 -> fa0b77a84
Updating libjn:descendant-arrays
Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/fa0b77a8
Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/fa0b77a8
Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/fa0b77a8
Branch: refs/heads/master
Commit: fa0b77a8444631ac70315c9a525b229d5c98e5b7
Parents: b6f0f7d
Author: Christina Pavlopoulou <cp...@ucr.edu>
Authored: Thu Jul 28 10:23:05 2016 -0700
Committer: Christina Pavlopoulou <cp...@ucr.edu>
Committed: Thu Jul 28 10:23:05 2016 -0700
----------------------------------------------------------------------
...nDescendantArraysScalarEvaluatorFactory.java | 34 +++++++++++++++-----
.../Json/Libraries/descendant_arrays3.txt | 2 ++
.../XQuery/Json/Libraries/descendant_arrays3.xq | 21 ++++++++++++
.../test/resources/cat/LibrariesInJSONiq.xml | 5 +++
4 files changed, 54 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/vxquery/blob/fa0b77a8/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/LibjnDescendantArraysScalarEvaluatorFactory.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/LibjnDescendantArraysScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/LibjnDescendantArraysScalarEvaluatorFactory.java
index 7896555..4899d9b 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/LibjnDescendantArraysScalarEvaluatorFactory.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/LibjnDescendantArraysScalarEvaluatorFactory.java
@@ -50,7 +50,6 @@ public class LibjnDescendantArraysScalarEvaluatorFactory extends AbstractTaggedV
throws AlgebricksException {
final SequencePointable sp = (SequencePointable) SequencePointable.FACTORY.createPointable();
final ArrayPointable ap = (ArrayPointable) ArrayPointable.FACTORY.createPointable();
- final ObjectPointable op = (ObjectPointable) ObjectPointable.FACTORY.createPointable();
final UTF8StringPointable stringp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
final SequenceBuilder sb = new SequenceBuilder();
final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
@@ -117,21 +116,40 @@ public class LibjnDescendantArraysScalarEvaluatorFactory extends AbstractTaggedV
}
public void insideObject(TaggedValuePointable tvp) throws SystemException {
- tvp.getValue(op);
TaggedValuePointable tempTvp = ppool.takeOne(TaggedValuePointable.class);
+ ObjectPointable op = ppool.takeOne(ObjectPointable.class);
+ SequencePointable sp = ppool.takeOne(SequencePointable.class);
+ tvp.getValue(op);
try {
op.getKeys(tvp);
- tvp.getValue(stringp);
- op.getValue(stringp, tempTvp);
+ if (tvp.getTag() == ValueTag.XS_STRING_TAG) {
+ tvp.getValue(stringp);
+ op.getValue(stringp, tempTvp);
+ checkFunction(tempTvp);
+ } else if (tvp.getTag() == ValueTag.SEQUENCE_TAG) {
+ tvp.getValue(sp);
+ int size = sp.getEntryCount();
+ for (int i = 0; i < size; i++) {
+ sp.getEntry(i, tempTvp);
+ tempTvp.getValue(stringp);
+ op.getValue(stringp, tempTvp);
+ checkFunction(tempTvp);
+ }
+ }
} catch (IOException e1) {
throw new SystemException(ErrorCode.SYSE0001, e1);
}
- if (tempTvp.getTag() == ValueTag.OBJECT_TAG) {
- insideObject(tempTvp);
+ ppool.giveBack(sp);
+ ppool.giveBack(op);
+ ppool.giveBack(tempTvp);
+ }
+
+ public void checkFunction(TaggedValuePointable tvp) throws SystemException {
+ if (tvp.getTag() == ValueTag.OBJECT_TAG) {
+ insideObject(tvp);
} else {
- nested(tempTvp, ap);
+ nested(tvp, ap);
}
- ppool.giveBack(tempTvp);
}
};
}
http://git-wip-us.apache.org/repos/asf/vxquery/blob/fa0b77a8/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Libraries/descendant_arrays3.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Libraries/descendant_arrays3.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Libraries/descendant_arrays3.txt
new file mode 100644
index 0000000..57ad8a3
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Libraries/descendant_arrays3.txt
@@ -0,0 +1,2 @@
+[1,2]
+[3,4]
http://git-wip-us.apache.org/repos/asf/vxquery/blob/fa0b77a8/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Libraries/descendant_arrays3.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Libraries/descendant_arrays3.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Libraries/descendant_arrays3.xq
new file mode 100644
index 0000000..7f4fad8
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Libraries/descendant_arrays3.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. :)
+
+(: JSONiq libjn:descendant_arrays :)
+(
+ libjn:descendant-arrays({"foo": [1,2], "bar":[3,4]})
+)
http://git-wip-us.apache.org/repos/asf/vxquery/blob/fa0b77a8/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 4c18447..fcae9a9 100644
--- a/vxquery-xtest/src/test/resources/cat/LibrariesInJSONiq.xml
+++ b/vxquery-xtest/src/test/resources/cat/LibrariesInJSONiq.xml
@@ -30,6 +30,11 @@
<query name="descendant_arrays2" date="2016-07-19"/>
<output-file compare="Text">descendant_arrays2.txt</output-file>
</test-case>
+ <test-case name="descendant-arrays3" FilePath="Json/Libraries/" Creator="Christina Pavlopoulou">
+ <description>Json Libraries.</description>
+ <query name="descendant_arrays3" date="2016-07-28"/>
+ <output-file compare="Text">descendant_arrays3.txt</output-file>
+ </test-case>
<test-case name="flatten" FilePath="Json/Libraries/" Creator="Christina Pavlopoulou">
<description>Json Libraries.</description>
<query name="flatten" date="2016-07-20"/>