Package org.apache.lucene.search
Class DisjunctionMatchesIterator
- java.lang.Object
-
- org.apache.lucene.search.DisjunctionMatchesIterator
-
- All Implemented Interfaces:
MatchesIterator
final class DisjunctionMatchesIterator extends java.lang.Object implements MatchesIterator
AMatchesIteratorthat combines matches from a set of sub-iterators Matches are sorted by their start positions, and then by their end positions, so that prefixes sort first. Matches may overlap, or be duplicated if they appear in more than one of the sub-iterators.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classDisjunctionMatchesIterator.TermsEnumDisjunctionMatchesIterator
-
Field Summary
Fields Modifier and Type Field Description private PriorityQueue<MatchesIterator>queueprivate booleanstarted
-
Constructor Summary
Constructors Modifier Constructor Description privateDisjunctionMatchesIterator(java.util.List<MatchesIterator> matches)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static BytesRefIteratorasBytesRefIterator(java.util.List<Term> terms)intendOffset()The ending offset of the current match, or-1if offsets are not available Should only be called afterMatchesIterator.next()has returnedtrueintendPosition()The end position of the current match Should only be called afterMatchesIterator.next()has returnedtrue(package private) static MatchesIteratorfromSubIterators(java.util.List<MatchesIterator> mis)(package private) static MatchesIteratorfromTerms(LeafReaderContext context, int doc, Query query, java.lang.String field, java.util.List<Term> terms)Create aDisjunctionMatchesIteratorover a list of terms Only terms that have at least one match in the given document will be included(package private) static MatchesIteratorfromTermsEnum(LeafReaderContext context, int doc, Query query, java.lang.String field, BytesRefIterator terms)Create aDisjunctionMatchesIteratorover a list of terms extracted from aBytesRefIteratorOnly terms that have at least one match in the given document will be includedQuerygetQuery()Returns the Query causing the current match If thisMatchesIteratorhas been returned from aMatchesIterator.getSubMatches()call, then returns aTermQueryequivalent to the current match Should only be called afterMatchesIterator.next()has returnedtrueMatchesIteratorgetSubMatches()Returns a MatchesIterator that iterates over the positions and offsets of individual terms within the current match Returnsnullif there are no submatches (ie the current iterator is at the leaf level) Should only be called afterMatchesIterator.next()has returnedtruebooleannext()Advance the iterator to the next match positionintstartOffset()The starting offset of the current match, or-1if offsets are not available Should only be called afterMatchesIterator.next()has returnedtrueintstartPosition()The start position of the current match Should only be called afterMatchesIterator.next()has returnedtrue
-
-
-
Field Detail
-
queue
private final PriorityQueue<MatchesIterator> queue
-
started
private boolean started
-
-
Constructor Detail
-
DisjunctionMatchesIterator
private DisjunctionMatchesIterator(java.util.List<MatchesIterator> matches) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
fromTerms
static MatchesIterator fromTerms(LeafReaderContext context, int doc, Query query, java.lang.String field, java.util.List<Term> terms) throws java.io.IOException
Create aDisjunctionMatchesIteratorover a list of terms Only terms that have at least one match in the given document will be included- Throws:
java.io.IOException
-
asBytesRefIterator
private static BytesRefIterator asBytesRefIterator(java.util.List<Term> terms)
-
fromTermsEnum
static MatchesIterator fromTermsEnum(LeafReaderContext context, int doc, Query query, java.lang.String field, BytesRefIterator terms) throws java.io.IOException
Create aDisjunctionMatchesIteratorover a list of terms extracted from aBytesRefIteratorOnly terms that have at least one match in the given document will be included- Throws:
java.io.IOException
-
fromSubIterators
static MatchesIterator fromSubIterators(java.util.List<MatchesIterator> mis) throws java.io.IOException
- Throws:
java.io.IOException
-
next
public boolean next() throws java.io.IOExceptionDescription copied from interface:MatchesIteratorAdvance the iterator to the next match position- Specified by:
nextin interfaceMatchesIterator- Returns:
trueif matches have not been exhausted- Throws:
java.io.IOException
-
startPosition
public int startPosition()
Description copied from interface:MatchesIteratorThe start position of the current match Should only be called afterMatchesIterator.next()has returnedtrue- Specified by:
startPositionin interfaceMatchesIterator
-
endPosition
public int endPosition()
Description copied from interface:MatchesIteratorThe end position of the current match Should only be called afterMatchesIterator.next()has returnedtrue- Specified by:
endPositionin interfaceMatchesIterator
-
startOffset
public int startOffset() throws java.io.IOExceptionDescription copied from interface:MatchesIteratorThe starting offset of the current match, or-1if offsets are not available Should only be called afterMatchesIterator.next()has returnedtrue- Specified by:
startOffsetin interfaceMatchesIterator- Throws:
java.io.IOException
-
endOffset
public int endOffset() throws java.io.IOExceptionDescription copied from interface:MatchesIteratorThe ending offset of the current match, or-1if offsets are not available Should only be called afterMatchesIterator.next()has returnedtrue- Specified by:
endOffsetin interfaceMatchesIterator- Throws:
java.io.IOException
-
getSubMatches
public MatchesIterator getSubMatches() throws java.io.IOException
Description copied from interface:MatchesIteratorReturns a MatchesIterator that iterates over the positions and offsets of individual terms within the current match Returnsnullif there are no submatches (ie the current iterator is at the leaf level) Should only be called afterMatchesIterator.next()has returnedtrue- Specified by:
getSubMatchesin interfaceMatchesIterator- Throws:
java.io.IOException
-
getQuery
public Query getQuery()
Description copied from interface:MatchesIteratorReturns the Query causing the current match If thisMatchesIteratorhas been returned from aMatchesIterator.getSubMatches()call, then returns aTermQueryequivalent to the current match Should only be called afterMatchesIterator.next()has returnedtrue- Specified by:
getQueryin interfaceMatchesIterator
-
-