final class BooleanScorer extends BulkScorer
BulkScorer
that is used for pure disjunctions and disjunctions
that have low values of BooleanQuery.Builder.setMinimumNumberShouldMatch(int)
and dense clauses. This scorer scores documents by batches of 2048 docs.Modifier and Type | Class and Description |
---|---|
(package private) static class |
BooleanScorer.Bucket |
private class |
BooleanScorer.BulkScorerAndDoc |
(package private) static class |
BooleanScorer.HeadPriorityQueue |
(package private) class |
BooleanScorer.OrCollector |
(package private) static class |
BooleanScorer.TailPriorityQueue |
Modifier and Type | Field and Description |
---|---|
(package private) BooleanScorer.Bucket[] |
buckets |
(package private) long |
cost |
(package private) BooleanScorer.HeadPriorityQueue |
head |
(package private) BooleanScorer.BulkScorerAndDoc[] |
leads |
(package private) static int |
MASK |
(package private) long[] |
matching |
(package private) int |
minShouldMatch |
(package private) BooleanScorer.OrCollector |
orCollector |
(package private) ScoreAndDoc |
scoreAndDoc |
(package private) static int |
SET_MASK |
(package private) static int |
SET_SIZE |
(package private) static int |
SHIFT |
(package private) static int |
SIZE |
(package private) BooleanScorer.TailPriorityQueue |
tail |
Constructor and Description |
---|
BooleanScorer(BooleanWeight weight,
java.util.Collection<BulkScorer> scorers,
int minShouldMatch,
boolean needsScores) |
Modifier and Type | Method and Description |
---|---|
private BooleanScorer.BulkScorerAndDoc |
advance(int min) |
long |
cost()
Same as
DocIdSetIterator.cost() for bulk scorers. |
private static long |
cost(java.util.Collection<BulkScorer> scorers,
int minShouldMatch) |
int |
score(LeafCollector collector,
Bits acceptDocs,
int min,
int max)
Collects matching documents in a range and return an estimation of the
next matching document which is on or after
max . |
private void |
scoreDocument(LeafCollector collector,
int base,
int i) |
private void |
scoreMatches(LeafCollector collector,
int base) |
private BooleanScorer.BulkScorerAndDoc |
scoreWindow(BooleanScorer.BulkScorerAndDoc top,
LeafCollector collector,
Bits acceptDocs,
int min,
int max) |
private void |
scoreWindowIntoBitSetAndReplay(LeafCollector collector,
Bits acceptDocs,
int base,
int min,
int max,
BooleanScorer.BulkScorerAndDoc[] scorers,
int numScorers) |
private void |
scoreWindowMultipleScorers(LeafCollector collector,
Bits acceptDocs,
int windowBase,
int windowMin,
int windowMax,
int maxFreq) |
private void |
scoreWindowSingleScorer(BooleanScorer.BulkScorerAndDoc bulkScorer,
LeafCollector collector,
Bits acceptDocs,
int windowMin,
int windowMax,
int max) |
score
static final int SHIFT
static final int SIZE
static final int MASK
static final int SET_SIZE
static final int SET_MASK
final BooleanScorer.Bucket[] buckets
final long[] matching
final BooleanScorer.BulkScorerAndDoc[] leads
final BooleanScorer.HeadPriorityQueue head
final BooleanScorer.TailPriorityQueue tail
final ScoreAndDoc scoreAndDoc
final int minShouldMatch
final long cost
final BooleanScorer.OrCollector orCollector
BooleanScorer(BooleanWeight weight, java.util.Collection<BulkScorer> scorers, int minShouldMatch, boolean needsScores)
private static long cost(java.util.Collection<BulkScorer> scorers, int minShouldMatch)
public long cost()
BulkScorer
DocIdSetIterator.cost()
for bulk scorers.cost
in class BulkScorer
private void scoreDocument(LeafCollector collector, int base, int i) throws java.io.IOException
java.io.IOException
private void scoreMatches(LeafCollector collector, int base) throws java.io.IOException
java.io.IOException
private void scoreWindowIntoBitSetAndReplay(LeafCollector collector, Bits acceptDocs, int base, int min, int max, BooleanScorer.BulkScorerAndDoc[] scorers, int numScorers) throws java.io.IOException
java.io.IOException
private BooleanScorer.BulkScorerAndDoc advance(int min) throws java.io.IOException
java.io.IOException
private void scoreWindowMultipleScorers(LeafCollector collector, Bits acceptDocs, int windowBase, int windowMin, int windowMax, int maxFreq) throws java.io.IOException
java.io.IOException
private void scoreWindowSingleScorer(BooleanScorer.BulkScorerAndDoc bulkScorer, LeafCollector collector, Bits acceptDocs, int windowMin, int windowMax, int max) throws java.io.IOException
java.io.IOException
private BooleanScorer.BulkScorerAndDoc scoreWindow(BooleanScorer.BulkScorerAndDoc top, LeafCollector collector, Bits acceptDocs, int min, int max) throws java.io.IOException
java.io.IOException
public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws java.io.IOException
BulkScorer
max
.
The return value must be:
max
,DocIdSetIterator.NO_MORE_DOCS
if there are no more matches,max
otherwise.min
is the minimum document to be considered for matching. All
documents strictly before this value must be ignored.
Although max
would be a legal return value for this method, higher
values might help callers skip more efficiently over non-matching portions
of the docID space.
For instance, a Scorer
-based implementation could look like
below:
private final Scorer scorer; // set via constructor public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException { collector.setScorer(scorer); int doc = scorer.docID(); if (doc < min) { doc = scorer.advance(min); } while (doc < max) { if (acceptDocs == null || acceptDocs.get(doc)) { collector.collect(doc); } doc = scorer.nextDoc(); } return doc; }
score
in class BulkScorer
collector
- The collector to which all matching documents are passed.acceptDocs
- Bits
that represents the allowed documents to match, or
null
if they are all allowed to match.min
- Score starting at, including, this documentmax
- Score up to, but not including, this docjava.io.IOException