lock.acquire(Lock.WRITE_LOCK);
final Value value = dbTokens.get(key);
if (value == null)
{continue;}
//Add its data to the new list
final VariableByteArrayInput is = new VariableByteArrayInput(value.getData());
while (is.available() > 0) {
final int storedDocId = is.readInt();
final byte storedSection = is.readByte();
final int termCount = is.readInt();
//Read (variable) length of node IDs + frequency + offsets
final int length = is.readFixedInt();
if (storedSection != currentSection || storedDocId != this.doc.getDocId()) {
// data are related to another section or document:
// append them to any existing data
os.writeInt(storedDocId);
os.writeByte(storedSection);
os.writeInt(termCount);
os.writeFixedInt(length);
is.copyRaw(os, length);
} else {
// data are related to our section and document:
// feed the new list with the GIDs
NodeId previous = null;
for (int m = 0; m < termCount; m++) {
NodeId nodeId = broker.getBrokerPool()
.getNodeFactory().createFromStream(previous, is);
previous = nodeId;
final int freq = is.readInt();
// add the node to the new list if it is not
// in the list of removed nodes
if (!storedOccurencesList.contains(nodeId)) {
for (int n = 0; n < freq; n++) {
newOccurencesList.add(nodeId, is.readInt());
}
} else {
is.skip(freq);
}
}
}
}
//append the data from the new list