/** * Return the {@link DocIdSet} representing the documents of the * virtual collection to be used in searches. * This will respect deleted documents. * * @param atomic * The {@link LeafReaderContext} to search in. * @param accepted * {@link Bits} vector of accepted documents. * @throws IOException */ public DocIdSet getDocIdSet (LeafReaderContext atomic, Bits acceptDocs) throws IOException { int maxDoc = atomic.reader().maxDoc(); FixedBitSet bitset = new FixedBitSet(maxDoc); Filter filter; if (this.cbi == null || (filter = this.cbi.toFilter()) == null) { if (acceptDocs == null) return null; bitset.set(0, maxDoc); } else { // Init vector DocIdSet docids = filter.getDocIdSet(atomic, null); DocIdSetIterator filterIter = (docids == null) ? null : docids.iterator(); if (filterIter == null) { if (!this.cbi.isNegative()) return null; bitset.set(0, maxDoc); } else { // Or bit set bitset.or(filterIter); // Revert for negation if (this.cbi.isNegative()) bitset.flip(0, maxDoc); }; }; if (DEBUG) { log.debug("Bit set is {}", _bits(bitset)); log.debug("Livedocs is {}", _bits(acceptDocs)); }; // Remove deleted docs return (DocIdSet) BitsFilteredDocIdSet .wrap((DocIdSet) new BitDocIdSet(bitset), acceptDocs); }