Skip to content

Commit

Permalink
[feature] Infer NodeProxy node type from name type. Allows future
Browse files Browse the repository at this point in the history
optimisation of directly seeking NGram value for attributes.
  • Loading branch information
adamretter committed Apr 6, 2015
1 parent 6b5d2ca commit e39c14d
Showing 1 changed file with 16 additions and 2 deletions.
Expand Up @@ -967,7 +967,7 @@ public boolean indexInfo(Value key, long pointer) throws TerminatedException {
return true;
while (is.available() > 0) {
int storedDocId = is.readInt();
is.readByte();
byte nameType = is.readByte();
int occurrences = is.readInt();
//Read (variable) length of node IDs + frequency + offsets
int length = is.readFixedInt();
Expand All @@ -982,7 +982,7 @@ public boolean indexInfo(Value key, long pointer) throws TerminatedException {
NodeId nodeId = index.getBrokerPool().getNodeFactory().createFromStream(previous, is);
previous = nodeId;
int freq = is.readInt();
NodeProxy nodeProxy = new NodeProxy(storedDocument, nodeId);
NodeProxy nodeProxy = new NodeProxy(storedDocument, nodeId, nameTypeToNodeType(nameType));
// if a context set is specified, we can directly check if the
// matching node is a descendant of one of the nodes
// in the context set.
Expand Down Expand Up @@ -1014,6 +1014,20 @@ public boolean indexInfo(Value key, long pointer) throws TerminatedException {
}
}

private short nameTypeToNodeType(final byte nameType) {
switch(nameType) {
case ElementValue.ELEMENT:
return Node.ELEMENT_NODE;

case ElementValue.ATTRIBUTE:
return Node.ATTRIBUTE_NODE;

case ElementValue.UNKNOWN:
default:
return NodeProxy.UNKNOWN_NODE_TYPE;
}
}

private void readMatches(String current, VariableByteInput is, NodeId nodeId, int freq, NodeProxy parentNode) throws IOException {
int diff = 0;
if (current.length() > ngram.length())
Expand Down

0 comments on commit e39c14d

Please sign in to comment.