os.clear();
    public void flush() {        //TODO : return if doc == null? -pb        if (pending.size() == 0)             return;        final ProgressIndicator progress = new ProgressIndicator(pending.size(), 5);         final short collectionId = this.doc.getCollection().getId();         final Lock lock = dbNodes.getLock();           int count = 0;        for (Iterator i = pending.entrySet().iterator(); i.hasNext(); count++) {            Map.Entry entry = (Map.Entry) i.next();            QName qname = (QName) entry.getKey();            //TODO : NativeValueIndex uses LongLinkedLists -pb            ArrayList gids = (ArrayList) entry.getValue();                        int gidsCount = gids.size();            //Don't forget this one            FastQSort.sort(gids, 0, gidsCount - 1);            os.clear();            os.writeInt(this.doc.getDocId());            os.writeByte(inUpdateMode ? ENTRIES_UNORDERED : ENTRIES_ORDERED);                        os.writeInt(gidsCount);            //TOUNDERSTAND -pb            int lenOffset = os.position();            os.writeFixedInt(0);              //Compute the GIDs list            for (int j = 0; j < gidsCount; j++) {                NodeProxy storedNode = (NodeProxy) gids.get(j);                if (doc.getDocId() != storedNode.getDocument().getDocId()) {                    throw new IllegalArgumentException("Document id ('" + doc.getDocId() + "') and proxy id ('" +                             storedNode.getDocument().getDocId() + "') differ !");                }                try {                    storedNode.getNodeId().write(os);                } catch (IOException e) {                    LOG.warn("IO error while writing structural index: " + e.getMessage(), e);                }                StorageAddress.write(storedNode.getInternalAddress(), os);            }            broker.getBrokerPool().getNodeFactory().writeEndOfDocument(os);            os.writeFixedInt(lenOffset, os.position() - lenOffset - 4);            try {                lock.acquire(Lock.WRITE_LOCK);                //Store the data                final Value key = computeKey(collectionId, qname);                if (dbNodes.append(key, os.data()) == BFile.UNKNOWN_ADDRESS) {                    LOG.error("Could not put index data for node '" +  qname + "'");                 }            } catch (LockException e) {                LOG.warn("Failed to acquire lock for '" + dbNodes.getFile().getName() + "'", e);                //TODO : return ?            } catch (IOException e) {                LOG.error(e.getMessage(), e);                   //TODO : return ?            } catch (ReadOnlyException e) {                LOG.warn("Read-only error on '" + dbNodes.getFile().getName() + "'", e);                //Return without clearing the pending entries                return;                             } finally {                lock.release();            }            progress.setValue(count);            if (progress.changed()) {                setChanged();                notifyObservers(progress);            }                    }                progress.finish();        setChanged();        notifyObservers(progress);        pending.clear();        inUpdateMode = false;    }    