data = os.toByteArray();
		public void reindex(DocumentImpl oldDoc, NodeImpl node) {			final short collectionId = doc.getCollection().getId();			int len, docId;			Map.Entry entry;			String word;			LongLinkedList idList;			long[] ids;			byte[] data;			long last, gid;			long delta;			NodeProxy p;			WordRef ref;			VariableByteInputStream is = new VariableByteInputStream();			VariableByteOutputStream os = new VariableByteOutputStream();			InputStream dis = null;			Lock lock = dbWords.getLock();			for (Iterator i = words.entrySet().iterator(); i.hasNext();) {				entry = (Map.Entry) i.next();				word = (String) entry.getKey();				idList = (LongLinkedList) entry.getValue();				ref = new WordRef(collectionId, word);				try {					lock.acquire(Lock.READ_LOCK);					dis = dbWords.getAsStream(ref);				} catch (LockException e) {					LOG.error("could not acquire lock on index for '" + word + "'");				} finally {					lock.release();				}				os.clear();				if (dis != null) {					// add old entries to the new list 					is.setInputStream(dis);					try {						while (dis.available() > 0) {							docId = is.readInt();							len = is.readInt();							if (docId != oldDoc.getDocId()) {								// section belongs to another document:								// copy data to new buffer								os.writeInt(docId);								os.writeInt(len);								is.copyTo(os, len);							} else {								// copy nodes to new list								gid = 0;								for (int j = 0; j < len; j++) {									delta = is.readLong();									gid += delta;									if (node == null										&& oldDoc.getTreeLevel(gid) < oldDoc.reindexRequired()) {										idList.add(gid);									} else if (										node != null											&& (!XMLUtil												.isDescendantOrSelf(oldDoc, node.getGID(), gid))) {										idList.add(gid);									}								}							}						}					} catch (EOFException e) {						//LOG.error("end-of-file while reading index entry for " + word, e);					} catch (IOException e) {						LOG.error("io-error while reading index entry for " + word, e);					}				}				ids = idList.getData();				i.remove();				Arrays.sort(ids);				len = ids.length;				os.writeInt(oldDoc.getDocId());				os.writeInt(len);				last = 0;				for (int j = 0; j < len; j++) {					delta = ids[j] - last;					if (delta < 0) {						LOG.debug("neg. delta: " + delta + " for " + word);						LOG.debug("id = " + ids[j] + "; prev = " + last);					}					os.writeLong(delta);					last = ids[j];				}				data = os.toByteArray();				try {					lock.acquire(Lock.WRITE_LOCK);					try {						if (dis == null)							dbWords.put(ref, data);						else {							dbWords.update(((BFile.PageInputStream)dis).getAddress(), ref, data);						}					} catch (ReadOnlyException e) {					}				} catch (LockException e) {					LOG.warn("could not acquire lock", e);				} finally {					lock.release();				}			}			words.clear();		}