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/21 18:23:53 UTC
vxquery git commit: Corrections for jn:size
Repository: vxquery
Updated Branches:
refs/heads/master 6d2732fa0 -> 5a9053bb6
Corrections for jn:size
Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/5a9053bb
Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/5a9053bb
Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/5a9053bb
Branch: refs/heads/master
Commit: 5a9053bb64403c4253d8a6c07a99e52a682d54fc
Parents: 6d2732f
Author: Christina Pavlopoulou <cp...@ucr.edu>
Authored: Sun Aug 21 10:15:28 2016 -0700
Committer: Christina Pavlopoulou <cp...@ucr.edu>
Committed: Sun Aug 21 10:19:28 2016 -0700
----------------------------------------------------------------------
.../vxquery/functions/builtin-functions.xml | 6 +-
.../misc/FnSizeScalarEvaluatorFactory.java | 77 --------------------
.../misc/JnSizeScalarEvaluatorFactory.java | 77 ++++++++++++++++++++
.../Array/Navigation/q03_array_navigation.xq | 2 +-
4 files changed, 81 insertions(+), 81 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/vxquery/blob/5a9053bb/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 9156331..10ca007 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
@@ -254,11 +254,11 @@
</property>
</function>
- <!-- fn:size($expr as item()*) as xs:anyAtomicType* -->
- <function name="fn:size">
+ <!-- jn:size($expr as item()*) as xs:anyAtomicType* -->
+ <function name="jn:size">
<param name="expr" type="item()*"/>
<return type="xs:integer"/>
- <runtime type="scalar" class="org.apache.vxquery.runtime.functions.misc.FnSizeScalarEvaluatorFactory"/>
+ <runtime type="scalar" class="org.apache.vxquery.runtime.functions.misc.JnSizeScalarEvaluatorFactory"/>
</function>
<!-- fn:dateTime($arg1 as xs:date?, $arg2 as xs:time?) as xs:dateTime? -->
http://git-wip-us.apache.org/repos/asf/vxquery/blob/5a9053bb/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/FnSizeScalarEvaluatorFactory.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/FnSizeScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/FnSizeScalarEvaluatorFactory.java
deleted file mode 100644
index 3ff935f..0000000
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/FnSizeScalarEvaluatorFactory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.misc;
-
-import java.io.DataOutput;
-import java.io.IOException;
-
-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.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.accessors.jsonitem.ArrayPointable;
-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.base.AbstractTaggedValueArgumentScalarEvaluatorFactory;
-
-public class FnSizeScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory {
-
- private static final long serialVersionUID = 1L;
-
- public FnSizeScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
- super(args);
- }
-
- @Override
- protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
- throws AlgebricksException {
- return new FnSizeScalarEvaluator(args);
- }
-
- private static class FnSizeScalarEvaluator extends AbstractTaggedValueArgumentScalarEvaluator {
- final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
- final ArrayPointable ap = (ArrayPointable) ArrayPointable.FACTORY.createPointable();
-
- public FnSizeScalarEvaluator(IScalarEvaluator[] args) {
- super(args);
- }
-
- @Override
- protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
- TaggedValuePointable tvp = args[0];
- if (!(tvp.getTag() != ValueTag.ARRAY_TAG || tvp.getTag() != ValueTag.OBJECT_TAG)) {
- throw new SystemException(ErrorCode.FORG0006);
- }
- abvs.reset();
- tvp.getValue(ap);
- DataOutput out = abvs.getDataOutput();
- ap.getEntryCount();
- try {
- out.write(ValueTag.XS_INTEGER_TAG);
- out.writeLong(ap.getEntryCount());
- } catch (IOException e) {
- e.printStackTrace();
- }
- result.set(abvs);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/vxquery/blob/5a9053bb/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/JnSizeScalarEvaluatorFactory.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/JnSizeScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/JnSizeScalarEvaluatorFactory.java
new file mode 100644
index 0000000..9ad34fa
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/JnSizeScalarEvaluatorFactory.java
@@ -0,0 +1,77 @@
+/*
+ * 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.misc;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+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.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.accessors.jsonitem.ArrayPointable;
+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.base.AbstractTaggedValueArgumentScalarEvaluatorFactory;
+
+public class JnSizeScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory {
+
+ private static final long serialVersionUID = 1L;
+
+ public JnSizeScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+ super(args);
+ }
+
+ @Override
+ protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
+ throws AlgebricksException {
+ return new JnSizeScalarEvaluator(args);
+ }
+
+ private static class JnSizeScalarEvaluator extends AbstractTaggedValueArgumentScalarEvaluator {
+ final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
+ final ArrayPointable ap = (ArrayPointable) ArrayPointable.FACTORY.createPointable();
+
+ public JnSizeScalarEvaluator(IScalarEvaluator[] args) {
+ super(args);
+ }
+
+ @Override
+ protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
+ TaggedValuePointable tvp = args[0];
+ if (!(tvp.getTag() != ValueTag.ARRAY_TAG || tvp.getTag() != ValueTag.OBJECT_TAG)) {
+ throw new SystemException(ErrorCode.FORG0006);
+ }
+ abvs.reset();
+ tvp.getValue(ap);
+ DataOutput out = abvs.getDataOutput();
+ ap.getEntryCount();
+ try {
+ out.write(ValueTag.XS_INTEGER_TAG);
+ out.writeLong(ap.getEntryCount());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ result.set(abvs);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/vxquery/blob/5a9053bb/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/Navigation/q03_array_navigation.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/Navigation/q03_array_navigation.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/Navigation/q03_array_navigation.xq
index 00afac3..179fb11 100644
--- a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/Navigation/q03_array_navigation.xq
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/Navigation/q03_array_navigation.xq
@@ -18,5 +18,5 @@
(: Json Array Size Query :)
(: Size of an array :)
let $x:=[2,[2,1,3]]
- return size($x)
+ return jn:size($x)
\ No newline at end of file