try { LOG.debug("Writing " + ((AtomicValue)indexable).getStringValue() + ": " + idList.size()); } catch (XPathException e1) {  e1.printStackTrace(); }
    public void flush() {        if (pending.size() == 0) return;        NodeProxy proxy;        Indexable indexable;        ArrayList idList;        int len;        Value ref;        Map.Entry entry;        // get collection id for this collection        long prevId;        long cid;        short collectionId = doc.getCollection().getId();        Lock lock = db.getLock();        try {            for (Iterator i = pending.entrySet().iterator(); i.hasNext();) {                entry = (Map.Entry) i.next();                indexable = (Indexable) entry.getKey();                idList = (ArrayList) entry.getValue();                try {                    LOG.debug("Writing " + ((AtomicValue)indexable).getStringValue() + ": " + idList.size());                } catch (XPathException e1) {                    // TODO Auto-generated catch block                    e1.printStackTrace();                }                os.clear();                FastQSort.sort(idList, 0, idList.size() - 1);                len = idList.size();                os.writeInt(doc.getDocId());                os.writeInt(len);                prevId = 0;                for (int j = 0; j < len; j++) {                    proxy = (NodeProxy) idList.get(j);                    cid = proxy.gid - prevId;                    prevId = proxy.gid;                    os.writeLong(cid);                }                ref = new Value(indexable.serialize(collectionId));                try {                    lock.acquire(Lock.WRITE_LOCK);                    if (db.append(ref, os.data()) < 0) {                        LOG.warn("could not save index for value");                        continue;                    }                } catch (LockException e) {                    LOG.error("could not acquire lock on values.dbx", e);                } catch (IOException e) {                    LOG.error("io error while writing value index.", e);                } finally {                    lock.release();                }            }        } catch (ReadOnlyException e) {            LOG.warn("database is read-only");            return;        }        pending.clear();    }