return (Occurrences[]) cb.map.values().toArray(result);
}
public Occurrences[] scanIndexTerms(DocumentSet docs, NodeSet contextSet,
QName[] qnames, String start, String end) throws PermissionDeniedException {
final Lock lock = dbTokens.getLock();
final IndexScanCallback cb = new IndexScanCallback(docs, contextSet, true);
for (int q = 0; q < qnames.length; q++) {
for (final Iterator<Collection> i = docs.getCollectionIterator(); i.hasNext();) {
final int collectionId = (i.next()).getId();
final IndexQuery query;
if (start == null) {
final Value startRef = new QNameWordRef(collectionId, qnames[q],
broker.getBrokerPool().getSymbols());
query = new IndexQuery(IndexQuery.TRUNC_RIGHT, startRef);
} else if (end == null) {
final Value startRef = new QNameWordRef(collectionId, qnames[q],
start.toLowerCase(), broker.getBrokerPool().getSymbols());
query = new IndexQuery(IndexQuery.TRUNC_RIGHT, startRef);
} else {
final Value startRef = new QNameWordRef(collectionId, qnames[q], start.toLowerCase(),
broker.getBrokerPool().getSymbols());
final Value endRef = new QNameWordRef(collectionId, qnames[q], end.toLowerCase(),
broker.getBrokerPool().getSymbols());
query = new IndexQuery(IndexQuery.BW, startRef, endRef);
}
try {
lock.acquire(Lock.READ_LOCK);
dbTokens.query(query, cb);
} catch (final LockException e) {
LOG.warn("Failed to acquire lock for '" + dbTokens.getFile().getName() + "'", e);
//TODO : throw exception ? -pb
} catch (final IOException e) {
LOG.error(e.getMessage(), e);
//TODO : throw exception ? -pb
} catch (final BTreeException e) {
LOG.error(e.getMessage(), e);
//TODO : throw exception ? -pb
} catch (final TerminatedException e) {
LOG.warn(e.getMessage(), e);
//TODO : throw exception ? -pb
} finally {
lock.release(Lock.READ_LOCK);
}
}
}
final Occurrences[] result = new Occurrences[cb.map.size()];
return (Occurrences[]) cb.map.values().toArray(result);