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/01/31 08:21:22 UTC
[06/13] git commit: Added a PointablePool to ChildPathStep.
Added a PointablePool to ChildPathStep.
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/323ea197
Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/323ea197
Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/323ea197
Branch: refs/heads/prestonc/benchmarks
Commit: 323ea1974698df3193ad57ed472f144a6de33ba8
Parents: fc136fc
Author: Preston Carman <pr...@apache.org>
Authored: Thu Jan 30 14:08:26 2014 -0800
Committer: Preston Carman <pr...@apache.org>
Committed: Thu Jan 30 14:08:26 2014 -0800
----------------------------------------------------------------------
.../VXQueryCollectionOperatorDescriptor.java | 7 +++-
.../runtime/functions/step/ChildPathStep.java | 42 +++++++++++--------
.../step/ChildPathStepUnnestingEvaluator.java | 44 ++++++++++++++++++++
.../ChildPathStepUnnestingEvaluatorFactory.java | 18 +-------
4 files changed, 75 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/323ea197/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 538c58f..976b2a7 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
@@ -20,6 +20,8 @@ import java.io.File;
import java.nio.ByteBuffer;
import java.util.List;
+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;
@@ -75,7 +77,9 @@ public class VXQueryCollectionOperatorDescriptor extends AbstractSingleActivityO
final ITreeNodeIdProvider nodeIdProvider = new TreeNodeIdProvider(partitionId, dataSourceId, totalDataSources);
final String nodeId = ctx.getJobletContext().getApplicationContext().getNodeId();
final int frameSize = ctx.getFrameSize();
- final IHyracksTaskContext ctx1 = ctx;
+ final PointablePool ppool = PointablePoolFactory.INSTANCE.createPointablePool();
+ final ChildPathStep childPathStep = new ChildPathStep(ctx, ppool);
+
final String collectionName = collectionPartitions[partition % collectionPartitions.length];
return new AbstractUnaryInputUnaryOutputOperatorNodePushable() {
@@ -144,7 +148,6 @@ public class VXQueryCollectionOperatorDescriptor extends AbstractSingleActivityO
private void processChildStep(final ArrayTupleBuilder tb, TaggedValuePointable tvp, int t)
throws HyracksDataException {
TaggedValuePointable result = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
- ChildPathStep childPathStep = new ChildPathStep(ctx1);
try {
childPathStep.init(tvp, childSeq);
} catch (SystemException e) {
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/323ea197/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
index da70ca8..f77647b 100644
--- 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
@@ -17,10 +17,11 @@
package org.apache.vxquery.runtime.functions.step;
import java.io.IOException;
-import java.util.List;
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;
@@ -42,40 +43,39 @@ import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
public class ChildPathStep {
private final DynamicContext dCtx;
- private List<INodeFilter> filter;
+ private List<INodeFilter> filter = new ArrayList<INodeFilter>();
private int indexSeqArgs;
private int[] indexSequence;
- private ArrayBackedValueStorage nodeAbvs;
+ private final ArrayBackedValueStorage nodeAbvs = new ArrayBackedValueStorage();
private final NodeTreePointable ntp = (NodeTreePointable) NodeTreePointable.FACTORY.createPointable();
private int seqArgsLength;
private final SequencePointable seqNtp = (SequencePointable) SequencePointable.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 IntegerPointable ip = (IntegerPointable) IntegerPointable.FACTORY.createPointable();
+ protected final PointablePool pp;
- public ChildPathStep(IHyracksTaskContext ctx) {
+ public ChildPathStep(IHyracksTaskContext ctx, PointablePool pp) {
dCtx = (DynamicContext) ctx.getJobletContext().getGlobalJobData();
- nodeAbvs = new ArrayBackedValueStorage();
- filter = new ArrayList<INodeFilter>();
+ this.pp = pp;
}
- private void getSequence(TaggedValuePointable tvp, SequencePointable seqp) {
+ protected void getSequence(TaggedValuePointable tvp, SequencePointable seqp) {
switch (tvp.getTag()) {
case ValueTag.DOCUMENT_NODE_TAG:
- DocumentNodePointable dnp = (DocumentNodePointable) DocumentNodePointable.FACTORY.createPointable();
tvp.getValue(dnp);
dnp.getContent(ntp, seqp);
return;
case ValueTag.ELEMENT_NODE_TAG:
- ElementNodePointable enp = (ElementNodePointable) ElementNodePointable.FACTORY.createPointable();
tvp.getValue(enp);
if (enp.childrenChunkExists()) {
enp.getChildrenSequence(ntp, seqp);
return;
}
}
- TaggedValuePointable seqTvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
- XDMConstants.setEmptySequence(seqTvp);
- seqTvp.getValue(seqp);
+ XDMConstants.setEmptySequence(seqp);
}
public void init(TaggedValuePointable tvp, List<Integer> typeCodes) throws SystemException {
@@ -102,7 +102,6 @@ public class ChildPathStep {
if (args[1].getTag() != ValueTag.XS_INT_TAG) {
throw new IllegalArgumentException("Expected int value tag, got: " + args[1].getTag());
}
- IntegerPointable ip = (IntegerPointable) IntegerPointable.FACTORY.createPointable();
args[1].getValue(ip);
int typeCode = ip.getInteger();
setFilterCode(typeCode);
@@ -141,10 +140,10 @@ public class ChildPathStep {
}
public boolean step(IPointable result) throws AlgebricksException {
- TaggedValuePointable tvpRoot = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+ TaggedValuePointable tvpRoot = pp.takeOne(TaggedValuePointable.class);
if (seqArgsLength > 0) {
+ TaggedValuePointable tvpNtp = pp.takeOne(TaggedValuePointable.class);
while (indexSeqArgs < seqArgsLength) {
- TaggedValuePointable tvpNtp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
seqNtp.getEntry(indexSeqArgs, tvpNtp);
if (tvpNtp.getTag() != ValueTag.NODE_TREE_TAG) {
String description = ErrorCode.SYSE0001 + ": " + ErrorCode.SYSE0001.getDescription();
@@ -153,21 +152,27 @@ public class ChildPathStep {
tvpNtp.getValue(ntp);
ntp.getRootNode(tvpRoot);
if (stepNodeTree(tvpRoot, 0, result)) {
+ pp.giveBack(tvpNtp);
+ pp.giveBack(tvpRoot);
return true;
}
}
+ pp.giveBack(tvpNtp);
} else {
// Single node tree input.
ntp.getRootNode(tvpRoot);
if (stepNodeTree(tvpRoot, 0, result)) {
+ pp.giveBack(tvpRoot);
return true;
}
}
+ pp.giveBack(tvpRoot);
return false;
}
- private boolean stepNodeTree(TaggedValuePointable tvpInput, int level, IPointable result) throws AlgebricksException {
- SequencePointable seqItem = (SequencePointable) SequencePointable.FACTORY.createPointable();
+ private 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) {
@@ -178,12 +183,14 @@ public class ChildPathStep {
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(result);
++indexSequence[level];
+ pp.giveBack(seqItem);
return true;
} catch (IOException e) {
String description = ErrorCode.SYSE0001 + ": " + ErrorCode.SYSE0001.getDescription();
@@ -195,6 +202,7 @@ public class ChildPathStep {
}
// 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/323ea197/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
new file mode 100644
index 0000000..0f132fc
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnestingEvaluator.java
@@ -0,0 +1,44 @@
+/*
+ * 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 org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentUnnestingEvaluator;
+
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.data.std.api.IPointable;
+
+public class ChildPathStepUnnestingEvaluator extends AbstractTaggedValueArgumentUnnestingEvaluator {
+ final ChildPathStep childPathStep;
+
+ public ChildPathStepUnnestingEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) {
+ super(args);
+ childPathStep = new ChildPathStep(ctx, ppool);
+ }
+
+ public boolean step(IPointable result) throws AlgebricksException {
+ return childPathStep.step(result);
+ }
+
+ @Override
+ protected void init(TaggedValuePointable[] args) throws SystemException {
+ childPathStep.init(args);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/323ea197/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnestingEvaluatorFactory.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnestingEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnestingEvaluatorFactory.java
index 78b6ae9..fc9844a 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnestingEvaluatorFactory.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/ChildPathStepUnnestingEvaluatorFactory.java
@@ -16,9 +16,6 @@
*/
package org.apache.vxquery.runtime.functions.step;
-import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
-import org.apache.vxquery.exceptions.SystemException;
-import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentUnnestingEvaluator;
import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentUnnestingEvaluatorFactory;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -26,7 +23,6 @@ import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluator;
import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import edu.uci.ics.hyracks.algebricks.runtime.base.IUnnestingEvaluator;
import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
-import edu.uci.ics.hyracks.data.std.api.IPointable;
public class ChildPathStepUnnestingEvaluatorFactory extends AbstractTaggedValueArgumentUnnestingEvaluatorFactory {
private static final long serialVersionUID = 1L;
@@ -38,18 +34,6 @@ public class ChildPathStepUnnestingEvaluatorFactory extends AbstractTaggedValueA
@Override
protected IUnnestingEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
throws AlgebricksException {
- final ChildPathStep childPathStep = new ChildPathStep(ctx);
-
- return new AbstractTaggedValueArgumentUnnestingEvaluator(args) {
- @Override
- public boolean step(IPointable result) throws AlgebricksException {
- return childPathStep.step(result);
- }
-
- @Override
- protected void init(TaggedValuePointable[] args) throws SystemException {
- childPathStep.init(args);
- }
- };
+ return new ChildPathStepUnnestingEvaluator(ctx, args);
}
}
\ No newline at end of file