Package org.apache.lucene.search
Class AcceptDocs
java.lang.Object
org.apache.lucene.search.AcceptDocs
Higher-level abstraction for document acceptance filtering. Can be consumed in either
random-access (Bits) or sequential (DocIdSetIterator) pattern.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Bitsbits()Random access to the accepted documents.abstract intcost()Return an approximation of the number of accepted documents.static AcceptDocsfromIteratorSupplier(IOSupplier<DocIdSetIterator> iteratorSupplier, Bits liveDocs, int maxDoc) Create AcceptDocs from anIOSupplierofDocIdSetIterator, optionally filtered by live documents.static AcceptDocsfromLiveDocs(Bits bits, int maxDoc) Create AcceptDocs from aBitsinstance representing live documents.abstract DocIdSetIteratoriterator()Create a new iterator of accepted docs.
-
Constructor Details
-
AcceptDocs
public AcceptDocs()
-
-
Method Details
-
bits
Random access to the accepted documents.- Returns:
- Bits instance for random access, or null if all documents are accepted
- Throws:
IOException- if an I/O error occurs
-
iterator
Create a new iterator of accepted docs. There accepted docs already ignore deleted docs.NOTE: If you also plan on calling
bits()orcost(), it is recommended to call these methods beforeiterator()for better performance.- Returns:
- DocIdSetIterator for sequential access
- Throws:
IOException- if an I/O error occurs
-
cost
Return an approximation of the number of accepted documents. This is typically useful to decide whether to consume these accept docs using random access (bits()) or sequential access (iterator()).NOTE: This must not be called after
iterator().- Returns:
- approximate cost
- Throws:
IOException
-
fromLiveDocs
Create AcceptDocs from aBitsinstance representing live documents. Anullinstance is interpreted as matching all documents, like inLeafReader.getLiveDocs().- Parameters:
bits- the Bits instance for random accessmaxDoc- the number of documents in the reader- Returns:
- AcceptDocs wrapping the Bits
-
fromIteratorSupplier
public static AcceptDocs fromIteratorSupplier(IOSupplier<DocIdSetIterator> iteratorSupplier, Bits liveDocs, int maxDoc) Create AcceptDocs from anIOSupplierofDocIdSetIterator, optionally filtered by live documents.- Parameters:
iteratorSupplier- a DocIdSetIterator iteratorliveDocs- Bits representing live documents, ornullif no deleted docs.maxDoc- the number of documents in the reader- Returns:
- AcceptDocs wrapping the iterator
-