public void dropIndex(DocumentImpl document) throws ReadOnlyException { final short collectionId = document.getCollection().getId(); final Value ref = new ElementValue(collectionId);
public void dropIndex(Collection collection) { final Value ref = new ElementValue(collection.getId());
    public void dropIndex(DocumentImpl document) throws ReadOnlyException {            final short collectionId = document.getCollection().getId();        final Value ref = new ElementValue(collectionId);        final IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref);        final Lock lock = dbValues.getLock();        try {            lock.acquire(Lock.WRITE_LOCK);            ArrayList elements = dbValues.findKeys(query);            for (int i = 0; i < elements.size(); i++) {                boolean changed = false;                Value key = (Value) elements.get(i);                Value value = dbValues.get(key);                                VariableByteArrayInput is = new VariableByteArrayInput(value.getData());                os.clear();                                while (is.available() > 0) {                    int storedDocId = is.readInt();                    int gidsCount = is.readInt();                        					if (storedDocId != document.getDocId()) {					    // data are related to another document:                        // copy them to any existing data                        os.writeInt(storedDocId);                        os.writeInt(gidsCount);                        NodeId nodeId;                        for (int j = 0; j < gidsCount; j++) {                            nodeId = broker.getBrokerPool().getNodeFactory().createFromStream(is);                            nodeId.write(os);                        }                    } else {                        // data are related to our document:                        // skip them                                                  is.skip(gidsCount);                        changed = true;                    }                }                //Store new data, if relevant                if (changed) {                    if (os.data().size() == 0) {                        //Well, nothing to store : remove the existing data                        dbValues.remove(key);                    } else {                                              if (dbValues.put(key, os.data()) == BFile.UNKNOWN_ADDRESS) {                            LOG.error("Could not put index data for value '" +  ref + "'");                        }                    }                }            }                    } catch (LockException e) {            LOG.warn("Failed to acquire lock for '" + dbValues.getFile().getName() + "'", e);               } catch (TerminatedException e) {            LOG.warn(e.getMessage(), e);                    } catch (BTreeException e) {            LOG.error(e.getMessage(), e);        } catch (IOException e) {            LOG.error(e.getMessage(), e);            } finally {            lock.release();        }    }