final class MinShouldMatchSumScorer extends Scorer
Scorer
for BooleanQuery
when
minShouldMatch
is
between 2 and the total number of clauses.
This implementation keeps sub scorers in 3 different places:
- lead: a linked list of scorer that are positioned on the desired doc ID
- tail: a heap that contains at most minShouldMatch - 1 scorers that are
behind the desired doc ID. These scorers are ordered by cost so that we
can advance the least costly ones first.
- head: a heap that contains scorers which are beyond the desired doc ID,
ordered by doc ID in order to move quickly to the next candidate.
Finding the next match consists of first setting the desired doc ID to the
least entry in 'head' and then advance 'tail' until there is a match.Scorer.ChildScorer
Modifier and Type | Field and Description |
---|---|
(package private) java.util.Collection<Scorer.ChildScorer> |
childScorers |
(package private) float[] |
coord |
(package private) long |
cost |
(package private) int |
doc |
(package private) int |
freq |
(package private) DisiPriorityQueue |
head |
(package private) DisiWrapper |
lead |
(package private) int |
minShouldMatch |
(package private) DisiWrapper[] |
tail |
(package private) int |
tailSize |
Constructor and Description |
---|
MinShouldMatchSumScorer(Weight weight,
java.util.Collection<Scorer> scorers,
int minShouldMatch,
float[] coord) |
Modifier and Type | Method and Description |
---|---|
private void |
addLead(DisiWrapper lead) |
private void |
addTail(DisiWrapper s)
Add an entry to 'tail'.
|
private void |
advanceTail() |
private void |
advanceTail(DisiWrapper top) |
private static long |
cost(java.util.Collection<Scorer> scorers,
int minShouldMatch) |
int |
docID()
Returns the doc ID that is currently being scored.
|
private int |
doNext()
Advance tail to the lead until there is a match.
|
private static void |
downHeapCost(DisiWrapper[] heap,
int size) |
int |
freq()
Returns the freq of this Scorer on the current document
|
java.util.Collection<Scorer.ChildScorer> |
getChildren()
Returns child sub-scorers
|
private DisiWrapper |
insertTailWithOverFlow(DisiWrapper s)
Insert an entry in 'tail' and evict the least-costly scorer if full.
|
DocIdSetIterator |
iterator()
Return a
DocIdSetIterator over matching documents. |
private DisiWrapper |
popTail()
Pop the least-costly scorer from 'tail'.
|
private void |
pushBackLeads() |
float |
score()
Returns the score of the current document matching the query.
|
private void |
setDocAndFreq()
Reinitializes head, freq and doc from 'head'
|
private void |
updateFreq()
Advance all entries from the tail to know about all matches on the
current doc.
|
private static void |
upHeapCost(DisiWrapper[] heap,
int i)
Heap helpers
|
getWeight, twoPhaseIterator
final int minShouldMatch
final float[] coord
DisiWrapper lead
int doc
int freq
final DisiPriorityQueue head
final DisiWrapper[] tail
int tailSize
final java.util.Collection<Scorer.ChildScorer> childScorers
final long cost
private static long cost(java.util.Collection<Scorer> scorers, int minShouldMatch)
public final java.util.Collection<Scorer.ChildScorer> getChildren()
Scorer
getChildren
in class Scorer
public DocIdSetIterator iterator()
Scorer
DocIdSetIterator
over matching documents.
The returned iterator will either be positioned on -1
if no
documents have been scored yet, DocIdSetIterator.NO_MORE_DOCS
if all documents have been scored already, or the last document id that
has been scored otherwise.
The returned iterator is a view: calling this method several times will
return iterators that have the same state.private void addLead(DisiWrapper lead)
private void pushBackLeads() throws java.io.IOException
java.io.IOException
private void advanceTail(DisiWrapper top) throws java.io.IOException
java.io.IOException
private void advanceTail() throws java.io.IOException
java.io.IOException
private void setDocAndFreq()
private int doNext() throws java.io.IOException
java.io.IOException
private void updateFreq() throws java.io.IOException
java.io.IOException
public int freq() throws java.io.IOException
Scorer
public float score() throws java.io.IOException
Scorer
DocIdSetIterator.nextDoc()
or
DocIdSetIterator.advance(int)
is called on the Scorer.iterator()
the first time, or when called from within LeafCollector.collect(int)
.public int docID()
Scorer
-1
if the Scorer.iterator()
is not positioned
or DocIdSetIterator.NO_MORE_DOCS
if it has been entirely consumed.docID
in class Scorer
DocIdSetIterator.docID()
private DisiWrapper insertTailWithOverFlow(DisiWrapper s)
private void addTail(DisiWrapper s)
private DisiWrapper popTail()
private static void upHeapCost(DisiWrapper[] heap, int i)
private static void downHeapCost(DisiWrapper[] heap, int size)