catch( final IOException e ) {
LOG.error( e.getMessage(), e );
return( true );
}
ValueOccurrences oc = map.get( atomic );
try {
while( is.available() > 0 ) {
boolean docAdded = false;
final int storedDocId = is.readInt();
final int gidsCount = is.readInt();
final int size = is.readFixedInt();
final DocumentImpl storedDocument = docs.getDoc( storedDocId );
//Exit if the document is not concerned
if( storedDocument == null ) {
is.skipBytes( size );
continue;
}
NodeId lastParentId = null;
NodeId previous = null;
NodeId nodeId;
NodeProxy parentNode;
for( int j = 0; j < gidsCount; j++ ) {
nodeId = broker.getBrokerPool().getNodeFactory().createFromStream( previous, is );
previous = nodeId;
if( contextSet != null ) {
parentNode = contextSet.get(storedDocument, nodeId);
// parentNode = contextSet.parentWithChild( storedDocument, nodeId, false, true );
} else {
parentNode = new NodeProxy( storedDocument, nodeId );
}
if( parentNode != null ) {
if( oc == null ) {
oc = new ValueOccurrences( atomic );
map.put( atomic, oc );
}
//Handle this very special case : /item[foo = "bar"] vs. /item[@foo = "bar"]
//Same value, same parent but different nodes !
//Not sure if we should track the contextSet's parentId... (just like we do)
//... or the way the contextSet is created (thus keeping track of the NodeTest)
if( ( lastParentId == null ) || !lastParentId.equals( parentNode.getNodeId() ) ) {
oc.addOccurrences( 1 );
}
if( !docAdded ) {
oc.addDocument( storedDocument );
docAdded = true;
}
lastParentId = parentNode.getNodeId();
}
//TODO : what if contextSet == null ? -pb