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
AMatchesIterator
that 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 class
DisjunctionMatchesIterator.TermsEnumDisjunctionMatchesIterator
-
Field Summary
Fields Modifier and Type Field Description private PriorityQueue<MatchesIterator>
queue
private boolean
started
-
Constructor Summary
Constructors Modifier Constructor Description private
DisjunctionMatchesIterator(java.util.List<MatchesIterator> matches)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static BytesRefIterator
asBytesRefIterator(java.util.List<Term> terms)
int
endOffset()
The ending offset of the current match, or-1
if offsets are not available Should only be called afterMatchesIterator.next()
has returnedtrue
int
endPosition()
The end position of the current match Should only be called afterMatchesIterator.next()
has returnedtrue
(package private) static MatchesIterator
fromSubIterators(java.util.List<MatchesIterator> mis)
(package private) static MatchesIterator
fromTerms(LeafReaderContext context, int doc, Query query, java.lang.String field, java.util.List<Term> terms)
Create aDisjunctionMatchesIterator
over a list of terms Only terms that have at least one match in the given document will be included(package private) static MatchesIterator
fromTermsEnum(LeafReaderContext context, int doc, Query query, java.lang.String field, BytesRefIterator terms)
Create aDisjunctionMatchesIterator
over a list of terms extracted from aBytesRefIterator
Only terms that have at least one match in the given document will be includedQuery
getQuery()
Returns the Query causing the current match If thisMatchesIterator
has been returned from aMatchesIterator.getSubMatches()
call, then returns aTermQuery
equivalent to the current match Should only be called afterMatchesIterator.next()
has returnedtrue
MatchesIterator
getSubMatches()
Returns a MatchesIterator that iterates over the positions and offsets of individual terms within the current match Returnsnull
if there are no submatches (ie the current iterator is at the leaf level) Should only be called afterMatchesIterator.next()
has returnedtrue
boolean
next()
Advance the iterator to the next match positionint
startOffset()
The starting offset of the current match, or-1
if offsets are not available Should only be called afterMatchesIterator.next()
has returnedtrue
int
startPosition()
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 aDisjunctionMatchesIterator
over 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 aDisjunctionMatchesIterator
over a list of terms extracted from aBytesRefIterator
Only 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.IOException
Description copied from interface:MatchesIterator
Advance the iterator to the next match position- Specified by:
next
in interfaceMatchesIterator
- Returns:
true
if matches have not been exhausted- Throws:
java.io.IOException
-
startPosition
public int startPosition()
Description copied from interface:MatchesIterator
The start position of the current match Should only be called afterMatchesIterator.next()
has returnedtrue
- Specified by:
startPosition
in interfaceMatchesIterator
-
endPosition
public int endPosition()
Description copied from interface:MatchesIterator
The end position of the current match Should only be called afterMatchesIterator.next()
has returnedtrue
- Specified by:
endPosition
in interfaceMatchesIterator
-
startOffset
public int startOffset() throws java.io.IOException
Description copied from interface:MatchesIterator
The starting offset of the current match, or-1
if offsets are not available Should only be called afterMatchesIterator.next()
has returnedtrue
- Specified by:
startOffset
in interfaceMatchesIterator
- Throws:
java.io.IOException
-
endOffset
public int endOffset() throws java.io.IOException
Description copied from interface:MatchesIterator
The ending offset of the current match, or-1
if offsets are not available Should only be called afterMatchesIterator.next()
has returnedtrue
- Specified by:
endOffset
in interfaceMatchesIterator
- Throws:
java.io.IOException
-
getSubMatches
public MatchesIterator getSubMatches() throws java.io.IOException
Description copied from interface:MatchesIterator
Returns a MatchesIterator that iterates over the positions and offsets of individual terms within the current match Returnsnull
if there are no submatches (ie the current iterator is at the leaf level) Should only be called afterMatchesIterator.next()
has returnedtrue
- Specified by:
getSubMatches
in interfaceMatchesIterator
- Throws:
java.io.IOException
-
getQuery
public Query getQuery()
Description copied from interface:MatchesIterator
Returns the Query causing the current match If thisMatchesIterator
has been returned from aMatchesIterator.getSubMatches()
call, then returns aTermQuery
equivalent to the current match Should only be called afterMatchesIterator.next()
has returnedtrue
- Specified by:
getQuery
in interfaceMatchesIterator
-
-