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 2014/02/13 18:17:51 UTC
[01/10] git commit: Updated the timing to show the average of all the
repeated runs after the first three.
Updated Branches:
refs/heads/prestonc/benchmarks 19a71c575 -> b98e16529
Updated the timing to show the average of all the repeated runs after the first three.
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/ce12767e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/ce12767e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/ce12767e
Branch: refs/heads/prestonc/benchmarks
Commit: ce12767ed11c379f6e4dfc50afffc091a53ea9e8
Parents: 19a71c5
Author: Preston Carman <pr...@apache.org>
Authored: Mon Feb 10 21:29:50 2014 -0800
Committer: Preston Carman <pr...@apache.org>
Committed: Mon Feb 10 21:29:50 2014 -0800
----------------------------------------------------------------------
.../main/java/org/apache/vxquery/cli/VXQuery.java | 15 +++++++++------
...tractValueFromDurationScalarEvaluatorFactory.java | 2 --
2 files changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/ce12767e/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
----------------------------------------------------------------------
diff --git a/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java b/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
index bc4fb61..24d3b78 100644
--- a/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
+++ b/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
@@ -79,6 +79,7 @@ public class VXQuery {
private ResultSetId resultSetId;
private static List<String> timing;
+ private static int totalTiming;
private static String message;
/**
@@ -99,7 +100,6 @@ public class VXQuery {
* @throws Exception
*/
public static void main(String[] args) throws Exception {
- Date start = new Date();
final CmdLineOptions opts = new CmdLineOptions();
CmdLineParser parser = new CmdLineParser(opts);
@@ -116,13 +116,13 @@ public class VXQuery {
}
VXQuery vxq = new VXQuery(opts);
vxq.execute();
- Date end = new Date();
// if -timing argument passed, show the starting and ending times
if (opts.timing) {
- message = "Execution time: " + (end.getTime() - start.getTime()) + "ms";
- System.out.println(message);
- timing.add(message);
-
+ if (opts.repeatExec > 3) {
+ message = "Average execution time: " + (totalTiming / (opts.repeatExec - 3)) + "ms";
+ System.out.println(message);
+ timing.add(message);
+ }
System.out.println("Timing Summary:");
for (String time : timing) {
System.out.println(" " + time);
@@ -274,6 +274,9 @@ public class VXQuery {
end = new Date();
// if -timing argument passed, show the starting and ending times
if (opts.timing) {
+ if ((i + 1) > 3) {
+ totalTiming += end.getTime() - start.getTime();
+ }
message = "Job (" + (i + 1) + ") execution time: " + (end.getTime() - start.getTime()) + "ms";
System.out.println(message);
timing.add(message);
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/ce12767e/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/AbstractValueFromDurationScalarEvaluatorFactory.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/AbstractValueFromDurationScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/AbstractValueFromDurationScalarEvaluatorFactory.java
index f54705b..2709d6d 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/AbstractValueFromDurationScalarEvaluatorFactory.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/datetime/AbstractValueFromDurationScalarEvaluatorFactory.java
@@ -19,8 +19,6 @@ package org.apache.vxquery.runtime.functions.datetime;
import java.io.DataOutput;
import java.io.IOException;
-import org.apache.vxquery.datamodel.accessors.PointablePool;
-import org.apache.vxquery.datamodel.accessors.PointablePoolFactory;
import org.apache.vxquery.datamodel.accessors.SequencePointable;
import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
import org.apache.vxquery.datamodel.accessors.atomic.XSDurationPointable;
[10/10] git commit: Removed paintable pool.
Posted by pr...@apache.org.
Removed paintable pool.
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/b98e1652
Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/b98e1652
Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/b98e1652
Branch: refs/heads/prestonc/benchmarks
Commit: b98e16529a64b727e42366f00212240e84dca2f4
Parents: f082dd4
Author: Preston Carman <pr...@apache.org>
Authored: Thu Feb 13 09:17:32 2014 -0800
Committer: Preston Carman <pr...@apache.org>
Committed: Thu Feb 13 09:17:32 2014 -0800
----------------------------------------------------------------------
.../bool/FnBooleanScalarEvaluator.java | 91 ++++++++++----------
1 file changed, 47 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/b98e1652/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/FnBooleanScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/FnBooleanScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/FnBooleanScalarEvaluator.java
index e2fd431..a666864 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/FnBooleanScalarEvaluator.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/FnBooleanScalarEvaluator.java
@@ -36,22 +36,31 @@ import edu.uci.ics.hyracks.data.std.primitive.ShortPointable;
import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
public class FnBooleanScalarEvaluator extends AbstractTaggedValueArgumentScalarEvaluator {
+ final BytePointable bp = (BytePointable) BytePointable.FACTORY.createPointable();
+ final XSDecimalPointable decp = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
+ final DoublePointable dp = (DoublePointable) DoublePointable.FACTORY.createPointable();
+ final FloatPointable fp = (FloatPointable) FloatPointable.FACTORY.createPointable();
+ final IntegerPointable ip = (IntegerPointable) IntegerPointable.FACTORY.createPointable();
+ final LongPointable lp = (LongPointable) LongPointable.FACTORY.createPointable();
+ final SequencePointable seqp = new SequencePointable();
+ final ShortPointable sp = (ShortPointable) ShortPointable.FACTORY.createPointable();
+ final UTF8StringPointable utf8p = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
+
public FnBooleanScalarEvaluator(IScalarEvaluator[] args) {
super(args);
}
protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
TaggedValuePointable tvp = args[0];
- boolean booleanResult = true;
switch (tvp.getTag()) {
case ValueTag.SEQUENCE_TAG: {
- SequencePointable seqp = ppool.takeOne(SequencePointable.class);
tvp.getValue(seqp);
if (seqp.getEntryCount() == 0) {
- booleanResult = false;
+ XDMConstants.setFalse(result);
+ return;
}
- ppool.giveBack(seqp);
- break;
+ XDMConstants.setTrue(result);
+ return;
}
case ValueTag.XS_BOOLEAN_TAG: {
@@ -60,13 +69,13 @@ public class FnBooleanScalarEvaluator extends AbstractTaggedValueArgumentScalarE
}
case ValueTag.XS_DECIMAL_TAG: {
- XSDecimalPointable decp = ppool.takeOne(XSDecimalPointable.class);
tvp.getValue(decp);
if (decp.longValue() == 0) {
- booleanResult = false;
+ XDMConstants.setFalse(result);
+ return;
}
- ppool.giveBack(decp);
- break;
+ XDMConstants.setTrue(result);
+ return;
}
case ValueTag.XS_INTEGER_TAG:
@@ -77,84 +86,78 @@ public class FnBooleanScalarEvaluator extends AbstractTaggedValueArgumentScalarE
case ValueTag.XS_POSITIVE_INTEGER_TAG:
case ValueTag.XS_UNSIGNED_INT_TAG:
case ValueTag.XS_UNSIGNED_LONG_TAG: {
- LongPointable lp = ppool.takeOne(LongPointable.class);
tvp.getValue(lp);
if (lp.longValue() == 0) {
- booleanResult = false;
+ XDMConstants.setFalse(result);
+ return;
}
- ppool.giveBack(lp);
- break;
+ XDMConstants.setTrue(result);
+ return;
}
case ValueTag.XS_INT_TAG:
case ValueTag.XS_UNSIGNED_SHORT_TAG: {
- IntegerPointable ip = ppool.takeOne(IntegerPointable.class);
tvp.getValue(ip);
if (ip.intValue() == 0) {
- booleanResult = false;
+ XDMConstants.setFalse(result);
+ return;
}
- ppool.giveBack(ip);
- break;
+ XDMConstants.setTrue(result);
+ return;
}
case ValueTag.XS_SHORT_TAG:
case ValueTag.XS_UNSIGNED_BYTE_TAG: {
- ShortPointable sp = ppool.takeOne(ShortPointable.class);
tvp.getValue(sp);
if (sp.shortValue() == 0) {
- booleanResult = false;
+ XDMConstants.setFalse(result);
+ return;
}
- ppool.giveBack(sp);
- break;
+ XDMConstants.setTrue(result);
+ return;
}
case ValueTag.XS_BYTE_TAG: {
- BytePointable bp = ppool.takeOne(BytePointable.class);
tvp.getValue(bp);
if (bp.byteValue() == 0) {
- booleanResult = false;
+ XDMConstants.setFalse(result);
+ return;
}
- ppool.giveBack(bp);
- break;
+ XDMConstants.setTrue(result);
+ return;
}
case ValueTag.XS_DOUBLE_TAG: {
- DoublePointable dp = ppool.takeOne(DoublePointable.class);
tvp.getValue(dp);
if (dp.doubleValue() == 0 || Double.isNaN(dp.doubleValue())) {
- booleanResult = false;
+ XDMConstants.setFalse(result);
+ return;
}
- ppool.giveBack(dp);
- break;
+ XDMConstants.setTrue(result);
+ return;
}
case ValueTag.XS_FLOAT_TAG: {
- FloatPointable fp = ppool.takeOne(FloatPointable.class);
tvp.getValue(fp);
if (fp.floatValue() == 0 || Float.isNaN(fp.floatValue())) {
- booleanResult = false;
+ XDMConstants.setFalse(result);
+ return;
}
- ppool.giveBack(fp);
- break;
+ XDMConstants.setTrue(result);
+ return;
}
case ValueTag.XS_ANY_URI_TAG:
case ValueTag.XS_STRING_TAG: {
- UTF8StringPointable utf8p = ppool.takeOne(UTF8StringPointable.class);
tvp.getValue(utf8p);
if (utf8p.getUTFLength() == 0) {
- booleanResult = false;
+ XDMConstants.setFalse(result);
+ return;
}
- ppool.giveBack(utf8p);
- break;
+ XDMConstants.setTrue(result);
+ return;
}
- default:
- throw new SystemException(ErrorCode.FORG0006);
- }
- if (booleanResult) {
- XDMConstants.setTrue(result);
- } else {
- XDMConstants.setFalse(result);
}
+ throw new SystemException(ErrorCode.FORG0006);
}
}
\ No newline at end of file
[06/10] git commit: Update to better weather output.
Posted by pr...@apache.org.
Update to better weather output.
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/c4d02d8f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/c4d02d8f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/c4d02d8f
Branch: refs/heads/prestonc/benchmarks
Commit: c4d02d8f5a6f1a8632f343b696c781732d9e3d88
Parents: 9445d89
Author: Preston Carman <pr...@apache.org>
Authored: Wed Feb 12 00:29:22 2014 -0800
Committer: Preston Carman <pr...@apache.org>
Committed: Wed Feb 12 00:29:22 2014 -0800
----------------------------------------------------------------------
.../src/main/resources/noaa-ghcn-daily/scripts/weather_cli.py | 2 +-
.../src/main/resources/noaa-ghcn-daily/scripts/weather_example.xml | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/c4d02d8f/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_cli.py
----------------------------------------------------------------------
diff --git a/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_cli.py b/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_cli.py
index e6f148b..1242c65 100644
--- a/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_cli.py
+++ b/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_cli.py
@@ -211,7 +211,7 @@ def main(argv):
if section in ("all", "partition"):
for partition in dataset.get_partitions():
- print 'Processing the partition section (d' + str(len(base_paths)) + ':p' + str(partition) + ').'
+ print 'Processing the partition section (' + dataset.get_name() + ':d' + str(len(base_paths)) + ':p' + str(partition) + ').'
data.reset()
data.copy_to_n_partitions(xml_data_save_path, partition, base_paths)
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/c4d02d8f/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_example.xml
----------------------------------------------------------------------
diff --git a/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_example.xml b/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_example.xml
index 0db9599..b8e60fd 100644
--- a/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_example.xml
+++ b/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_example.xml
@@ -34,5 +34,6 @@
<name>small</name>
<save_path>/data</save_path>
<partitions_per_path>4</partitions_per_path>
+ <partitions_per_path>8</partitions_per_path>
</dataset>
</data>
[09/10] git commit: Added short circuiting for both AND and OR scalar
evaluators.
Posted by pr...@apache.org.
Added short circuiting for both AND and OR scalar evaluators.
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/f082dd44
Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/f082dd44
Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/f082dd44
Branch: refs/heads/prestonc/benchmarks
Commit: f082dd448e8676982ec8ad368d12575388c4752f
Parents: b31c29c
Author: Preston Carman <pr...@apache.org>
Authored: Thu Feb 13 09:17:00 2014 -0800
Committer: Preston Carman <pr...@apache.org>
Committed: Thu Feb 13 09:17:00 2014 -0800
----------------------------------------------------------------------
.../functions/bool/AndScalarEvaluator.java | 19 +++++---
.../functions/bool/OrScalarEvaluator.java | 51 ++++++++++++++++++++
.../bool/OrScalarEvaluatorFactory.java | 22 +--------
3 files changed, 64 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/f082dd44/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/AndScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/AndScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/AndScalarEvaluator.java
index b8cedda..9af3494 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/AndScalarEvaluator.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/AndScalarEvaluator.java
@@ -18,24 +18,29 @@ package org.apache.vxquery.runtime.functions.bool;
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;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
import edu.uci.ics.hyracks.data.std.api.IPointable;
import edu.uci.ics.hyracks.data.std.primitive.BooleanPointable;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class AndScalarEvaluator implements IScalarEvaluator {
+ private final IScalarEvaluator[] args;
-public class AndScalarEvaluator extends AbstractTaggedValueArgumentScalarEvaluator {
private final BooleanPointable bp = (BooleanPointable) BooleanPointable.FACTORY.createPointable();
+ private final TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+
public AndScalarEvaluator(IScalarEvaluator[] args) {
- super(args);
+ this.args = args;
}
@Override
- protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
- for (TaggedValuePointable arg : args) {
- arg.getValue(bp);
+ public final void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+ for (int i = 0; i < args.length; ++i) {
+ args[i].evaluate(tuple, tvp);
+ tvp.getValue(bp);
if (!bp.getBoolean()) {
XDMConstants.setFalse(result);
return;
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/f082dd44/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/OrScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/OrScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/OrScalarEvaluator.java
new file mode 100644
index 0000000..ece7e02
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/OrScalarEvaluator.java
@@ -0,0 +1,51 @@
+/*
+ * 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.bool;
+
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.values.XDMConstants;
+
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.primitive.BooleanPointable;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class OrScalarEvaluator implements IScalarEvaluator {
+ private final IScalarEvaluator[] args;
+
+ private final BooleanPointable bp = (BooleanPointable) BooleanPointable.FACTORY.createPointable();
+
+ private final TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+
+ public OrScalarEvaluator(IScalarEvaluator[] args) {
+ this.args = args;
+ }
+
+ @Override
+ public final void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+ for (int i = 0; i < args.length; ++i) {
+ args[i].evaluate(tuple, tvp);
+ tvp.getValue(bp);
+ if (bp.getBoolean()) {
+ XDMConstants.setTrue(result);
+ return;
+ }
+ }
+ XDMConstants.setFalse(result);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/f082dd44/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/OrScalarEvaluatorFactory.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/OrScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/OrScalarEvaluatorFactory.java
index 5309ba5..42b04b9 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/OrScalarEvaluatorFactory.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/OrScalarEvaluatorFactory.java
@@ -16,18 +16,12 @@
*/
package org.apache.vxquery.runtime.functions.bool;
-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;
import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluatorFactory;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
-import edu.uci.ics.hyracks.data.std.api.IPointable;
-import edu.uci.ics.hyracks.data.std.primitive.BooleanPointable;
public class OrScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory {
private static final long serialVersionUID = 1L;
@@ -39,20 +33,6 @@ public class OrScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarE
@Override
protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
throws AlgebricksException {
- return new AbstractTaggedValueArgumentScalarEvaluator(args) {
- private final BooleanPointable bp = (BooleanPointable) BooleanPointable.FACTORY.createPointable();
-
- @Override
- protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
- for (TaggedValuePointable arg : args) {
- arg.getValue(bp);
- if (bp.getBoolean()) {
- XDMConstants.setTrue(result);
- return;
- }
- }
- XDMConstants.setFalse(result);
- }
- };
+ return new OrScalarEvaluator(args);
}
}
\ No newline at end of file
[03/10] git commit: Switched to add field in the frame instead of the
tuple.
Posted by pr...@apache.org.
Switched to add field in the frame instead of the tuple.
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/fa18c045
Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/fa18c045
Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/fa18c045
Branch: refs/heads/prestonc/benchmarks
Commit: fa18c045646af8c4161e699eef66fe7cacd3d679
Parents: 64bb2be
Author: Preston Carman <pr...@apache.org>
Authored: Tue Feb 11 19:02:15 2014 -0800
Committer: Preston Carman <pr...@apache.org>
Committed: Tue Feb 11 19:02:15 2014 -0800
----------------------------------------------------------------------
.../VXQueryCollectionOperatorDescriptor.java | 43 ++++++++++----------
1 file changed, 22 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/fa18c045/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java
index 53697de..8e18485 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java
@@ -30,6 +30,7 @@ import org.apache.vxquery.exceptions.SystemException;
import org.apache.vxquery.runtime.functions.step.ChildPathStep;
import org.apache.vxquery.runtime.functions.util.FunctionHelper;
import org.apache.vxquery.xmlparser.ITreeNodeIdProvider;
+import org.apache.vxquery.xmlparser.SAXContentHandler;
import org.apache.vxquery.xmlparser.TreeNodeIdProvider;
import org.xml.sax.InputSource;
@@ -41,7 +42,6 @@ import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.api.job.IOperatorDescriptorRegistry;
import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
-import edu.uci.ics.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
import edu.uci.ics.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
import edu.uci.ics.hyracks.dataflow.common.comm.io.FrameTupleAppender;
import edu.uci.ics.hyracks.dataflow.common.comm.util.FrameUtils;
@@ -70,10 +70,9 @@ public class VXQueryCollectionOperatorDescriptor extends AbstractSingleActivityO
IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) throws HyracksDataException {
final FrameTupleAccessor fta = new FrameTupleAccessor(ctx.getFrameSize(),
recordDescProvider.getInputRecordDescriptor(getActivityId(), 0));
- final ArrayTupleBuilder tb = new ArrayTupleBuilder(recordDescProvider.getOutputRecordDescriptor(
- getActivityId(), 0).getFieldCount());
+ final int fieldOutputCount = recordDescProvider.getOutputRecordDescriptor(getActivityId(), 0).getFieldCount();
final ByteBuffer frame = ctx.allocateFrame();
- final FrameTupleAppender appender = new FrameTupleAppender(ctx.getFrameSize());
+ final FrameTupleAppender appender = new FrameTupleAppender(ctx.getFrameSize(), fieldOutputCount);
final InputSource in = new InputSource();
final ArrayBackedValueStorage abvsFileNode = new ArrayBackedValueStorage();
final short partitionId = (short) ctx.getTaskAttemptId().getTaskId().getPartition();
@@ -134,17 +133,16 @@ public class VXQueryCollectionOperatorDescriptor extends AbstractSingleActivityO
"XML node is to large for the current frame size (VXQueryCollectionOperatorDescriptor.addXmlFile).");
}
tvp.set(abvsFileNode.getByteArray(), abvsFileNode.getStartOffset(), abvsFileNode.getLength());
- addNodeToTuple(tb, tvp, t);
+ addNodeToTuple(tvp, t);
} else {
// Process child nodes.
tvp.set(abvsFileNode.getByteArray(), abvsFileNode.getStartOffset(), abvsFileNode.getLength());
- processChildStep(tb, tvp, t);
+ processChildStep(tvp, t);
}
ppool.giveBack(tvp);
}
- private void processChildStep(final ArrayTupleBuilder tb, TaggedValuePointable tvp, int t)
- throws HyracksDataException {
+ private void processChildStep(TaggedValuePointable tvp, int t) throws HyracksDataException {
try {
childPathStep.init(tvp, childSeq);
} catch (SystemException e) {
@@ -153,7 +151,7 @@ public class VXQueryCollectionOperatorDescriptor extends AbstractSingleActivityO
try {
TaggedValuePointable result = ppool.takeOne(TaggedValuePointable.class);
while (childPathStep.step(result)) {
- addNodeToTuple(tb, result, t);
+ addNodeToTuple(result, t);
}
ppool.giveBack(result);
} catch (AlgebricksException e) {
@@ -161,27 +159,30 @@ public class VXQueryCollectionOperatorDescriptor extends AbstractSingleActivityO
}
}
- private void addNodeToTuple(final ArrayTupleBuilder tb, TaggedValuePointable result, int t)
- throws HyracksDataException {
- // First copy all new fields over.
- tb.reset();
- if (fta.getFieldCount() > 0) {
- for (int f = 0; f < fta.getFieldCount(); ++f) {
- tb.addField(fta, t, f);
- }
- }
- tb.addField(result.getByteArray(), result.getStartOffset(), result.getLength());
+ private void addNodeToTuple(TaggedValuePointable result, int t) throws HyracksDataException {
// Send to the writer.
- if (!appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize())) {
+ if (!addNodeToTupleAppender(result, t)) {
FrameUtils.flushFrame(frame, writer);
appender.reset(frame, true);
- if (!appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize())) {
+ if (!addNodeToTupleAppender(result, t)) {
throw new HyracksDataException(
"Could not write frame (VXQueryCollectionOperatorDescriptor.createPushRuntime).");
}
}
}
+ private boolean addNodeToTupleAppender(TaggedValuePointable result, int t) throws HyracksDataException {
+ // First copy all new fields over.
+ if (fta.getFieldCount() > 0) {
+ for (int f = 0; f < fta.getFieldCount(); ++f) {
+ if (!appender.appendField(fta, t, f)) {
+ return false;
+ }
+ }
+ }
+ return appender.appendField(result.getByteArray(), result.getStartOffset(), result.getLength());
+ }
+
@Override
public void fail() throws HyracksDataException {
writer.fail();
[04/10] git commit: Cleaned up child path step for a small gain.
Posted by pr...@apache.org.
Cleaned up child path step for a small gain.
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/07a42ea4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/07a42ea4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/07a42ea4
Branch: refs/heads/prestonc/benchmarks
Commit: 07a42ea4222c407ee25ddfaffa70aed5531a7d9c
Parents: fa18c04
Author: Preston Carman <pr...@apache.org>
Authored: Wed Feb 12 00:27:26 2014 -0800
Committer: Preston Carman <pr...@apache.org>
Committed: Wed Feb 12 00:27:26 2014 -0800
----------------------------------------------------------------------
.../functions/step/AbstractChildPathStep.java | 74 +++++++++
.../step/AbstractPathStepScalarEvaluator.java | 21 +--
.../runtime/functions/step/ChildPathStep.java | 158 -------------------
.../functions/step/ChildPathStepEvaluator.java | 94 -----------
.../step/ChildPathStepOperatorDescriptor.java | 153 ++++++++++++++++++
.../step/ChildPathStepScalarEvaluator.java | 4 +-
.../functions/step/ChildPathStepUnnesting.java | 126 +++++++++++++++
.../step/ChildPathStepUnnestingEvaluator.java | 4 +-
8 files changed, 364 insertions(+), 270 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/07a42ea4/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractChildPathStep.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractChildPathStep.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractChildPathStep.java
new file mode 100644
index 0000000..2668719
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractChildPathStep.java
@@ -0,0 +1,74 @@
+/*
+ * 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.step;
+
+import java.io.IOException;
+
+import org.apache.vxquery.context.DynamicContext;
+import org.apache.vxquery.datamodel.accessors.PointablePool;
+import org.apache.vxquery.datamodel.accessors.SequencePointable;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.DocumentNodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.ElementNodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.NodeTreePointable;
+import org.apache.vxquery.datamodel.builders.nodes.NodeSubTreeBuilder;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.datamodel.values.XDMConstants;
+
+import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+
+public abstract class AbstractChildPathStep {
+ protected final DynamicContext dCtx;
+ protected final PointablePool pp;
+ private final ArrayBackedValueStorage nodeAbvs = new ArrayBackedValueStorage();
+ protected final NodeTreePointable ntp = (NodeTreePointable) NodeTreePointable.FACTORY.createPointable();
+ private final DocumentNodePointable dnp = (DocumentNodePointable) DocumentNodePointable.FACTORY.createPointable();
+ private final ElementNodePointable enp = (ElementNodePointable) ElementNodePointable.FACTORY.createPointable();
+ private final NodeSubTreeBuilder nstb = new NodeSubTreeBuilder();
+
+ public AbstractChildPathStep(IHyracksTaskContext ctx, PointablePool pp) {
+ dCtx = (DynamicContext) ctx.getJobletContext().getGlobalJobData();
+ this.pp = pp;
+ }
+
+ protected void getSequence(TaggedValuePointable tvp, SequencePointable seqp) {
+ switch (tvp.getTag()) {
+ case ValueTag.DOCUMENT_NODE_TAG:
+ tvp.getValue(dnp);
+ dnp.getContent(ntp, seqp);
+ return;
+
+ case ValueTag.ELEMENT_NODE_TAG:
+ tvp.getValue(enp);
+ if (enp.childrenChunkExists()) {
+ enp.getChildrenSequence(ntp, seqp);
+ return;
+ }
+ }
+ XDMConstants.setEmptySequence(seqp);
+ }
+
+ protected void setNodeToResult(TaggedValuePointable tvpItem, IPointable result) throws IOException {
+ nodeAbvs.reset();
+ nstb.reset(nodeAbvs);
+ nstb.setChildNode(ntp, tvpItem);
+ nstb.finish();
+ result.set(nodeAbvs.getByteArray(), nodeAbvs.getStartOffset(), nodeAbvs.getLength());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/07a42ea4/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractPathStepScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractPathStepScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractPathStepScalarEvaluator.java
index 3f4d8e3..1442800 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractPathStepScalarEvaluator.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractPathStepScalarEvaluator.java
@@ -33,22 +33,17 @@ import edu.uci.ics.hyracks.data.std.api.IPointable;
import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
public abstract class AbstractPathStepScalarEvaluator extends AbstractTaggedValueArgumentScalarEvaluator {
- protected final SequenceBuilder seqb;
-
- protected final NodeTreePointable ntp;
-
- private final ArrayBackedValueStorage nodeAbvs;
-
- protected final TaggedValuePointable itemTvp;
-
private INodeFilter filter;
+ private final ArrayBackedValueStorage nodeAbvs = new ArrayBackedValueStorage();
+ private final NodeSubTreeBuilder nstb = new NodeSubTreeBuilder();
+ protected final SequenceBuilder seqb = new SequenceBuilder();
+ protected final TaggedValuePointable itemTvp = (TaggedValuePointable) TaggedValuePointable.FACTORY
+ .createPointable();
+ private final TaggedValuePointable node = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+ protected final NodeTreePointable ntp = (NodeTreePointable) NodeTreePointable.FACTORY.createPointable();
public AbstractPathStepScalarEvaluator(IScalarEvaluator[] args, IHyracksTaskContext ctx) {
super(args);
- ntp = (NodeTreePointable) NodeTreePointable.FACTORY.createPointable();
- seqb = new SequenceBuilder();
- nodeAbvs = new ArrayBackedValueStorage();
- itemTvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
}
protected void setNodeTest(SequenceType sType) {
@@ -64,7 +59,6 @@ public abstract class AbstractPathStepScalarEvaluator extends AbstractTaggedValu
protected void setNodeToResult(IPointable result) throws IOException {
nodeAbvs.reset();
- NodeSubTreeBuilder nstb = new NodeSubTreeBuilder();
nstb.reset(nodeAbvs);
nstb.setChildNode(ntp, itemTvp);
nstb.finish();
@@ -72,7 +66,6 @@ public abstract class AbstractPathStepScalarEvaluator extends AbstractTaggedValu
}
protected void appendNodeToResult() throws IOException {
- TaggedValuePointable node = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
setNodeToResult(node);
seqb.addItem(node);
}
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/07a42ea4/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStep.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStep.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStep.java
deleted file mode 100644
index 8cec889..0000000
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStep.java
+++ /dev/null
@@ -1,158 +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.step;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.vxquery.context.DynamicContext;
-import org.apache.vxquery.datamodel.accessors.PointablePool;
-import org.apache.vxquery.datamodel.accessors.SequencePointable;
-import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
-import org.apache.vxquery.datamodel.accessors.nodes.DocumentNodePointable;
-import org.apache.vxquery.datamodel.accessors.nodes.ElementNodePointable;
-import org.apache.vxquery.datamodel.accessors.nodes.NodeTreePointable;
-import org.apache.vxquery.datamodel.builders.nodes.NodeSubTreeBuilder;
-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.step.NodeTestFilter.INodeFilter;
-import org.apache.vxquery.types.SequenceType;
-
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
-import edu.uci.ics.hyracks.data.std.api.IPointable;
-import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
-
-public class ChildPathStep {
- private final DynamicContext dCtx;
- private List<INodeFilter> filter = new ArrayList<INodeFilter>();
- protected int[] indexSequence;
- private final ArrayBackedValueStorage nodeAbvs = new ArrayBackedValueStorage();
- protected final NodeTreePointable ntp = (NodeTreePointable) NodeTreePointable.FACTORY.createPointable();
- private final TaggedValuePointable tvpItem = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
- private final DocumentNodePointable dnp = (DocumentNodePointable) DocumentNodePointable.FACTORY.createPointable();
- private final ElementNodePointable enp = (ElementNodePointable) ElementNodePointable.FACTORY.createPointable();
- protected final PointablePool pp;
-
- public ChildPathStep(IHyracksTaskContext ctx, PointablePool pp) {
- dCtx = (DynamicContext) ctx.getJobletContext().getGlobalJobData();
- this.pp = pp;
- }
-
- protected void getSequence(TaggedValuePointable tvp, SequencePointable seqp) {
- switch (tvp.getTag()) {
- case ValueTag.DOCUMENT_NODE_TAG:
- tvp.getValue(dnp);
- dnp.getContent(ntp, seqp);
- return;
-
- case ValueTag.ELEMENT_NODE_TAG:
- tvp.getValue(enp);
- if (enp.childrenChunkExists()) {
- enp.getChildrenSequence(ntp, seqp);
- return;
- }
- }
- XDMConstants.setEmptySequence(seqp);
- }
-
- public void init(TaggedValuePointable tvp, List<Integer> typeCodes) throws SystemException {
- indexSequence = new int[typeCodes.size()];
- for (int i = 0; i < typeCodes.size(); ++i) {
- indexSequence[i] = 0;
- }
- setFilterCode(typeCodes);
- if (tvp.getTag() != ValueTag.NODE_TREE_TAG) {
- throw new SystemException(ErrorCode.SYSE0001);
- }
- tvp.getValue(ntp);
- }
-
- protected void setFilterCode(List<Integer> typeCodes) {
- for (int typeCode : typeCodes) {
- SequenceType sType = dCtx.getStaticContext().lookupSequenceType(typeCode);
- INodeFilter f = NodeTestFilter.getNodeTestFilter(sType);
- filter.add(f);
- }
- }
-
- private void setNodeToResult(TaggedValuePointable tvpItem, IPointable result) throws IOException {
- nodeAbvs.reset();
- NodeSubTreeBuilder nstb = new NodeSubTreeBuilder();
- nstb.reset(nodeAbvs);
- nstb.setChildNode(ntp, tvpItem);
- nstb.finish();
- result.set(nodeAbvs.getByteArray(), nodeAbvs.getStartOffset(), nodeAbvs.getLength());
- }
-
- /**
- * Single node tree input.
- * Requirement: "ntp" must be the node tree.
- */
- public boolean step(IPointable result) throws AlgebricksException {
- TaggedValuePointable tvpRoot = pp.takeOne(TaggedValuePointable.class);
- ntp.getRootNode(tvpRoot);
- if (stepNodeTree(tvpRoot, 0, result)) {
- pp.giveBack(tvpRoot);
- return true;
- }
- pp.giveBack(tvpRoot);
- return false;
- }
-
- /**
- * Find the next node to return.
- */
- protected boolean stepNodeTree(TaggedValuePointable tvpInput, int level, IPointable result)
- throws AlgebricksException {
- SequencePointable seqItem = pp.takeOne(SequencePointable.class);
- getSequence(tvpInput, seqItem);
- int seqLength = seqItem.getEntryCount();
- while (indexSequence[level] < seqLength) {
- // Get the next item
- seqItem.getEntry(indexSequence[level], tvpItem);
-
- // Test to see if the item fits the path step
- if (filter.get(level).accept(ntp, tvpItem)) {
- if (level + 1 < indexSequence.length) {
- if (stepNodeTree(tvpItem, level + 1, result)) {
- pp.giveBack(seqItem);
- return true;
- }
- } else {
- try {
- setNodeToResult(tvpItem, result);
- ++indexSequence[level];
- pp.giveBack(seqItem);
- return true;
- } catch (IOException e) {
- String description = ErrorCode.SYSE0001 + ": " + ErrorCode.SYSE0001.getDescription();
- throw new AlgebricksException(description);
- }
- }
- }
- ++indexSequence[level];
- }
- // Reset for next node tree.
- indexSequence[level] = 0;
- pp.giveBack(seqItem);
- return false;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/07a42ea4/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepEvaluator.java
deleted file mode 100644
index 714820c..0000000
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepEvaluator.java
+++ /dev/null
@@ -1,94 +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.step;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.vxquery.datamodel.accessors.PointablePool;
-import org.apache.vxquery.datamodel.accessors.SequencePointable;
-import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
-import org.apache.vxquery.datamodel.values.ValueTag;
-import org.apache.vxquery.exceptions.ErrorCode;
-import org.apache.vxquery.exceptions.SystemException;
-
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
-import edu.uci.ics.hyracks.data.std.api.IPointable;
-import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
-
-public class ChildPathStepEvaluator extends ChildPathStep {
- private int indexSeqArgs;
- private int seqArgsLength;
- private final SequencePointable seqNtp = (SequencePointable) SequencePointable.FACTORY.createPointable();
-
- public ChildPathStepEvaluator(IHyracksTaskContext ctx, PointablePool pp) {
- super(ctx, pp);
- indexSequence = new int[1];
- }
-
- protected void init(TaggedValuePointable[] args) throws SystemException {
- indexSequence[0] = 0;
- indexSeqArgs = 0;
-
- if (args[1].getTag() != ValueTag.XS_INT_TAG) {
- throw new IllegalArgumentException("Expected int value tag, got: " + args[1].getTag());
- }
- IntegerPointable ip = pp.takeOne(IntegerPointable.class);
- args[1].getValue(ip);
- List<Integer> typeCodes = new ArrayList<Integer>();
- typeCodes.add(ip.getInteger());
- pp.giveBack(ip);
-
- setFilterCode(typeCodes);
-
- if (args[0].getTag() == ValueTag.SEQUENCE_TAG) {
- args[0].getValue(seqNtp);
- seqArgsLength = seqNtp.getEntryCount();
- } else if (args[0].getTag() == ValueTag.NODE_TREE_TAG) {
- args[0].getValue(ntp);
- seqArgsLength = -1;
- } else {
- throw new SystemException(ErrorCode.SYSE0001);
- }
- }
-
- public boolean step(IPointable result) throws AlgebricksException {
- if (seqArgsLength > 0) {
- TaggedValuePointable tvpNtp = pp.takeOne(TaggedValuePointable.class);
- while (indexSeqArgs < seqArgsLength) {
- seqNtp.getEntry(indexSeqArgs, tvpNtp);
- if (tvpNtp.getTag() != ValueTag.NODE_TREE_TAG) {
- String description = ErrorCode.SYSE0001 + ": " + ErrorCode.SYSE0001.getDescription();
- throw new AlgebricksException(description);
- }
- tvpNtp.getValue(ntp);
- if (super.step(result)) {
- pp.giveBack(tvpNtp);
- return true;
- }
- }
- pp.giveBack(tvpNtp);
- } else {
- // Single node tree input.
- if (super.step(result)) {
- return true;
- }
- }
- return false;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/07a42ea4/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepOperatorDescriptor.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepOperatorDescriptor.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepOperatorDescriptor.java
new file mode 100644
index 0000000..1edf0f5
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepOperatorDescriptor.java
@@ -0,0 +1,153 @@
+/*
+ * 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.step;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.vxquery.datamodel.accessors.PointablePool;
+import org.apache.vxquery.datamodel.accessors.SequencePointable;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.DocumentNodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.ElementNodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.NodeTreePointable;
+import org.apache.vxquery.datamodel.builders.nodes.NodeSubTreeBuilder;
+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.step.NodeTestFilter.INodeFilter;
+import org.apache.vxquery.types.SequenceType;
+
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+
+public class ChildPathStepOperatorDescriptor extends AbstractChildPathStep {
+ private List<INodeFilter> filter = new ArrayList<INodeFilter>();
+ private int[] indexSequence;
+ private final ArrayBackedValueStorage nodeAbvs = new ArrayBackedValueStorage();
+ protected final NodeTreePointable ntp = (NodeTreePointable) NodeTreePointable.FACTORY.createPointable();
+ private final TaggedValuePointable tvpItem = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+ private final DocumentNodePointable dnp = (DocumentNodePointable) DocumentNodePointable.FACTORY.createPointable();
+ private final ElementNodePointable enp = (ElementNodePointable) ElementNodePointable.FACTORY.createPointable();
+ private final TaggedValuePointable tvpStep = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+ private final NodeSubTreeBuilder nstb = new NodeSubTreeBuilder();
+
+ public ChildPathStepOperatorDescriptor(IHyracksTaskContext ctx, PointablePool pp) {
+ super(ctx, pp);
+ }
+
+ protected void getSequence(TaggedValuePointable tvp, SequencePointable seqp) {
+ switch (tvp.getTag()) {
+ case ValueTag.DOCUMENT_NODE_TAG:
+ tvp.getValue(dnp);
+ dnp.getContent(ntp, seqp);
+ return;
+
+ case ValueTag.ELEMENT_NODE_TAG:
+ tvp.getValue(enp);
+ if (enp.childrenChunkExists()) {
+ enp.getChildrenSequence(ntp, seqp);
+ return;
+ }
+ }
+ XDMConstants.setEmptySequence(seqp);
+ }
+
+ public void init(TaggedValuePointable tvp, List<Integer> typeCodes) throws SystemException {
+ indexSequence = new int[typeCodes.size()];
+ for (int i = 0; i < typeCodes.size(); ++i) {
+ indexSequence[i] = 0;
+ }
+ setFilterCode(typeCodes);
+ if (tvp.getTag() != ValueTag.NODE_TREE_TAG) {
+ throw new SystemException(ErrorCode.SYSE0001);
+ }
+ tvp.getValue(ntp);
+ }
+
+ protected void setFilterCode(List<Integer> typeCodes) {
+ for (int typeCode : typeCodes) {
+ SequenceType sType = dCtx.getStaticContext().lookupSequenceType(typeCode);
+ INodeFilter f = NodeTestFilter.getNodeTestFilter(sType);
+ filter.add(f);
+ }
+ }
+
+ protected void setNodeToResult(TaggedValuePointable tvpItem, IPointable result) throws IOException {
+ nodeAbvs.reset();
+ nstb.reset(nodeAbvs);
+ nstb.setChildNode(ntp, tvpItem);
+ nstb.finish();
+ result.set(nodeAbvs.getByteArray(), nodeAbvs.getStartOffset(), nodeAbvs.getLength());
+ }
+
+ /**
+ * Single node tree input.
+ * Requirement: "ntp" must be the node tree.
+ */
+ public boolean step(IPointable result) throws AlgebricksException {
+ ntp.getRootNode(tvpStep);
+ if (stepNodeTree(tvpStep, 0, result)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Find the next node to return.
+ */
+ protected boolean stepNodeTree(TaggedValuePointable tvpInput, int level, IPointable result)
+ throws AlgebricksException {
+ SequencePointable seqItem = pp.takeOne(SequencePointable.class);
+ try {
+ getSequence(tvpInput, seqItem);
+ int seqLength = seqItem.getEntryCount();
+ while (indexSequence[level] < seqLength) {
+ // Get the next item
+ seqItem.getEntry(indexSequence[level], tvpItem);
+
+ // Test to see if the item fits the path step
+ if (filter.get(level).accept(ntp, tvpItem)) {
+ if (level + 1 < indexSequence.length) {
+ if (stepNodeTree(tvpItem, level + 1, result)) {
+ return true;
+ }
+ } else {
+ try {
+ setNodeToResult(tvpItem, result);
+ ++indexSequence[level];
+ return true;
+ } catch (IOException e) {
+ String description = ErrorCode.SYSE0001 + ": " + ErrorCode.SYSE0001.getDescription();
+ throw new AlgebricksException(description);
+ }
+ }
+ }
+ ++indexSequence[level];
+ }
+ // Reset for next node tree.
+ indexSequence[level] = 0;
+ return false;
+ } finally {
+ pp.giveBack(seqItem);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/07a42ea4/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepScalarEvaluator.java
index 106df8d..729f8a2 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepScalarEvaluator.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepScalarEvaluator.java
@@ -35,13 +35,13 @@ public class ChildPathStepScalarEvaluator extends AbstractTaggedValueArgumentSca
private final ArrayBackedValueStorage seqAbvs = new ArrayBackedValueStorage();
- private final ChildPathStepEvaluator childPathStep;
+ private final ChildPathStepUnnesting childPathStep;
private final TaggedValuePointable itemTvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
public ChildPathStepScalarEvaluator(IScalarEvaluator[] args, IHyracksTaskContext ctx) {
super(args);
- childPathStep = new ChildPathStepEvaluator(ctx, ppool);
+ childPathStep = new ChildPathStepUnnesting(ctx, ppool);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/07a42ea4/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnesting.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnesting.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnesting.java
new file mode 100644
index 0000000..1e93ce3
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnesting.java
@@ -0,0 +1,126 @@
+/*
+ * 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.step;
+
+import java.io.IOException;
+
+import org.apache.vxquery.datamodel.accessors.PointablePool;
+import org.apache.vxquery.datamodel.accessors.SequencePointable;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+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.step.NodeTestFilter.INodeFilter;
+import org.apache.vxquery.types.SequenceType;
+
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
+
+public class ChildPathStepUnnesting extends AbstractChildPathStep {
+ private int indexSeqArgs;
+ private int seqArgsLength;
+ private int indexSequence;
+ private final IntegerPointable ip = (IntegerPointable) IntegerPointable.FACTORY.createPointable();
+ private final SequencePointable seqItem = (SequencePointable) SequencePointable.FACTORY.createPointable();
+ private final SequencePointable seqNtp = (SequencePointable) SequencePointable.FACTORY.createPointable();
+ private final TaggedValuePointable tvpItem = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+ private final TaggedValuePointable tvpNtp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+ private final TaggedValuePointable tvpStep = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+ INodeFilter filter;
+
+ public ChildPathStepUnnesting(IHyracksTaskContext ctx, PointablePool pp) {
+ super(ctx, pp);
+ }
+
+ protected void init(TaggedValuePointable[] args) throws SystemException {
+ indexSeqArgs = 0;
+ indexSequence = 0;
+
+ if (args[1].getTag() != ValueTag.XS_INT_TAG) {
+ throw new IllegalArgumentException("Expected int value tag, got: " + args[1].getTag());
+ }
+ args[1].getValue(ip);
+ SequenceType sType = dCtx.getStaticContext().lookupSequenceType(ip.getInteger());
+ filter = NodeTestFilter.getNodeTestFilter(sType);
+
+ if (args[0].getTag() == ValueTag.SEQUENCE_TAG) {
+ args[0].getValue(seqNtp);
+ seqArgsLength = seqNtp.getEntryCount();
+ } else if (args[0].getTag() == ValueTag.NODE_TREE_TAG) {
+ args[0].getValue(ntp);
+ seqArgsLength = -1;
+ } else {
+ throw new SystemException(ErrorCode.SYSE0001);
+ }
+ }
+
+ public boolean step(IPointable result) throws AlgebricksException {
+ if (seqArgsLength > 0) {
+ while (indexSeqArgs < seqArgsLength) {
+ seqNtp.getEntry(indexSeqArgs, tvpNtp);
+ if (tvpNtp.getTag() != ValueTag.NODE_TREE_TAG) {
+ String description = ErrorCode.SYSE0001 + ": " + ErrorCode.SYSE0001.getDescription();
+ throw new AlgebricksException(description);
+ }
+ tvpNtp.getValue(ntp);
+ ntp.getRootNode(tvpStep);
+ if (stepNodeTree(tvpStep, 0, result)) {
+ return true;
+ }
+ }
+ } else {
+ // Single node tree input.
+ ntp.getRootNode(tvpStep);
+ if (stepNodeTree(tvpStep, 0, result)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Find the next node to return.
+ */
+ protected boolean stepNodeTree(TaggedValuePointable tvpInput, int level, IPointable result)
+ throws AlgebricksException {
+ getSequence(tvpInput, seqItem);
+ int seqLength = seqItem.getEntryCount();
+ while (indexSequence < seqLength) {
+ // Get the next item
+ seqItem.getEntry(indexSequence, tvpItem);
+
+ // Test to see if the item fits the path step
+ if (filter.accept(ntp, tvpItem)) {
+ try {
+ setNodeToResult(tvpItem, result);
+ ++indexSequence;
+ return true;
+ } catch (IOException e) {
+ String description = ErrorCode.SYSE0001 + ": " + ErrorCode.SYSE0001.getDescription();
+ throw new AlgebricksException(description);
+ }
+ }
+ ++indexSequence;
+ }
+ // Reset for next node tree.
+ indexSequence = 0;
+ return false;
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/07a42ea4/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnestingEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnestingEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnestingEvaluator.java
index ce39df9..02515c4 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnestingEvaluator.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnestingEvaluator.java
@@ -26,11 +26,11 @@ import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
import edu.uci.ics.hyracks.data.std.api.IPointable;
public class ChildPathStepUnnestingEvaluator extends AbstractTaggedValueArgumentUnnestingEvaluator {
- final ChildPathStepEvaluator childPathStep;
+ final ChildPathStepUnnesting childPathStep;
public ChildPathStepUnnestingEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) {
super(args);
- childPathStep = new ChildPathStepEvaluator(ctx, ppool);
+ childPathStep = new ChildPathStepUnnesting(ctx, ppool);
}
public boolean step(IPointable result) throws AlgebricksException {
[02/10] git commit: Attempting to streamline the data building
process and management. Started a xml file to hold the parameters and the cli
to do all steps to build out data and partitions.
Posted by pr...@apache.org.
Attempting to streamline the data building process and management. Started a xml file to hold the parameters and the cli to do all steps to build out data and partitions.
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/64bb2bea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/64bb2bea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/64bb2bea
Branch: refs/heads/prestonc/benchmarks
Commit: 64bb2bea24e6b32f1e99bd29ff911342c18d5298
Parents: ce12767
Author: Preston Carman <pr...@apache.org>
Authored: Tue Feb 11 19:01:34 2014 -0800
Committer: Preston Carman <pr...@apache.org>
Committed: Tue Feb 11 19:01:34 2014 -0800
----------------------------------------------------------------------
.../noaa-ghcn-daily/scripts/weather_cli.py | 139 +++++++------------
.../noaa-ghcn-daily/scripts/weather_config.py | 115 +++++++++++++++
.../scripts/weather_data_files.py | 11 +-
.../noaa-ghcn-daily/scripts/weather_example.xml | 38 +++++
4 files changed, 207 insertions(+), 96 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/64bb2bea/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_cli.py
----------------------------------------------------------------------
diff --git a/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_cli.py b/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_cli.py
index 108d7e6..e6f148b 100644
--- a/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_cli.py
+++ b/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_cli.py
@@ -20,6 +20,7 @@ import sys, getopt
from weather_data_files import *
from weather_download_files import *
from weather_convert_to_xml import *
+from weather_config import *
DEBUG_OUTPUT = False
COMPRESSED = False
@@ -31,23 +32,17 @@ COMPRESSED = False
#
def main(argv):
append = False
- base_paths = []
- download_path = ""
max_records = 0
package = "ghcnd_gsn"
- partitions = 0
- nodes = -1
process_file_name = ""
reset = False
- save_path = ""
section = "all"
- test = ""
token = ""
update = False
- virtual_partitions = 0
+ xml_config_path = ""
try:
- opts, args = getopt.getopt(argv, "ab:cd:f:hl:m:n:p:rs:t:uvw:", ["base_paths", "download_directory=", "file=", "locality=", "max_station_files=", "nodes=", "save_directory=", "package=", "partitions=", "virtual_partitions=", "web_service="])
+ opts, args = getopt.getopt(argv, "ab:cf:hl:m:n:p:rs:t:uvw:x:", ["base_paths", "download_directory=", "file=", "locality=", "max_station_files=", "nodes=", "package=", "partitions=", "virtual_partitions=", "web_service=", "xml_config="])
except getopt.GetoptError:
print 'The file options for weather_cli.py were not correctly specified.'
print 'To see a full list of options try:'
@@ -57,52 +52,24 @@ def main(argv):
if opt == '-h':
print 'Converting weather daily files to xml options:'
print ' -a Append the results to the progress file.'
- print ' -b (str) The directories for saving the partitioned files seperated by a vertical bar (|).'
print ' -c Compress the produced XML file with .gz.'
- print ' --download_directory (str) The directory for saving the downloaded files. (default: downloads)'
- print ' -d (str) The directory for saving the downloaded files and generated XML files.'
print ' -f (str) The file name of a specific station to process.'
print ' * Helpful when testing a single stations XML file output.'
print ' -l (str) Select the locality of the scripts execution (download, progress_file, sensor_build, station_build, partition, statistics).'
print ' -m (int) Limits the number of files created for each station.'
print ' * Helpful when testing to make sure all elements are supported for each station.'
print ' Alternate form: --max_station_files=(int)'
- print ' -n (int) The numeric node id starting at 0.'
- print ' --partitions (int) The number of partitions (sections) for creating split up generated data.'
- print ' -p (str) The package used to generate files. (all, gsn, hcn)'
- print ' -t (str) The benchmark test used to partition files. (speed_up, batch_scale_up)'
print ' -r Reset the build process. (For one section or all sections depending on other parameters.)'
print ' -u Recalculate the file count and data size for each data source file.'
print ' -v Extra debug information.'
- print ' --virtual_partitions (int) The number of partitions viewable for benchmarking.'
print ' -w (str) Downloads the station XML file form the web service.'
+ print ' -x (str) XML config file for weather data.'
sys.exit()
elif opt in ('-a', "--append"):
append = True
- elif opt in ('-b', "--base_paths"):
- # check if directories exist.
- base_paths = arg.split('|')
- for base_path in base_paths:
- if not os.path.exists(base_path):
- print 'Error: Argument must be a directory list --base_paths (-b).'
- sys.exit()
elif opt == '-c':
global COMPRESSED
COMPRESSED = True
- elif opt == '--download_directory':
- # check if file exists.
- if os.path.exists(arg):
- download_path = arg
- else:
- print 'Error: Argument must be a directory for --download_directory.'
- sys.exit()
- elif opt in ('-d', "--save_directory"):
- # check if file exists.
- if os.path.exists(arg):
- save_path = arg
- else:
- print 'Error: Argument must be a directory for --save_directory (-s).'
- sys.exit()
elif opt in ('-f', "--file"):
# check if file exists.
if os.path.exists(arg):
@@ -122,40 +89,16 @@ def main(argv):
else:
print 'Error: Argument must be an integer for --max_station_files (-m).'
sys.exit()
- elif opt in ('-n'):
- if arg.isdigit():
- nodes = int(arg)
- else:
- print 'Error: Argument must be an integer for -n.'
- sys.exit()
- elif opt == "--partitions":
- if arg.isdigit():
- partitions = int(arg)
- else:
- print 'Error: Argument must be an integer for --partitions.'
- sys.exit()
elif opt in ('-p', "--package"):
if arg in ("all", "gsn", "hcn"):
package = "ghcnd_" + arg
else:
print 'Error: Argument must be an string for one of the known weather packages: "all", "gsn", "hcn"'
sys.exit()
- elif opt in ('-t'):
- if arg in ("speed_up", "batch_scale_up"):
- test = arg
- else:
- print 'Error: Argument must be an string for one of the known benchmark tests: "speed_up", "batch_scale_up"'
- sys.exit()
elif opt == '-r':
reset = True
elif opt == '-u':
update = True
- elif opt == "--virtual_partitions":
- if arg.isdigit():
- virtual_partitions = int(arg)
- else:
- print 'Error: Argument must be an integer for --virtual_partitions.'
- sys.exit()
elif opt == '-v':
global DEBUG_OUTPUT
DEBUG_OUTPUT = True
@@ -166,15 +109,27 @@ def main(argv):
else:
print 'Error: Argument must be a string --web_service (-w).'
sys.exit()
+ elif opt in ('-x', "--xml_config"):
+ # check if file exists.
+ if os.path.exists(arg):
+ xml_config_path = arg
+ else:
+ print 'Error: Argument must be a xml file for --xml_config (-x).'
+ sys.exit()
# Required fields to run the script.
- if save_path == "" or not os.path.exists(save_path):
+ if xml_config_path == "" or not os.path.exists(xml_config_path):
+ print 'Error: The xml config option must be supplied: --xml_config (-x).'
+ sys.exit()
+ config = WeatherConfig(xml_config_path)
+
+ # Required fields to run the script.
+ if config.get_save_path() == "" or not os.path.exists(config.get_save_path()):
print 'Error: The save directory option must be supplied: --save_directory (-d).'
sys.exit()
# Set up downloads folder.
- if download_path == "":
- download_path = save_path + "/downloads"
+ download_path = config.get_save_path() + "/downloads"
if section in ("all", "download"):
print 'Processing the download section.'
download = WeatherDownloadFiles(download_path)
@@ -185,19 +140,13 @@ def main(argv):
# Create some basic paths for save files and references.
- ghcnd_data_dly_path = download_path + '/' + package + '/' + package
- ghcnd_xml_path = save_path + "/1.0_partition_" + package + '_xml/'
- ghcnd_xml_gz_path = save_path + "/1.0_partition_" + package + '_xml_gz/'
- if COMPRESSED:
- xml_data_save_path = ghcnd_xml_gz_path
- else:
- xml_data_save_path = ghcnd_xml_path
+ ghcnd_data_dly_path = download_path + '/' + config.get_package() + '/' + config.get_package()
+ xml_data_save_path = config.get_save_path() + '/all_xml_files/'
# Make sure the xml folder is available.
if not os.path.isdir(xml_data_save_path):
os.makedirs(xml_data_save_path)
-
# Set up the XML build objects.
convert = WeatherWebServiceMonthlyXMLFile(download_path, xml_data_save_path, COMPRESSED, DEBUG_OUTPUT)
progress_file = xml_data_save_path + "_data_progress.csv"
@@ -250,25 +199,35 @@ def main(argv):
data.update_file_station_status(file_name, status)
else:
data.update_file_station_status(file_name, WeatherDataFiles.DATA_FILE_MISSING)
-
- if section in ("all", "partition") and partitions > 0:
- print 'Processing the partition section.'
- data.reset()
- data_key = "_partition_" + package + ("_xml_gz" if COMPRESSED else "_xml")
- data.copy_to_n_partitions(xml_data_save_path, data_key, partitions, base_paths)
+
+ for dataset in config.get_dataset_list():
+ # Set up the setting for each dataset.
+ dataset_folder = "/dataset-" + dataset.get_name()
+ progress_file = config.get_save_path() + dataset_folder + "/_data_progress.csv"
+ data = WeatherDataFiles(ghcnd_data_dly_path, progress_file)
+ base_paths = []
+ for paths in dataset.get_save_paths():
+ base_paths.append(paths + dataset_folder + "/")
- if section in ("test_links"):
- if test and partitions > 0 and virtual_partitions > 0 and nodes > -1:
- print 'Processing the test links section.'
- data.reset()
- data.create_test_links(save_path, xml_data_save_path, test, nodes, partitions, virtual_partitions, base_paths)
- else:
- print 'Error: Not enough information for this section.'
- sys.exit()
+ if section in ("all", "partition"):
+ for partition in dataset.get_partitions():
+ print 'Processing the partition section (d' + str(len(base_paths)) + ':p' + str(partition) + ').'
+ data.reset()
+ data.copy_to_n_partitions(xml_data_save_path, partition, base_paths)
+
+ if section in ("all", "test_links"):
+ # TODO determine current node
+ if test and partitions > 0 and virtual_partitions > 0 and nodes > -1:
+ print 'Processing the test links section.'
+ data.reset()
+ data.create_test_links(config.get_save_path(), xml_data_save_path, test, nodes, partitions, virtual_partitions, base_paths)
+ else:
+ print 'Error: Not enough information for this section.'
+ sys.exit()
- if section in ("all", "statistics"):
- print 'Processing the statistics section.'
- data.print_progress_file_stats(convert)
-
+# if section in ("statistics"):
+# print 'Processing the statistics section.'
+# data.print_progress_file_stats(convert)
+
if __name__ == "__main__":
main(sys.argv[1:])
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/64bb2bea/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_config.py
----------------------------------------------------------------------
diff --git a/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_config.py b/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_config.py
new file mode 100644
index 0000000..fa12342
--- /dev/null
+++ b/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_config.py
@@ -0,0 +1,115 @@
+#!/usr/bin/env python
+#
+# 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.
+from xml.dom.minidom import parse
+
+class WeatherConfig:
+ def __init__(self, config_xml_file):
+ self.config_xml_file = config_xml_file
+
+ self.config = parse(self.config_xml_file)
+
+ def get_save_path(self):
+ return self.get_text(self.config.getElementsByTagName("save_path")[0])
+
+ def get_package(self):
+ return self.get_text(self.config.getElementsByTagName("package")[0])
+
+ def get_node_machine_list(self):
+ nodes = []
+ for node in self.config.getElementsByTagName("node"):
+ id = self.get_node_name(node)
+ ip = self.get_node_ip(node)
+ nodes.append(Machine(id, ip))
+ return nodes
+
+ def get_dataset_list(self):
+ nodes = []
+ for node in self.config.getElementsByTagName("dataset"):
+ name = self.get_dataset_name(node)
+ save_paths = self.get_dataset_save_paths(node)
+ partitions = self.get_dataset_partitions(node)
+ nodes.append(Dataset(name, save_paths, partitions))
+ return nodes
+
+
+ # --------------------------------------------------------------------------
+ # Node Specific Functions
+ # --------------------------------------------------------------------------
+ def get_node_ip(self, node):
+ return self.get_text(node.getElementsByTagName("ip_address")[0])
+
+ def get_node_name(self, node):
+ return self.get_text(node.getElementsByTagName("name")[0])
+
+
+ # --------------------------------------------------------------------------
+ # Dataset Specific Functions
+ # --------------------------------------------------------------------------
+ def get_dataset_name(self, node):
+ return self.get_text(node.getElementsByTagName("name")[0])
+
+ def get_dataset_save_paths(self, node):
+ paths = []
+ for node in node.getElementsByTagName("save_path"):
+ paths.append(self.get_text(node))
+ return paths
+
+ def get_dataset_partitions(self, node):
+ paths = []
+ for node in node.getElementsByTagName("partitions_per_path"):
+ paths.append(int(self.get_text(node)))
+ return paths
+
+ def get_text(self, xml_node):
+ rc = []
+ for node in xml_node.childNodes:
+ if node.nodeType == node.TEXT_NODE:
+ rc.append(node.data)
+ return ''.join(rc)
+
+class Machine:
+ def __init__(self, id, ip):
+ self.id = id
+ self.ip = ip
+
+ def get_node_name(self):
+ return self.id
+
+ def get_node_ip(self):
+ return self.ip
+
+ def __repr__(self):
+ return self.id + "(" + self.ip + ")"
+
+class Dataset:
+ def __init__(self, name, save_paths, partitions):
+ self.name = name
+ self.save_paths = save_paths
+ self.partitions = partitions
+
+ def get_name(self):
+ return self.name
+
+ def get_save_paths(self):
+ return self.save_paths
+
+ def get_partitions(self):
+ return self.partitions
+
+ def __repr__(self):
+ return self.name + ":" + str(self.save_paths) + ":" + str(self.partitions)
+
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/64bb2bea/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_data_files.py
----------------------------------------------------------------------
diff --git a/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_data_files.py b/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_data_files.py
index 0a71973..be85c69 100644
--- a/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_data_files.py
+++ b/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_data_files.py
@@ -95,7 +95,7 @@ class WeatherDataFiles:
def create_test_links(self, save_path, xml_save_path, test, node, partitions, virtual_partitions, base_paths=[]):
if (len(base_paths) == 0):
base_paths.append(os.path.dirname(save_path))
- partition_list = sorted(get_partition_paths(xml_save_path, partitions, base_paths))
+ partition_list = sorted(get_partition_paths(partitions, base_paths))
test_path = save_path + "/" + test
if not os.path.isdir(test_path):
@@ -125,13 +125,13 @@ class WeatherDataFiles:
# Once the initial data has been generated, the data can be copied into a set number of partitions.
- def copy_to_n_partitions(self, save_path, data_key, partitions, base_paths=[]):
+ def copy_to_n_partitions(self, save_path, partitions, base_paths=[]):
if (len(base_paths) == 0):
return
# Initialize the partition paths.
partition_sizes = []
- partition_paths = get_partition_paths(data_key, partitions, base_paths)
+ partition_paths = get_partition_paths(partitions, base_paths)
for path in partition_paths:
partition_sizes.append(0)
# Make sure the xml folder is available.
@@ -143,7 +143,6 @@ class WeatherDataFiles:
csv_sorted = self.get_csv_in_partition_order()
for item, size in csv_sorted.iteritems():
station_id = item.split('.')[0]
-
# Update partition bases on smallest current size.
current_partition = partition_sizes.index(min(partition_sizes))
@@ -348,11 +347,11 @@ class WeatherDataFiles:
break
return columns[self.INDEX_DATA_FILE_NAME]
-def get_partition_paths(data_key, partitions, base_paths):
+def get_partition_paths(partitions, base_paths):
partition_paths = []
for i in range(0, partitions):
for j in range(0, len(base_paths)):
- new_partition_path = base_paths[j] + "/p" + str(partitions) + ".i" + str(i) + ".d" + str(j) + data_key + "/"
+ new_partition_path = base_paths[j] + "partitions/" + str(len(base_paths)) + "disk/d" + str(j) +"_p" + str(partitions) + "_i" + str(i) + "/"
partition_paths.append(new_partition_path)
return partition_paths
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/64bb2bea/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_example.xml
----------------------------------------------------------------------
diff --git a/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_example.xml b/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_example.xml
new file mode 100644
index 0000000..0db9599
--- /dev/null
+++ b/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/scripts/weather_example.xml
@@ -0,0 +1,38 @@
+<!--
+ 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.
+-->
+<data xmlns="data">
+ <name>Local Example</name>
+ <save_path>/data</save_path>
+ <package>all</package>
+ <node>
+ <name>localhost</name>
+ <ip_address>127.0.0.1</ip_address>
+ </node>
+ <dataset>
+ <name>tiny</name>
+ <save_path>/data</save_path>
+ <partitions_per_path>1</partitions_per_path>
+ <partitions_per_path>2</partitions_per_path>
+ <partitions_per_path>4</partitions_per_path>
+ <partitions_per_path>8</partitions_per_path>
+ </dataset>
+ <dataset>
+ <name>small</name>
+ <save_path>/data</save_path>
+ <partitions_per_path>4</partitions_per_path>
+ </dataset>
+</data>
[08/10] git commit: Added the total execution time back to help with
comparing older numbers.
Posted by pr...@apache.org.
Added the total execution time back to help with comparing older numbers.
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/b31c29c4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/b31c29c4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/b31c29c4
Branch: refs/heads/prestonc/benchmarks
Commit: b31c29c4545166c080546538840a780d9682ecc5
Parents: 337c67e
Author: Preston Carman <pr...@apache.org>
Authored: Wed Feb 12 11:18:59 2014 -0800
Committer: Preston Carman <pr...@apache.org>
Committed: Wed Feb 12 11:18:59 2014 -0800
----------------------------------------------------------------------
vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/b31c29c4/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
----------------------------------------------------------------------
diff --git a/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java b/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
index 24d3b78..06deac5 100644
--- a/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
+++ b/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
@@ -100,6 +100,7 @@ public class VXQuery {
* @throws Exception
*/
public static void main(String[] args) throws Exception {
+ Date start = new Date();
final CmdLineOptions opts = new CmdLineOptions();
CmdLineParser parser = new CmdLineParser(opts);
@@ -116,8 +117,12 @@ public class VXQuery {
}
VXQuery vxq = new VXQuery(opts);
vxq.execute();
+ Date end = new Date();
// if -timing argument passed, show the starting and ending times
if (opts.timing) {
+ message = "Execution time: " + (end.getTime() - start.getTime()) + "ms";
+ System.out.println(message);
+ timing.add(message);
if (opts.repeatExec > 3) {
message = "Average execution time: " + (totalTiming / (opts.repeatExec - 3)) + "ms";
System.out.println(message);
[05/10] git commit: Allows the xml parser to be reused per partition.
Posted by pr...@apache.org.
Allows the xml parser to be reused per partition.
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/9445d895
Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/9445d895
Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/9445d895
Branch: refs/heads/prestonc/benchmarks
Commit: 9445d89524da703c0cdfe1804228830039cc13d0
Parents: 07a42ea
Author: Preston Carman <pr...@apache.org>
Authored: Wed Feb 12 00:28:40 2014 -0800
Committer: Preston Carman <pr...@apache.org>
Committed: Wed Feb 12 00:28:40 2014 -0800
----------------------------------------------------------------------
.../builders/nodes/DictionaryBuilder.java | 7 +++++
.../VXQueryCollectionOperatorDescriptor.java | 8 +++---
.../runtime/functions/util/FunctionHelper.java | 16 ++++++++++++
.../vxquery/xmlparser/SAXContentHandler.java | 2 ++
.../org/apache/vxquery/xmlparser/XMLParser.java | 27 ++++++++++++++++++++
5 files changed, 57 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/9445d895/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/nodes/DictionaryBuilder.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/nodes/DictionaryBuilder.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/nodes/DictionaryBuilder.java
index 41cc98c..20b7333 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/nodes/DictionaryBuilder.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/nodes/DictionaryBuilder.java
@@ -78,6 +78,13 @@ public class DictionaryBuilder {
tempOut = new DataOutputStream(tempStringData);
tempStringPointable = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
}
+
+ public void reset() {
+ stringEndOffsets.clear();
+ sortedSlotIndexes.clear();
+ dataBuffer.reset();
+ tempStringData.reset();
+ }
public void write(ArrayBackedValueStorage abvs) throws IOException {
DataOutput out = abvs.getDataOutput();
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/9445d895/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java
index 8e18485..593b8ad 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java
@@ -27,11 +27,12 @@ import org.apache.vxquery.datamodel.accessors.PointablePool;
import org.apache.vxquery.datamodel.accessors.PointablePoolFactory;
import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
import org.apache.vxquery.exceptions.SystemException;
-import org.apache.vxquery.runtime.functions.step.ChildPathStep;
+import org.apache.vxquery.runtime.functions.step.ChildPathStepOperatorDescriptor;
import org.apache.vxquery.runtime.functions.util.FunctionHelper;
import org.apache.vxquery.xmlparser.ITreeNodeIdProvider;
import org.apache.vxquery.xmlparser.SAXContentHandler;
import org.apache.vxquery.xmlparser.TreeNodeIdProvider;
+import org.apache.vxquery.xmlparser.XMLParser;
import org.xml.sax.InputSource;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -80,9 +81,10 @@ public class VXQueryCollectionOperatorDescriptor extends AbstractSingleActivityO
final String nodeId = ctx.getJobletContext().getApplicationContext().getNodeId();
final int frameSize = ctx.getFrameSize();
final PointablePool ppool = PointablePoolFactory.INSTANCE.createPointablePool();
- final ChildPathStep childPathStep = new ChildPathStep(ctx, ppool);
+ final ChildPathStepOperatorDescriptor childPathStep = new ChildPathStepOperatorDescriptor(ctx, ppool);
final String collectionName = collectionPartitions[partition % collectionPartitions.length];
+ final XMLParser parser = new XMLParser(false, nodeIdProvider);;
return new AbstractUnaryInputUnaryOutputOperatorNodePushable() {
@Override
@@ -120,7 +122,7 @@ public class VXQueryCollectionOperatorDescriptor extends AbstractSingleActivityO
// Now add new field.
abvsFileNode.reset();
try {
- FunctionHelper.readInDocFromString(file, in, abvsFileNode, nodeIdProvider);
+ FunctionHelper.readInDocFromString(file, in, abvsFileNode, parser);
} catch (Exception e) {
throw new HyracksDataException(e);
}
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/9445d895/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
index e96c8a9..f444bc7 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
@@ -1677,6 +1677,22 @@ public class FunctionHelper {
}
public static void readInDocFromString(File file, InputSource in, ArrayBackedValueStorage abvs,
+ XMLParser parser) throws SystemException {
+ try {
+ if (file.getName().toLowerCase().endsWith(".xml.gz")) {
+ in.setCharacterStream(new InputStreamReader(new GZIPInputStream(new FileInputStream(file))));
+ } else {
+ in.setCharacterStream(new InputStreamReader(new FileInputStream(file)));
+ }
+ parser.parseInputSource(in, abvs);
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException("The file (" + file.getName() + ") does not exist.");
+ } catch (IOException e) {
+ throw new SystemException(ErrorCode.SYSE0001, e);
+ }
+ }
+
+ public static void readInDocFromString(File file, InputSource in, ArrayBackedValueStorage abvs,
ITreeNodeIdProvider treeNodeIdProvider) throws SystemException {
try {
if (file.getName().toLowerCase().endsWith(".xml.gz")) {
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/9445d895/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java
index ecf4d7d..a8ec0b9 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java
@@ -162,6 +162,8 @@ public class SAXContentHandler implements ContentHandler, LexicalHandler {
@Override
public void startDocument() throws SAXException {
try {
+ db.reset();
+ docABVS.reset();
docb.reset(docABVS);
if (createNodeIds) {
docb.setLocalNodeId(nodeIdCounter++);
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/9445d895/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java
index fee41df..c2ada24 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java
@@ -20,9 +20,36 @@ import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
public class XMLParser {
+ XMLReader parser;
+ SAXContentHandler handler;
+
+ public XMLParser(boolean attachTypes, ITreeNodeIdProvider idProvider) throws HyracksDataException {
+ try {
+ parser = XMLReaderFactory.createXMLReader();
+ handler = new SAXContentHandler(attachTypes, idProvider);
+ parser.setContentHandler(handler);
+ parser.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
+ } catch (Exception e) {
+ throw new HyracksDataException(e.toString());
+ }
+ }
+
+ public void parseInputSource(InputSource in, ArrayBackedValueStorage abvs) throws HyracksDataException {
+ try {
+ parser.parse(in);
+ handler.write(abvs);
+ } catch (Exception e) {
+ throw new HyracksDataException(e.toString());
+ }
+ }
+
+ public void reset() throws SystemException {
+ }
+
public static void parseInputSource(InputSource in, ArrayBackedValueStorage abvs, boolean attachTypes,
ITreeNodeIdProvider idProvider) throws SystemException {
XMLReader parser;
[07/10] git commit: Reduced the need for atomize functions
requirement for paintable pool.
Posted by pr...@apache.org.
Reduced the need for atomize functions requirement for paintable pool.
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/337c67ea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/337c67ea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/337c67ea
Branch: refs/heads/prestonc/benchmarks
Commit: 337c67ea4ac45e821b7148ce52383699f1b2b59e
Parents: c4d02d8
Author: Preston Carman <pr...@apache.org>
Authored: Wed Feb 12 11:16:07 2014 -0800
Committer: Preston Carman <pr...@apache.org>
Committed: Wed Feb 12 11:16:07 2014 -0800
----------------------------------------------------------------------
...GeneralComparisonScalarEvaluatorFactory.java | 10 +-
.../functions/misc/FnDataScalarEvaluator.java | 16 +-
.../runtime/functions/util/AtomizeHelper.java | 167 +++++++++++++++++++
.../runtime/functions/util/FunctionHelper.java | 154 -----------------
4 files changed, 180 insertions(+), 167 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/337c67ea/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison/general/AbstractGeneralComparisonScalarEvaluatorFactory.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison/general/AbstractGeneralComparisonScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison/general/AbstractGeneralComparisonScalarEvaluatorFactory.java
index a265c7c..98d74a2 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison/general/AbstractGeneralComparisonScalarEvaluatorFactory.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/comparison/general/AbstractGeneralComparisonScalarEvaluatorFactory.java
@@ -62,6 +62,7 @@ import org.apache.vxquery.runtime.functions.cast.CastToUnsignedShortOperation;
import org.apache.vxquery.runtime.functions.cast.CastToUntypedAtomicOperation;
import org.apache.vxquery.runtime.functions.cast.CastToYMDurationOperation;
import org.apache.vxquery.runtime.functions.comparison.AbstractValueComparisonOperation;
+import org.apache.vxquery.runtime.functions.util.AtomizeHelper;
import org.apache.vxquery.runtime.functions.util.FunctionHelper;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -90,6 +91,7 @@ public abstract class AbstractGeneralComparisonScalarEvaluatorFactory extends
final ArrayBackedValueStorage abvsInner2 = new ArrayBackedValueStorage();
final DataOutput dOutInner2 = abvsInner2.getDataOutput();
+ final AtomizeHelper ah = new AtomizeHelper();
final FunctionHelper.TypedPointables tp1 = new FunctionHelper.TypedPointables();
final FunctionHelper.TypedPointables tp2 = new FunctionHelper.TypedPointables();
final DynamicContext dCtx = (DynamicContext) ctx.getJobletContext().getGlobalJobData();
@@ -199,15 +201,15 @@ public abstract class AbstractGeneralComparisonScalarEvaluatorFactory extends
try {
// Converts node tree's into untyped atomic values that can then be compared as atomic items.
if (tid1 == ValueTag.NODE_TREE_TAG && tid2 == ValueTag.NODE_TREE_TAG) {
- FunctionHelper.atomize(tvpArg1, ppool, tvpTransform1);
- FunctionHelper.atomize(tvpArg2, ppool, tvpTransform2);
+ ah.atomize(tvpArg1, ppool, tvpTransform1);
+ ah.atomize(tvpArg2, ppool, tvpTransform2);
tid1 = FunctionHelper.getBaseTypeForGeneralComparisons(tvpTransform1.getTag());
tid2 = FunctionHelper.getBaseTypeForGeneralComparisons(tvpTransform2.getTag());
} else if (tid1 == ValueTag.NODE_TREE_TAG) {
- FunctionHelper.atomize(tvpArg1, ppool, tvpTransform1);
+ ah.atomize(tvpArg1, ppool, tvpTransform1);
tid1 = FunctionHelper.getBaseTypeForGeneralComparisons(tvpTransform1.getTag());
} else if (tid2 == ValueTag.NODE_TREE_TAG) {
- FunctionHelper.atomize(tvpArg2, ppool, tvpTransform2);
+ ah.atomize(tvpArg2, ppool, tvpTransform2);
tid2 = FunctionHelper.getBaseTypeForGeneralComparisons(tvpTransform2.getTag());
}
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/337c67ea/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/FnDataScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/FnDataScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/FnDataScalarEvaluator.java
index 859f3c5..901d259 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/FnDataScalarEvaluator.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/FnDataScalarEvaluator.java
@@ -25,7 +25,7 @@ import org.apache.vxquery.datamodel.values.ValueTag;
import org.apache.vxquery.exceptions.ErrorCode;
import org.apache.vxquery.exceptions.SystemException;
import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator;
-import org.apache.vxquery.runtime.functions.util.FunctionHelper;
+import org.apache.vxquery.runtime.functions.util.AtomizeHelper;
import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
import edu.uci.ics.hyracks.data.std.api.IPointable;
@@ -38,30 +38,28 @@ public class FnDataScalarEvaluator extends AbstractTaggedValueArgumentScalarEval
final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
final SequenceBuilder sb = new SequenceBuilder();
+ final AtomizeHelper ah = new AtomizeHelper();
+ final TaggedValuePointable tempTVP = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+ final SequencePointable seq = (SequencePointable) SequencePointable.FACTORY.createPointable();
+ final TaggedValuePointable p = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
try {
abvs.reset();
sb.reset(abvs);
TaggedValuePointable tvp = args[0];
- TaggedValuePointable tempTVP = ppool.takeOne(TaggedValuePointable.class);
if (tvp.getTag() == ValueTag.SEQUENCE_TAG) {
- SequencePointable seq = ppool.takeOne(SequencePointable.class);
- TaggedValuePointable p = ppool.takeOne(TaggedValuePointable.class);
tvp.getValue(seq);
int seqLen = seq.getEntryCount();
for (int j = 0; j < seqLen; ++j) {
seq.getEntry(j, p);
- FunctionHelper.atomize(p, ppool, tempTVP);
+ ah.atomize(p, ppool, tempTVP);
sb.addItem(tempTVP);
}
- ppool.giveBack(p);
- ppool.giveBack(seq);
} else {
- FunctionHelper.atomize(tvp, ppool, tempTVP);
+ ah.atomize(tvp, ppool, tempTVP);
sb.addItem(tempTVP);
}
- ppool.giveBack(tempTVP);
sb.finish();
result.set(abvs);
} catch (IOException e) {
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/337c67ea/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/AtomizeHelper.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/AtomizeHelper.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/AtomizeHelper.java
new file mode 100644
index 0000000..ed9cd72
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/AtomizeHelper.java
@@ -0,0 +1,167 @@
+/*
+ * 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.util;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.vxquery.datamodel.accessors.PointablePool;
+import org.apache.vxquery.datamodel.accessors.SequencePointable;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.AttributeNodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.DocumentNodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.ElementNodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.NodeTreePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.PINodePointable;
+import org.apache.vxquery.datamodel.accessors.nodes.TextOrCommentNodePointable;
+import org.apache.vxquery.datamodel.values.ValueTag;
+
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+import edu.uci.ics.hyracks.data.std.primitive.VoidPointable;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+
+public class AtomizeHelper {
+ AttributeNodePointable anp = (AttributeNodePointable) AttributeNodePointable.FACTORY.createPointable();
+ DocumentNodePointable dnp = (DocumentNodePointable) DocumentNodePointable.FACTORY.createPointable();
+ ElementNodePointable enp = (ElementNodePointable) ElementNodePointable.FACTORY.createPointable();
+ NodeTreePointable ntp = (NodeTreePointable) NodeTreePointable.FACTORY.createPointable();
+ PINodePointable pnp = (PINodePointable) PINodePointable.FACTORY.createPointable();
+ SequencePointable sp = (SequencePointable) SequencePointable.FACTORY.createPointable();
+ TextOrCommentNodePointable tcnp = (TextOrCommentNodePointable) TextOrCommentNodePointable.FACTORY.createPointable();
+ ArrayBackedValueStorage tempABVS = new ArrayBackedValueStorage();
+ TaggedValuePointable tempTVP = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+ VoidPointable vp = (VoidPointable) VoidPointable.FACTORY.createPointable();
+
+ public void atomize(TaggedValuePointable tvp, PointablePool pp, IPointable result) throws IOException {
+ switch (tvp.getTag()) {
+ case ValueTag.NODE_TREE_TAG:
+ tvp.getValue(ntp);
+ atomizeNode(ntp, pp, result);
+ break;
+
+ default:
+ result.set(tvp);
+ }
+ }
+
+ public void atomizeNode(NodeTreePointable ntp, PointablePool pp, IPointable result) throws IOException {
+ ntp.getRootNode(tempTVP);
+ switch (tempTVP.getTag()) {
+ case ValueTag.ATTRIBUTE_NODE_TAG: {
+ tempTVP.getValue(anp);
+ anp.getValue(ntp, result);
+ break;
+ }
+
+ case ValueTag.TEXT_NODE_TAG:
+ case ValueTag.COMMENT_NODE_TAG: {
+ tempTVP.getValue(tcnp);
+ tcnp.getValue(ntp, vp);
+ tempABVS.reset();
+ tempABVS.getDataOutput().write(ValueTag.XS_UNTYPED_ATOMIC_TAG);
+ tempABVS.append(vp);
+ result.set(tempABVS.getByteArray(), tempABVS.getStartOffset(), tempABVS.getLength());
+ break;
+ }
+
+ case ValueTag.DOCUMENT_NODE_TAG: {
+ tempTVP.getValue(dnp);
+ dnp.getContent(ntp, sp);
+ buildStringConcatenation(sp, pp, tempABVS, ntp);
+ result.set(tempABVS.getByteArray(), tempABVS.getStartOffset(), tempABVS.getLength());
+ break;
+ }
+
+ case ValueTag.ELEMENT_NODE_TAG: {
+ tempTVP.getValue(enp);
+ if (enp.childrenChunkExists()) {
+ enp.getChildrenSequence(ntp, sp);
+ buildStringConcatenation(sp, pp, tempABVS, ntp);
+ result.set(tempABVS.getByteArray(), tempABVS.getStartOffset(), tempABVS.getLength());
+ }
+ break;
+ }
+
+ case ValueTag.PI_NODE_TAG: {
+ tempTVP.getValue(pnp);
+ pnp.getContent(ntp, vp);
+ tempABVS.reset();
+ tempABVS.getDataOutput().write(ValueTag.XS_UNTYPED_ATOMIC_TAG);
+ tempABVS.append(vp);
+ result.set(tempABVS.getByteArray(), tempABVS.getStartOffset(), tempABVS.getLength());
+ break;
+ }
+
+ }
+ }
+
+ public static void buildConcatenationRec(SequencePointable sp, PointablePool pp, DataOutput out,
+ NodeTreePointable ntp) throws IOException {
+ TaggedValuePointable tempTVP2 = pp.takeOne(TaggedValuePointable.class);
+ int nItems = sp.getEntryCount();
+ for (int i = 0; i < nItems; ++i) {
+ sp.getEntry(i, tempTVP2);
+ switch (tempTVP2.getTag()) {
+ case ValueTag.TEXT_NODE_TAG: {
+ TextOrCommentNodePointable tcnp = pp.takeOne(TextOrCommentNodePointable.class);
+ VoidPointable vp = pp.takeOne(VoidPointable.class);
+ try {
+ tempTVP2.getValue(tcnp);
+ tcnp.getValue(ntp, vp);
+ out.write(vp.getByteArray(), vp.getStartOffset() + 2, vp.getLength() - 2);
+ } finally {
+ pp.giveBack(vp);
+ pp.giveBack(tcnp);
+ }
+ break;
+ }
+ case ValueTag.ELEMENT_NODE_TAG: {
+ ElementNodePointable enp = pp.takeOne(ElementNodePointable.class);
+ SequencePointable sp2 = pp.takeOne(SequencePointable.class);
+ try {
+ tempTVP2.getValue(enp);
+ if (enp.childrenChunkExists()) {
+ enp.getChildrenSequence(ntp, sp2);
+ buildConcatenationRec(sp2, pp, out, ntp);
+ }
+ } finally {
+ pp.giveBack(sp2);
+ pp.giveBack(enp);
+ }
+ }
+ }
+ }
+ pp.giveBack(tempTVP2);
+ }
+
+ public static void buildStringConcatenation(SequencePointable sp, PointablePool pp,
+ ArrayBackedValueStorage tempABVS, NodeTreePointable ntp) throws IOException {
+ tempABVS.reset();
+ DataOutput out = tempABVS.getDataOutput();
+ out.write(ValueTag.XS_UNTYPED_ATOMIC_TAG);
+ // Leave room for the utf-8 length
+ out.write(0);
+ out.write(0);
+ buildConcatenationRec(sp, pp, out, ntp);
+ int utflen = tempABVS.getLength() - 3;
+ byte[] bytes = tempABVS.getByteArray();
+ // Patch utf-8 length at bytes 1 and 2
+ bytes[1] = (byte) ((utflen >>> 8) & 0xFF);
+ bytes[2] = (byte) ((utflen >>> 0) & 0xFF);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/337c67ea/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
index f444bc7..9bcdf46 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
@@ -514,160 +514,6 @@ public class FunctionHelper {
throw new SystemException(ErrorCode.XPTY0004);
}
- public static void atomize(TaggedValuePointable tvp, PointablePool pp, IPointable result) throws IOException {
- NodeTreePointable ntp = pp.takeOne(NodeTreePointable.class);
- switch (tvp.getTag()) {
- case ValueTag.NODE_TREE_TAG:
- tvp.getValue(ntp);
- atomizeNode(ntp, pp, result);
- break;
-
- default:
- result.set(tvp);
- }
- pp.giveBack(ntp);
- }
-
- public static void atomizeNode(NodeTreePointable ntp, PointablePool pp, IPointable result) throws IOException {
- ArrayBackedValueStorage tempABVS = new ArrayBackedValueStorage();
- TaggedValuePointable tempTVP = pp.takeOne(TaggedValuePointable.class);
- VoidPointable vp = pp.takeOne(VoidPointable.class);
- ntp.getRootNode(tempTVP);
- switch (tempTVP.getTag()) {
- case ValueTag.ATTRIBUTE_NODE_TAG: {
- AttributeNodePointable anp = pp.takeOne(AttributeNodePointable.class);
- try {
- tempTVP.getValue(anp);
- anp.getValue(ntp, result);
- } finally {
- pp.giveBack(anp);
- }
- break;
- }
-
- case ValueTag.TEXT_NODE_TAG:
- case ValueTag.COMMENT_NODE_TAG: {
- TextOrCommentNodePointable tcnp = pp.takeOne(TextOrCommentNodePointable.class);
- try {
- tempTVP.getValue(tcnp);
- tcnp.getValue(ntp, vp);
- tempABVS.reset();
- tempABVS.getDataOutput().write(ValueTag.XS_UNTYPED_ATOMIC_TAG);
- tempABVS.append(vp);
- result.set(tempABVS.getByteArray(), tempABVS.getStartOffset(), tempABVS.getLength());
- } finally {
- pp.giveBack(tcnp);
- }
- break;
- }
-
- case ValueTag.DOCUMENT_NODE_TAG: {
- DocumentNodePointable dnp = pp.takeOne(DocumentNodePointable.class);
- SequencePointable sp = pp.takeOne(SequencePointable.class);
- try {
- tempTVP.getValue(dnp);
- dnp.getContent(ntp, sp);
- buildStringConcatenation(sp, pp, tempABVS, ntp);
- result.set(tempABVS.getByteArray(), tempABVS.getStartOffset(), tempABVS.getLength());
- } finally {
- pp.giveBack(sp);
- pp.giveBack(dnp);
- }
- break;
- }
-
- case ValueTag.ELEMENT_NODE_TAG: {
- ElementNodePointable enp = pp.takeOne(ElementNodePointable.class);
- SequencePointable sp = pp.takeOne(SequencePointable.class);
- try {
- tempTVP.getValue(enp);
- if (enp.childrenChunkExists()) {
- enp.getChildrenSequence(ntp, sp);
- buildStringConcatenation(sp, pp, tempABVS, ntp);
- result.set(tempABVS.getByteArray(), tempABVS.getStartOffset(), tempABVS.getLength());
- }
- } finally {
- pp.giveBack(sp);
- pp.giveBack(enp);
- }
- break;
- }
-
- case ValueTag.PI_NODE_TAG: {
- PINodePointable pnp = pp.takeOne(PINodePointable.class);
- try {
- tempTVP.getValue(pnp);
- pnp.getContent(ntp, vp);
- tempABVS.reset();
- tempABVS.getDataOutput().write(ValueTag.XS_UNTYPED_ATOMIC_TAG);
- tempABVS.append(vp);
- result.set(tempABVS.getByteArray(), tempABVS.getStartOffset(), tempABVS.getLength());
- } finally {
- pp.giveBack(pnp);
- }
- break;
- }
-
- }
- pp.giveBack(vp);
- pp.giveBack(tempTVP);
- }
-
- public static void buildStringConcatenation(SequencePointable sp, PointablePool pp,
- ArrayBackedValueStorage tempABVS, NodeTreePointable ntp) throws IOException {
- tempABVS.reset();
- DataOutput out = tempABVS.getDataOutput();
- out.write(ValueTag.XS_UNTYPED_ATOMIC_TAG);
- // Leave room for the utf-8 length
- out.write(0);
- out.write(0);
- buildConcatenationRec(sp, pp, out, ntp);
- int utflen = tempABVS.getLength() - 3;
- byte[] bytes = tempABVS.getByteArray();
- // Patch utf-8 length at bytes 1 and 2
- bytes[1] = (byte) ((utflen >>> 8) & 0xFF);
- bytes[2] = (byte) ((utflen >>> 0) & 0xFF);
- }
-
- public static void buildConcatenationRec(SequencePointable sp, PointablePool pp, DataOutput out,
- NodeTreePointable ntp) throws IOException {
- TaggedValuePointable tempTVP2 = pp.takeOne(TaggedValuePointable.class);
- int nItems = sp.getEntryCount();
- for (int i = 0; i < nItems; ++i) {
- sp.getEntry(i, tempTVP2);
- switch (tempTVP2.getTag()) {
- case ValueTag.TEXT_NODE_TAG: {
- TextOrCommentNodePointable tcnp = pp.takeOne(TextOrCommentNodePointable.class);
- VoidPointable vp = pp.takeOne(VoidPointable.class);
- try {
- tempTVP2.getValue(tcnp);
- tcnp.getValue(ntp, vp);
- out.write(vp.getByteArray(), vp.getStartOffset() + 2, vp.getLength() - 2);
- } finally {
- pp.giveBack(vp);
- pp.giveBack(tcnp);
- }
- break;
- }
- case ValueTag.ELEMENT_NODE_TAG: {
- ElementNodePointable enp = pp.takeOne(ElementNodePointable.class);
- SequencePointable sp2 = pp.takeOne(SequencePointable.class);
- try {
- tempTVP2.getValue(enp);
- if (enp.childrenChunkExists()) {
- enp.getChildrenSequence(ntp, sp2);
- buildConcatenationRec(sp2, pp, out, ntp);
- }
- } finally {
- pp.giveBack(sp2);
- pp.giveBack(enp);
- }
- }
- }
- }
- pp.giveBack(tempTVP2);
- }
-
public static boolean compareTaggedValues(AbstractValueComparisonOperation aOp, TaggedValuePointable tvp1,
TaggedValuePointable tvp2, PointablePool pp, DynamicContext dCtx) throws SystemException {
int tid1 = getBaseTypeForComparisons(tvp1.getTag());