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 2013/04/16 07:21:46 UTC
svn commit: r1468304 - in
/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery:
datamodel/accessors/nodes/ functions/ runtime/functions/node/
runtime/functions/step/ runtime/functions/util/ xmlparser/
Author: prestonc
Date: Tue Apr 16 05:21:46 2013
New Revision: 1468304
URL: http://svn.apache.org/r1468304
Log:
Changed the Node Tree ID from a long to int. Also added a new operator for getting the node id as a combined long from node tree and local id.
Modified:
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/NodeTreePointable.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/LocalIdFromNodeScalarEvaluatorFactory.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/TreeIdFromNodeScalarEvaluatorFactory.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractPathStepScalarEvaluator.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/ITreeNodeIdProvider.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/TreeNodeIdProvider.java
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/NodeTreePointable.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/NodeTreePointable.java?rev=1468304&r1=1468303&r2=1468304&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/NodeTreePointable.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/nodes/NodeTreePointable.java Tue Apr 16 05:21:46 2013
@@ -37,7 +37,7 @@ public class NodeTreePointable extends A
private static final int HEADER_OFFSET = 0;
private static final int HEADER_SIZE = 1;
- private static final int NODE_ID_SIZE = 8;
+ private static final int NODE_ID_SIZE = 4;
private static final int DICTIONARY_SIZE_SIZE = 4;
private static final int DICTIONARY_NENTRIES_SIZE = 4;
@@ -98,8 +98,8 @@ public class NodeTreePointable extends A
return (getHeader() & HEADER_TYPE_EXISTS_MASK) != 0;
}
- public long getRootNodeId() {
- return nodeIdExists() ? LongPointable.getLong(bytes, getNodeIdOffset()) : -1;
+ public int getRootNodeId() {
+ return nodeIdExists() ? IntegerPointable.getInteger(bytes, getNodeIdOffset()) : -1;
}
public int getDictionaryEntryCount() {
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml?rev=1468304&r1=1468303&r2=1468304&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml Tue Apr 16 05:21:46 2013
@@ -760,17 +760,24 @@
<return type="item()*"/>
</operator>
- <!-- opext:local-id-from-node($arg as node()) as xs:int -->
+ <!-- opext:id-from-node($arg as item()) as xs:integer -->
+ <operator name="opext:id-from-node">
+ <param name="arg" type="item()"/>
+ <return type="xs:integer"/>
+ <runtime type="scalar" class="org.apache.vxquery.runtime.functions.node.IdFromNodeScalarEvaluatorFactory"/>
+ </operator>
+
+ <!-- opext:local-id-from-node($arg as item()) as xs:int -->
<operator name="opext:local-id-from-node">
- <param name="arg" type="node()"/>
+ <param name="arg" type="item()"/>
<return type="xs:int"/>
<runtime type="scalar" class="org.apache.vxquery.runtime.functions.node.LocalIdFromNodeScalarEvaluatorFactory"/>
</operator>
- <!-- opext:tree-id-from-node($arg as node()) as xs:integer -->
+ <!-- opext:tree-id-from-node($arg as item()) as xs:int -->
<operator name="opext:tree-id-from-node">
- <param name="arg" type="node()"/>
- <return type="xs:integer"/>
+ <param name="arg" type="item()"/>
+ <return type="xs:int"/>
<runtime type="scalar" class="org.apache.vxquery.runtime.functions.node.TreeIdFromNodeScalarEvaluatorFactory"/>
</operator>
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/LocalIdFromNodeScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/LocalIdFromNodeScalarEvaluatorFactory.java?rev=1468304&r1=1468303&r2=1468304&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/LocalIdFromNodeScalarEvaluatorFactory.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/LocalIdFromNodeScalarEvaluatorFactory.java Tue Apr 16 05:21:46 2013
@@ -19,8 +19,8 @@ package org.apache.vxquery.runtime.funct
import java.io.DataOutput;
import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
-import org.apache.vxquery.datamodel.accessors.nodes.NodeTreePointable;
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.base.AbstractTaggedValueArgumentScalarEvaluator;
@@ -46,56 +46,28 @@ public class LocalIdFromNodeScalarEvalua
throws AlgebricksException {
final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
final DataOutput dOut = abvs.getDataOutput();
- final TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
- final FunctionHelper.TypedPointables tp = new FunctionHelper.TypedPointables();
return new AbstractTaggedValueArgumentScalarEvaluator(args) {
@Override
protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
TaggedValuePointable tvp1 = args[0];
// Only accept node trees as input.
- if (tvp1.getTag() == ValueTag.NODE_TREE_TAG) {
- try {
+ try {
+ int localNodeId = FunctionHelper.getLocalNodeId(tvp1);
+ if (localNodeId == -1) {
+ XDMConstants.setEmptySequence(result);
+ } else {
abvs.reset();
- tvp1.getValue(tp.ntp);
dOut.write(ValueTag.XS_INT_TAG);
- tp.ntp.getRootNode(tvp);
- switch (tvp.getTag()) {
- case ValueTag.ATTRIBUTE_NODE_TAG:
- tvp.getValue(tp.anp);
- dOut.writeInt(tp.anp.getLocalNodeId(tp.ntp));
- break;
- case ValueTag.COMMENT_NODE_TAG:
- case ValueTag.TEXT_NODE_TAG:
- tvp.getValue(tp.tocnp);
- dOut.writeInt(tp.tocnp.getLocalNodeId(tp.ntp));
- break;
- case ValueTag.DOCUMENT_NODE_TAG:
- tvp.getValue(tp.dnp);
- dOut.writeInt(tp.dnp.getLocalNodeId(tp.ntp));
- break;
- case ValueTag.ELEMENT_NODE_TAG:
- tvp.getValue(tp.enp);
- dOut.writeInt(tp.enp.getLocalNodeId(tp.ntp));
- break;
- case ValueTag.PI_NODE_TAG:
- tvp.getValue(tp.pinp);
- dOut.writeInt(tp.pinp.getLocalNodeId(tp.ntp));
- break;
- default:
- dOut.writeInt(-1);
- }
-
+ dOut.writeInt(localNodeId);
result.set(abvs);
- } catch (Exception e) {
- throw new SystemException(ErrorCode.SYSE0001, e);
}
- } else {
- throw new SystemException(ErrorCode.FORG0006);
+ } catch (Exception e) {
+ throw new SystemException(ErrorCode.SYSE0001, e);
}
}
+
};
}
-
}
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/TreeIdFromNodeScalarEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/TreeIdFromNodeScalarEvaluatorFactory.java?rev=1468304&r1=1468303&r2=1468304&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/TreeIdFromNodeScalarEvaluatorFactory.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/TreeIdFromNodeScalarEvaluatorFactory.java Tue Apr 16 05:21:46 2013
@@ -21,6 +21,7 @@ import java.io.DataOutput;
import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
import org.apache.vxquery.datamodel.accessors.nodes.NodeTreePointable;
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.base.AbstractTaggedValueArgumentScalarEvaluator;
@@ -56,14 +57,15 @@ public class TreeIdFromNodeScalarEvaluat
try {
abvs.reset();
tvp1.getValue(ntp);
- dOut.write(ValueTag.XS_INTEGER_TAG);
- dOut.writeLong(ntp.getRootNodeId());
+ dOut.write(ValueTag.XS_INT_TAG);
+ tvp1.getValue(ntp);
+ dOut.writeInt(ntp.getRootNodeId());
result.set(abvs);
} catch (Exception e) {
throw new SystemException(ErrorCode.SYSE0001, e);
}
} else {
- throw new SystemException(ErrorCode.FORG0006);
+ XDMConstants.setEmptySequence(result);
}
}
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractPathStepScalarEvaluator.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractPathStepScalarEvaluator.java?rev=1468304&r1=1468303&r2=1468304&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractPathStepScalarEvaluator.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/step/AbstractPathStepScalarEvaluator.java Tue Apr 16 05:21:46 2013
@@ -223,8 +223,7 @@ public abstract class AbstractPathStepSc
}
mainOut.write(header);
if (hasNodeIds) {
- // TODO put in real id.
- mainOut.writeLong(ntp.getRootNodeId());
+ mainOut.writeInt(ntp.getRootNodeId());
}
if (hasDictionary) {
mainOut.write(ntp.getByteArray(), ntp.getDictionaryOffset(), ntp.getDictionarySize());
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java?rev=1468304&r1=1468303&r2=1468304&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java Tue Apr 16 05:21:46 2013
@@ -1083,6 +1083,46 @@ public class FunctionHelper {
}
/**
+ * Get the local node id from a tagged value pointable when available.
+ */
+ public static int getLocalNodeId(TaggedValuePointable tvp1) {
+ final TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+ final TypedPointables tp = new TypedPointables();
+ int localNodeId = -1;
+ if (tvp1.getTag() == ValueTag.NODE_TREE_TAG) {
+ tvp1.getValue(tp.ntp);
+ tp.ntp.getRootNode(tvp);
+ switch (tvp.getTag()) {
+ case ValueTag.ATTRIBUTE_NODE_TAG:
+ tvp.getValue(tp.anp);
+ localNodeId = tp.anp.getLocalNodeId(tp.ntp);
+ break;
+ case ValueTag.COMMENT_NODE_TAG:
+ case ValueTag.TEXT_NODE_TAG:
+ tvp.getValue(tp.tocnp);
+ localNodeId = tp.tocnp.getLocalNodeId(tp.ntp);
+ break;
+ case ValueTag.DOCUMENT_NODE_TAG:
+ tvp.getValue(tp.dnp);
+ localNodeId = tp.dnp.getLocalNodeId(tp.ntp);
+ break;
+ case ValueTag.ELEMENT_NODE_TAG:
+ tvp.getValue(tp.enp);
+ localNodeId = tp.enp.getLocalNodeId(tp.ntp);
+ break;
+ case ValueTag.PI_NODE_TAG:
+ tvp.getValue(tp.pinp);
+ localNodeId = tp.pinp.getLocalNodeId(tp.ntp);
+ break;
+ default:
+ localNodeId = -1;
+ break;
+ }
+ }
+ return localNodeId;
+ }
+
+ /**
* Returns the number of digits in a long. A few special cases that needed attention.
*/
public static int getNumberOfDigits(long value) {
@@ -1366,4 +1406,5 @@ public class FunctionHelper {
}
}
}
+
}
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/ITreeNodeIdProvider.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/ITreeNodeIdProvider.java?rev=1468304&r1=1468303&r2=1468304&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/ITreeNodeIdProvider.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/ITreeNodeIdProvider.java Tue Apr 16 05:21:46 2013
@@ -17,5 +17,5 @@
package org.apache.vxquery.xmlparser;
public interface ITreeNodeIdProvider {
- public long getId();
+ public int getId();
}
\ No newline at end of file
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java?rev=1468304&r1=1468303&r2=1468304&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/SAXContentHandler.java Tue Apr 16 05:21:46 2013
@@ -306,7 +306,7 @@ public class SAXContentHandler implement
}
out.write(header);
if (createNodeIds) {
- out.writeLong(nodeIdProvider.getId());
+ out.writeInt(nodeIdProvider.getId());
}
db.write(abvs);
out.write(docABVS.getByteArray(), docABVS.getStartOffset(), docABVS.getLength());
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/TreeNodeIdProvider.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/TreeNodeIdProvider.java?rev=1468304&r1=1468303&r2=1468304&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/TreeNodeIdProvider.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/TreeNodeIdProvider.java Tue Apr 16 05:21:46 2013
@@ -20,7 +20,7 @@ public class TreeNodeIdProvider implemen
private final short partitionDataSource;
private final short dataSouceScanId;
- private int currentId;
+ private short currentId;
public TreeNodeIdProvider(short partitionDataSource, short dataSouceScanId) {
this.partitionDataSource = partitionDataSource;
@@ -35,9 +35,10 @@ public class TreeNodeIdProvider implemen
currentId = 0;
}
- public long getId() {
- long p = partitionDataSource;
- long dssi = dataSouceScanId;
- return ((p << 48) | (dssi << 32)) | currentId++;
+ public int getId() {
+ int p = partitionDataSource;
+ int dssi = dataSouceScanId;
+ // TODO the first 2 bytes from a combination of data source scan id and currentId.
+ return (p << 16) | currentId++;
}
}
\ No newline at end of file