Package org.apache.lucene.search
Class FilteredDocIdSet
- java.lang.Object
-
- org.apache.lucene.search.DocIdSet
-
- org.apache.lucene.search.FilteredDocIdSet
-
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 contrib/misc), 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
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.search.DocIdSet
EMPTY_DOCIDSET
-
-
Constructor Summary
Constructors Constructor Description FilteredDocIdSet(DocIdSet innerSet)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanisCacheable()This DocIdSet implementation is cacheable if the inner set is cacheable.DocIdSetIteratoriterator()Implementation of the contract to build a DocIdSetIterator.protected abstract booleanmatch(int docid)Validation method to determine whether a docid should be in the result set.
-
-
-
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
-
match
protected abstract boolean match(int docid) throws IOExceptionValidation method to determine whether a docid should be in the result set.- Parameters:
docid- docid to be tested- Returns:
- true if input docid should be in the result set, false otherwise.
- Throws:
IOException
-
iterator
public DocIdSetIterator iterator() throws IOException
Implementation of the contract to build a DocIdSetIterator.- Specified by:
iteratorin classDocIdSet- Throws:
IOException- See Also:
DocIdSetIterator,FilteredDocIdSetIterator
-
-