if (!containsNode(idList, gid)) {
	public void reindex(DocumentImpl oldDoc, NodeImpl node) {		if (elementIds.size() == 0)			return;		Lock lock = dbElement.getLock();		Map.Entry entry;		String elementName;		List oldList = new ArrayList(), idList;		NodeProxy p;		VariableByteOutputStream os = new VariableByteOutputStream();		VariableByteInputStream is = new VariableByteInputStream();		InputStream dis = null;		int len, docId;		byte[] data;		Value ref;		Value val;		short sym;		short collectionId = oldDoc.getCollection().getId();		long delta, last, gid, address;		try {			// iterate through elements			for (Iterator i = elementIds.entrySet().iterator(); i.hasNext();) {				entry = (Map.Entry) i.next();				idList = (ArrayList) entry.getValue();				elementName = (String) entry.getKey();				sym = NativeBroker.getSymbols().getSymbol(elementName);				ref = new NativeBroker.ElementValue(collectionId, sym);				// try to retrieve old index entry for the element				try {					lock.acquire(Lock.READ_LOCK);					//val = dbElement.get(ref);					dis = dbElement.getAsStream(ref);				} catch (LockException e) {					LOG.error("could not acquire lock for index on " + elementName);					return;				} finally {					lock.release();				}				os.clear();				oldList.clear();				if (dis != null) {					// add old entries to the new list 					//data = val.getData();					is.setInputStream(dis);					try {						while (is.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 * 4);							} else {								// copy nodes to new list								last = 0;								for (int j = 0; j < len; j++) {									delta = is.readLong();									gid = last + delta;									last = gid;									address = StorageAddress.read(is);									if (node == null										&& oldDoc.getTreeLevel(gid) < oldDoc.reindexRequired()) {										idList.add(new NodeProxy(oldDoc, gid, address));									} else if (										node != null											&& (!XMLUtil												.isDescendantOrSelf(oldDoc, node.getGID(), gid))) {										if (!containsNode(idList, gid)) {											oldList.add(new NodeProxy(oldDoc, gid, address));										}									}								}							}						}					} catch (EOFException e) {					} catch (IOException e) {						LOG.error("io-error while updating index for element " + elementName);					}				}				if (node != null)					idList.addAll(oldList);				// write out the updated list				FastQSort.sort(idList, 0, idList.size() - 1);				len = idList.size();				os.writeInt(doc.getDocId());				os.writeInt(len);				last = 0;				for (int j = 0; j < len; j++) {					p = (NodeProxy) idList.get(j);					delta = p.gid - last;					last = p.gid;					os.writeLong(delta);					StorageAddress.write(p.internalAddress, os);				}				data = os.toByteArray();				try {					lock.acquire(Lock.WRITE_LOCK);					if (dis == null)						dbElement.put(ref, data);					else {						address = ((BFile.PageInputStream)dis).getAddress();						dbElement.update(address, ref, data);						//dbElement.update(val.getAddress(), ref, data);					}				} catch (LockException e) {					LOG.error("could not acquire lock on elements", e);				} finally {					lock.release();				}			}		} catch (ReadOnlyException e) {			LOG.warn("database is read only");		}		elementIds.clear();	}