Package org.apache.lucene.search
Class FilteredDocIdSet
- java.lang.Object
-
- org.apache.lucene.search.DocIdSet
-
- org.apache.lucene.search.FilteredDocIdSet
-
- Direct Known Subclasses:
BitsFilteredDocIdSet
public abstract class FilteredDocIdSet extends DocIdSet
Abstract decorator class for a DocIdSet implementation that provides on-demand filtering/validation mechanism on a given DocIdSet. Technically, this same functionality could be achieved with ChainedFilter (under queries/), however the benefit of this class is it never materializes the full bitset for the filter. Instead, thematch(int)method is invoked on-demand, per docID visited during searching. If you know few docIDs will be visited, and the logic behindmatch(int)is relatively costly, this may be a better way to filter than ChainedFilter.- See Also:
DocIdSet
-
-
Constructor Summary
Constructors Constructor Description FilteredDocIdSet(DocIdSet innerSet)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Bitsbits()Optionally provides aBitsinterface for random access to matching documents.booleanisCacheable()This DocIdSet implementation is cacheable if the inner set is cacheable.DocIdSetIteratoriterator()Implementation of the contract to build a DocIdSetIterator.
-
-
-
Constructor Detail
-
FilteredDocIdSet
public FilteredDocIdSet(DocIdSet innerSet)
Constructor.- Parameters:
innerSet- Underlying DocIdSet
-
-
Method Detail
-
isCacheable
public boolean isCacheable()
This DocIdSet implementation is cacheable if the inner set is cacheable.- Overrides:
isCacheablein classDocIdSet
-
bits
public Bits bits() throws java.io.IOException
Description copied from class:DocIdSetOptionally provides aBitsinterface for random access to matching documents.- Overrides:
bitsin classDocIdSet- Returns:
null, if thisDocIdSetdoes not support random access. In contrast toDocIdSet.iterator(), a return value ofnulldoes not imply that no documents match the filter! The default implementation does not provide random access, so you only need to implement this method if your DocIdSet can guarantee random access to every docid in O(1) time without external disk access (asBitsinterface cannot throwIOException). This is generally true for bit sets likeFixedBitSet, which return itself if they are used asDocIdSet.- Throws:
java.io.IOException
-
iterator
public DocIdSetIterator iterator() throws java.io.IOException
Implementation of the contract to build a DocIdSetIterator.- Specified by:
iteratorin classDocIdSet- Throws:
java.io.IOException- See Also:
DocIdSetIterator,FilteredDocIdSetIterator
-
-