if (node == null) LOG.debug("reindexing level " + idxLevel + " of document " + doc.getDocId());
	public void reindex(DocumentImpl oldDoc, DocumentImpl doc, NodeImpl node) {		int idxLevel = doc.reindexRequired();		if (idxLevel < 0) {			flush();			return;		}		oldDoc.setReindexRequired(idxLevel);//		if (node == null)//			LOG.debug("reindexing level " + idxLevel + " of document " + doc.getDocId());		final long start = System.currentTimeMillis();		// remove all old index keys from the btree		Value ref = new NodeRef(doc.getDocId());		final IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref);		final Lock lock = domDb.getLock();		// try to acquire a lock on the file		try {			lock.acquire(Lock.WRITE_LOCK);			domDb.setOwnerObject(this);			final ArrayList nodes = domDb.findKeys(query);			long gid;			for (Iterator i = nodes.iterator(); i.hasNext();) {				ref = (Value) i.next();				gid = ByteConversion.byteToLong(ref.data(), ref.start() + 4);				if (oldDoc.getTreeLevel(gid) >= doc.reindexRequired()) {					if (node != null) {						if (XMLUtil.isDescendant(oldDoc, node.getGID(), gid)) {							domDb.removeValue(ref);						}					} else						domDb.removeValue(ref);				}			}		} catch (DBException e) {			LOG.warn("db error during reindex", e);		} catch (IOException e) {			LOG.warn("io error during reindex", e);		} catch (LockException e) {			// timed out			LOG.warn("lock timed out during reindex", e);			return;		} finally {			lock.release();		}		// now reindex the nodes		Iterator iterator;		if (node == null) {			NodeList nodes = doc.getChildNodes();			NodeImpl n;			for (int i = 0; i < nodes.getLength(); i++) {				n = (NodeImpl) nodes.item(i);				iterator =					getNodeIterator(						new NodeProxy(doc, n.getGID(), n.getInternalAddress()));				iterator.next();				scanNodes(iterator, n, new NodePath());			}		} else {			iterator =				getNodeIterator(					new NodeProxy(doc, node.getGID(), node.getInternalAddress()));			iterator.next();			scanNodes(iterator, node, node.getPath());		}		elementIndex.reindex(oldDoc, node);		textEngine.reindex(oldDoc, node);		doc.setReindexRequired(-1);		LOG.debug("reindex took " + (System.currentTimeMillis() - start) + "ms.");	}