http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayConstructorScalarEvaluator.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayConstructorScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayConstructorScalarEvaluator.java new file mode 100644 index 0000000..7386ce9 --- /dev/null +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayConstructorScalarEvaluator.java @@ -0,0 +1,76 @@ +/* + * 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.node; + +import java.io.IOException; + +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.builders.jsonitem.ArrayBuilder; +import org.apache.vxquery.datamodel.values.ValueTag; +import org.apache.vxquery.exceptions.SystemException; +import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator; + +public class ArrayConstructorScalarEvaluator extends AbstractTaggedValueArgumentScalarEvaluator { + protected final IHyracksTaskContext ctx; + + private final ArrayBackedValueStorage mvs; + + private final ArrayBuilder ab; + + private final SequencePointable sp; + + public ArrayConstructorScalarEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) { + super(args); + this.ctx = ctx; + ab = new ArrayBuilder(); + sp = (SequencePointable) SequencePointable.FACTORY.createPointable(); + mvs = new ArrayBackedValueStorage(); + } + + @Override + protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException { + mvs.reset(); + try { + ab.reset(mvs); + TaggedValuePointable arg = args[0]; + if (arg.getTag() == ValueTag.SEQUENCE_TAG) { + TaggedValuePointable tempTvp = ppool.takeOne(TaggedValuePointable.class); + try { + arg.getValue(sp); + for (int i = 0; i < sp.getEntryCount(); ++i) { + sp.getEntry(i, tempTvp); + ab.addItem(tempTvp); + } + } finally { + ppool.giveBack(tempTvp); + } + } else { + ab.addItem(arg); + } + ab.finish(); + } catch (IOException e) { + e.printStackTrace(); + } + result.set(mvs); + } + +}
http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayConstructorScalarEvaluatorFactory.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayConstructorScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayConstructorScalarEvaluatorFactory.java new file mode 100644 index 0000000..c70a8e2 --- /dev/null +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayConstructorScalarEvaluatorFactory.java @@ -0,0 +1,37 @@ +/* + * 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.node; + +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 ArrayConstructorScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory { + private static final long serialVersionUID = 1L; + + public ArrayConstructorScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) { + super(args); + } + + @Override + protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) + throws AlgebricksException { + return new ArrayConstructorScalarEvaluator(ctx, args); + } +} http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayNodeConstructorScalarEvaluator.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayNodeConstructorScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayNodeConstructorScalarEvaluator.java deleted file mode 100644 index 05f4498..0000000 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayNodeConstructorScalarEvaluator.java +++ /dev/null @@ -1,69 +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.node; - -import java.io.IOException; - -import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; -import org.apache.hyracks.api.context.IHyracksTaskContext; -import org.apache.hyracks.data.std.api.IMutableValueStorage; -import org.apache.vxquery.datamodel.accessors.SequencePointable; -import org.apache.vxquery.datamodel.accessors.TaggedValuePointable; -import org.apache.vxquery.datamodel.builders.jsonitem.ArrayBuilder; -import org.apache.vxquery.datamodel.builders.nodes.DictionaryBuilder; -import org.apache.vxquery.datamodel.values.ValueTag; -import org.apache.vxquery.exceptions.SystemException; - -public class ArrayNodeConstructorScalarEvaluator extends AbstractNodeConstructorScalarEvaluator { - private final ArrayBuilder ab; - - private final SequencePointable sp; - - public ArrayNodeConstructorScalarEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) { - super(ctx, args); - ab = new ArrayBuilder(); - sp = (SequencePointable) SequencePointable.FACTORY.createPointable(); - } - - @Override - protected void constructNode(DictionaryBuilder db, TaggedValuePointable[] args, IMutableValueStorage mvs) - throws IOException, SystemException { - ab.reset(mvs); - TaggedValuePointable arg = args[0]; - if (arg.getTag() == ValueTag.SEQUENCE_TAG) { - TaggedValuePointable tempTvp = ppool.takeOne(TaggedValuePointable.class); - try { - arg.getValue(sp); - for (int i = 0; i < sp.getEntryCount(); ++i) { - sp.getEntry(i, tempTvp); - ab.addItem(tempTvp); - } - } finally { - ppool.giveBack(tempTvp); - } - } else { - ab.addItem(arg); - } - ab.finish(); - } - - @Override - protected boolean createsDictionary() { - return false; - } - -} http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayNodeConstructorScalarEvaluatorFactory.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayNodeConstructorScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayNodeConstructorScalarEvaluatorFactory.java deleted file mode 100644 index e32034c..0000000 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/ArrayNodeConstructorScalarEvaluatorFactory.java +++ /dev/null @@ -1,37 +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.node; - -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 ArrayNodeConstructorScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory { - private static final long serialVersionUID = 1L; - - public ArrayNodeConstructorScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) { - super(args); - } - - @Override - protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) - throws AlgebricksException { - return new ArrayNodeConstructorScalarEvaluator(ctx, args); - } -} http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java b/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java index 9e1b663..8b83995 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java @@ -222,7 +222,7 @@ public class XMLSerializer implements IPrinter { break; case ValueTag.ARRAY_TAG: - printArrayNode(ps, tvp); + printArray(ps, tvp); break; case ValueTag.ATTRIBUTE_NODE_TAG: @@ -446,28 +446,22 @@ public class XMLSerializer implements IPrinter { } } - private void printArrayNode(PrintStream ps, TaggedValuePointable tvp) { + private void printArray(PrintStream ps, TaggedValuePointable tvp) { ArrayPointable ap = pp.takeOne(ArrayPointable.class); - try { tvp.getValue(ap); - if (tvp.getTag() == ValueTag.ARRAY_TAG) { - tvp.getValue(ap); - int len = ap.getEntryCount(); - ps.append('['); - ps.append(' '); - for (int i = 0; i < len; i++) { - ap.getEntry(i, tvp); - print(tvp.getByteArray(), tvp.getStartOffset(), tvp.getLength(), ps); - if (i != len - 1) { - ps.append(','); - ps.append(' '); - } + int len = ap.getEntryCount(); + ps.append('['); + ps.append(' '); + for (int i = 0; i < len; i++) { + ap.getEntry(i, tvp); + print(tvp.getByteArray(), tvp.getStartOffset(), tvp.getLength(), ps); + if (i != len - 1) { + ps.append(','); } ps.append(' '); - ps.append(']'); } - + ps.append(']'); } finally { pp.giveBack(ap); pp.giveBack(tvp); http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ArrayConstructor.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ArrayConstructor.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ArrayConstructor.java new file mode 100644 index 0000000..65ec6b6 --- /dev/null +++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ArrayConstructor.java @@ -0,0 +1,40 @@ +/* +* 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.xmlquery.ast; + +import org.apache.vxquery.util.SourceLocation; + +public class ArrayConstructor extends ASTNode { + private ASTNode expression; + + public ArrayConstructor(SourceLocation loc) { + super(loc); + } + + @Override + public ASTTag getTag() { + return ASTTag.ARRAY_CONSTRUCTOR; + } + + public ASTNode getExpression() { + return expression; + } + + public void setExpression(ASTNode expression) { + this.expression = expression; + } +} http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ArrayConstructorNode.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ArrayConstructorNode.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ArrayConstructorNode.java deleted file mode 100644 index cf034a3..0000000 --- a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ArrayConstructorNode.java +++ /dev/null @@ -1,40 +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.xmlquery.ast; - -import org.apache.vxquery.util.SourceLocation; - -public class ArrayConstructorNode extends ASTNode { - private ASTNode expression; - - public ArrayConstructorNode(SourceLocation loc) { - super(loc); - } - - @Override - public ASTTag getTag() { - return ASTTag.ARRAY_CONSTRUCTOR; - } - - public ASTNode getExpression() { - return expression; - } - - public void setExpression(ASTNode expression) { - this.expression = expression; - } -} http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/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 d684e34..047ffc8 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 @@ -98,7 +98,7 @@ import org.apache.vxquery.types.TextType; import org.apache.vxquery.types.TypeUtils; import org.apache.vxquery.xmlquery.ast.ASTNode; import org.apache.vxquery.xmlquery.ast.ASTTag; -import org.apache.vxquery.xmlquery.ast.ArrayConstructorNode; +import org.apache.vxquery.xmlquery.ast.ArrayConstructor; import org.apache.vxquery.xmlquery.ast.AtomicTypeNode; import org.apache.vxquery.xmlquery.ast.AttributeTestNode; import org.apache.vxquery.xmlquery.ast.AxisStepNode; @@ -820,8 +820,8 @@ public class XMLQueryTranslator { } case ARRAY_CONSTRUCTOR: { - ArrayConstructorNode aNode = (ArrayConstructorNode) value; - return translateArrayConstructorNode(tCtx, aNode); + ArrayConstructor aNode = (ArrayConstructor) value; + return translateArrayConstructor(tCtx, aNode); } case COMPUTED_ATTRIBUTE_CONSTRUCTOR: { @@ -977,13 +977,12 @@ public class XMLQueryTranslator { return lVar; } - private LogicalVariable translateArrayConstructorNode(TranslationContext tCtx, ArrayConstructorNode aNode) + private LogicalVariable translateArrayConstructor(TranslationContext tCtx, ArrayConstructor aNode) throws SystemException { - ILogicalExpression name = vre(translateExpression(aNode.getExpression(), tCtx)); ASTNode expression = aNode.getExpression(); ILogicalExpression aExpr = expression == null ? sfce(BuiltinOperators.CONCATENATE) : vre(translateExpression(expression, tCtx)); - LogicalVariable lVar = createAssignment(sfce(BuiltinOperators.ARRAY_CONSTRUCTOR, name, aExpr), tCtx); + LogicalVariable lVar = createAssignment(sfce(BuiltinOperators.ARRAY_CONSTRUCTOR, aExpr), tCtx); return lVar; } http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-core/src/main/javacc/xquery-grammar.jj ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/javacc/xquery-grammar.jj b/vxquery-core/src/main/javacc/xquery-grammar.jj index de1272b..6dc9865 100644 --- a/vxquery-core/src/main/javacc/xquery-grammar.jj +++ b/vxquery-core/src/main/javacc/xquery-grammar.jj @@ -2456,12 +2456,12 @@ ASTNode JsonConstructor() : ASTNode ArrayConstructor() : { - ASTNode expr; + ASTNode expr=null; Token start; } { - (start = "[") expr = Expr() "]" { - ArrayConstructorNode an = new ArrayConstructorNode(createSourceLocation(start)); + (start = "[") [expr = Expr()] "]" { + ArrayConstructor an = new ArrayConstructor(createSourceLocation(start)); an.setExpression(expr); return an; } http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q01_array.txt ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q01_array.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q01_array.txt new file mode 100644 index 0000000..404b10d --- /dev/null +++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q01_array.txt @@ -0,0 +1 @@ +[ 1 ] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q02_array.txt ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q02_array.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q02_array.txt new file mode 100644 index 0000000..6038e9b --- /dev/null +++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q02_array.txt @@ -0,0 +1 @@ +[ 1, string, 3.1 ] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q03_array.txt ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q03_array.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q03_array.txt new file mode 100644 index 0000000..6330c79 --- /dev/null +++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q03_array.txt @@ -0,0 +1 @@ +[ [ 1, 2 ], [ 2, 3 ] ] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q04_array.txt ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q04_array.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q04_array.txt new file mode 100644 index 0000000..8878e54 --- /dev/null +++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Array/q04_array.txt @@ -0,0 +1 @@ +[ ] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/q01_object.txt ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/q01_object.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/q01_object.txt new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Object/q01_object.txt @@ -0,0 +1 @@ +1 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q01_array.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q01_array.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q01_array.xq new file mode 100644 index 0000000..ecb653d --- /dev/null +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q01_array.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 Array Query :) +(: Just parse an array with a single item :) + [1] http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q02_array.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q02_array.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q02_array.xq new file mode 100644 index 0000000..4954f21 --- /dev/null +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q02_array.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 Array Query :) +(: Just parse an array with a sequence of items :) + [1,"string",3.1] http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q03_array.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q03_array.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q03_array.xq new file mode 100644 index 0000000..f9913be --- /dev/null +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q03_array.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 Array Query :) +(: Just parse an array with nested arrays :) + [[1,2],[2,3]] http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q04_array.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q04_array.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q04_array.xq new file mode 100644 index 0000000..de1447e --- /dev/null +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Array/q04_array.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 Array Query :) +(: Just parse an empty array :) + [] http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/q01_object.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/q01_object.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/q01_object.xq new file mode 100644 index 0000000..52c9044 --- /dev/null +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Object/q01_object.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 Query :) +(: Just an object example :) + 1 http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/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 f75ce49..076341e 100644 --- a/vxquery-xtest/src/test/resources/VXQueryCatalog.xml +++ b/vxquery-xtest/src/test/resources/VXQueryCatalog.xml @@ -42,6 +42,9 @@ <!ENTITY HDFSAggregateQueries SYSTEM "cat/HDFSAggregateQueries.xml"> +<!ENTITY JsonArrayQueries SYSTEM "cat/JsonArrayQueries.xml"> +<!ENTITY JsonObjectQueries SYSTEM "cat/JsonObjectQueries.xml"> + ]> <test-suite xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" @@ -208,4 +211,18 @@ &HDFSAggregateQueries; </test-group> </test-group> + <test-group name="JsoniqQueries" featureOwner="Christina Pavlopoulou"> + <GroupInfo> + <title>Jsoniq Queries</title> + <description/> + </GroupInfo> + <test-group name="JsoniqTesting" featureOwner="Christina Pavlopoulou"> + <GroupInfo> + <title>Json Constructor Tests</title> + <description/> + </GroupInfo> + &JsonArrayQueries; + &JsonObjectQueries; + </test-group> + </test-group> </test-suite> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-xtest/src/test/resources/cat/JsonArrayQueries.xml ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/cat/JsonArrayQueries.xml b/vxquery-xtest/src/test/resources/cat/JsonArrayQueries.xml new file mode 100644 index 0000000..cfa18af --- /dev/null +++ b/vxquery-xtest/src/test/resources/cat/JsonArrayQueries.xml @@ -0,0 +1,43 @@ +<!-- + 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="JsonArrayQueries" featureOwner="VXQuery"> + <GroupInfo> + <title>Json Array</title> + <description/> + </GroupInfo> + <test-case name="json-array-q01" FilePath="Json/Array/" Creator="Christina Pavlopoulou"> + <description>Array with a single item.</description> + <query name="q01_array" date="2016-06-09"/> + <output-file compare="Text">q01_array.txt</output-file> + </test-case> + <test-case name="json-array-q02" FilePath="Json/Array/" Creator="Christina Pavlopoulou"> + <description>Array with a sequence of items.</description> + <query name="q02_array" date="2016-06-09"/> + <output-file compare="Text">q02_array.txt</output-file> + </test-case> + <test-case name="json-array-q03" FilePath="Json/Array/" Creator="Christina Pavlopoulou"> + <description>Array with a sequence of items.</description> + <query name="q03_array" date="2016-06-09"/> + <output-file compare="Text">q03_array.txt</output-file> + </test-case> + <test-case name="json-array-q04" FilePath="Json/Array/" Creator="Christina Pavlopoulou"> + <description>Empty array.</description> + <query name="q04_array" date="2016-06-09"/> + <output-file compare="Text">q04_array.txt</output-file> + </test-case> +</test-group> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/bb1fa8ec/vxquery-xtest/src/test/resources/cat/JsonObjectQueries.xml ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/cat/JsonObjectQueries.xml b/vxquery-xtest/src/test/resources/cat/JsonObjectQueries.xml new file mode 100644 index 0000000..dcdf6e6 --- /dev/null +++ b/vxquery-xtest/src/test/resources/cat/JsonObjectQueries.xml @@ -0,0 +1,28 @@ +<!-- + 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="JsonObjectQueries" featureOwner="VXQuery"> + <GroupInfo> + <title>Json Object</title> + <description/> + </GroupInfo> + <test-case name="json-object-q01" FilePath="Json/Object/" Creator="Christina Pavlopoulou"> + <description>Object.</description> + <query name="q01_object" date="2016-06-09"/> + <output-file compare="Text">q01_object.txt</output-file> + </test-case> +</test-group> \ No newline at end of file
