int txnId = kContext.getLocker();
boolean needLog = kContext.getNeedLog();
//search key2root first
Integer idocID = new Integer(docID);
PageNumber subRoot = (PageNumber) id2root.get(idocID);
if (subRoot == null) {
Key tmpKey = new IntKey(docID);
indexBTree.acquire(kContext, READ_MODE);
byte[] bRoot = null;
try {
bRoot = (byte[]) indexBTree.lookup(tmpKey, kContext);
} finally {
indexBTree.release(kContext);
}
if (bRoot != null) subRoot = new PageNumber(ByteTool.bytesToInt(bRoot, 0, btreeSpec.isMsbFirst()));
else subRoot = null;
}
if (needLog) {
BTreeSpecLogRecord logRec = new BTreeSpecLogRecord(id, subRoot == null ? -1 : subRoot.getPageNumber(), docRoot.getPageNumber(), BTreeSpecLogRecord.DOC_ROOT_PAGE_NUMBER_FLAG, txnId, docID, IDBIndex.ID2NODE_BTREE);
logRec.log();
}
docRoot.setTreeId(id);
if (subRoot == null) id2root.put(idocID, docRoot);
else subRoot.setPageNumber(docRoot);
//This situation occurs to do commit like operation(such as delete, modify node etc)after getDocument operation
synchronized (cleanIdQueue) {
cleanIdQueue.remove(idocID);
}