final IndexQuery query = new IndexQuery(IndexQuery.RANGE, new Value(fromKey), new Value(toKey));
final Lock lock = index.btree.getLock();
try {
lock.acquire(Lock.READ_LOCK);
index.btree.query(query, new BTreeCallback() {
public boolean indexInfo(Value value, long pointer) throws TerminatedException {
Occurrences oc = occurrences.get(name);
if (oc == null) {
oc = new Occurrences(name);
occurrences.put(name, oc);