public void dropIndex(DocumentImpl doc) throws ReadOnlyException {  short collectionId = doc.getCollection().getId(); Value ref = new ElementValue(collectionId);
public void dropIndex(Collection collection) { LOG.debug("removing elements ..."); Value ref = new ElementValue(collection.getId());
    public void dropIndex(DocumentImpl doc) throws ReadOnlyException {        //	  drop element-index        short collectionId = doc.getCollection().getId();        Value ref = new ElementValue(collectionId);        IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref);        Lock lock = dbElement.getLock();        try {            lock.acquire(Lock.WRITE_LOCK);            ArrayList elements = dbElement.findKeys(query);            if (LOG.isDebugEnabled()) {                LOG.debug("removeDocument() - " + "found " + elements.size()                        + " elements.");            }            Value key;//            Value value;            VariableByteInput is;            VariableByteOutputStream os;            int len;            int docId;//            long delta;//            long address;            boolean changed;            for (int i = 0; i < elements.size(); i++) {                key = (Value) elements.get(i);                is = dbElement.getAsStream(key);                os = new VariableByteOutputStream();                changed = false;                try {                    while (is.available() > 0) {                        docId = is.readInt();                        len = is.readInt();                        if (docId != doc.getDocId()) {                            // copy data to new buffer                            os.writeInt(docId);                            os.writeInt(len);                            is.copyTo(os, len * 4);                        } else {                            changed = true;                            // skip                            is.skip(len * 4);                        }                    }                } catch (EOFException e) {                    // EOF is expected here                } catch (IOException e) {                    LOG.warn("removeDocument(String) " + e.getMessage(), e);                }                if (changed) {                    if (dbElement.put(key, os.data()) < 0)                            if (LOG.isDebugEnabled()) {                                LOG.debug("removeDocument() - "                                        + "could not save element");                            }                }            }        } catch (LockException e) {            LOG.warn("removeDocument(String) - "                    + "could not acquire lock on elements", e);        } catch (TerminatedException e) {            LOG.warn("method terminated", e);        } catch (BTreeException e) {            LOG.warn(e.getMessage(), e);        } catch (IOException e) {            LOG.warn(e.getMessage(), e);        } finally {            lock.release();        }    }