- java.lang.Object
-
- org.apache.lucene.search.BulkScorer
-
- org.apache.lucene.search.BooleanScorer
-
final class BooleanScorer extends BulkScorer
BulkScorer
that is used for pure disjunctions and disjunctions that have low values ofBooleanQuery.Builder.setMinimumNumberShouldMatch(int)
and dense clauses. This scorer scores documents by batches of 2048 docs.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
BooleanScorer.Bucket
private class
BooleanScorer.BulkScorerAndDoc
(package private) class
BooleanScorer.DocIdStreamView
(package private) static class
BooleanScorer.HeadPriorityQueue
(package private) class
BooleanScorer.OrCollector
(package private) static class
BooleanScorer.TailPriorityQueue
-
Field Summary
Fields Modifier and Type Field Description (package private) BooleanScorer.Bucket[]
buckets
(package private) long
cost
private BooleanScorer.DocIdStreamView
docIdStreamView
(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) boolean
needsScores
(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 Summary
Constructors Constructor Description BooleanScorer(BooleanWeight weight, java.util.Collection<BulkScorer> scorers, int minShouldMatch, boolean needsScores)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private BooleanScorer.BulkScorerAndDoc
advance(int min)
long
cost()
Same asDocIdSetIterator.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 aftermax
.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)
-
Methods inherited from class org.apache.lucene.search.BulkScorer
score
-
-
-
-
Field Detail
-
SHIFT
static final int SHIFT
- See Also:
- Constant Field Values
-
SIZE
static final int SIZE
- See Also:
- Constant Field Values
-
MASK
static final int MASK
- See Also:
- Constant Field Values
-
SET_SIZE
static final int SET_SIZE
- See Also:
- Constant Field Values
-
SET_MASK
static final int SET_MASK
- See Also:
- Constant Field Values
-
buckets
final BooleanScorer.Bucket[] buckets
-
matching
final long[] matching
-
leads
final BooleanScorer.BulkScorerAndDoc[] leads
-
head
final BooleanScorer.HeadPriorityQueue head
-
tail
final BooleanScorer.TailPriorityQueue tail
-
scoreAndDoc
final ScoreAndDoc scoreAndDoc
-
minShouldMatch
final int minShouldMatch
-
cost
final long cost
-
needsScores
final boolean needsScores
-
orCollector
final BooleanScorer.OrCollector orCollector
-
docIdStreamView
private final BooleanScorer.DocIdStreamView docIdStreamView
-
-
Constructor Detail
-
BooleanScorer
BooleanScorer(BooleanWeight weight, java.util.Collection<BulkScorer> scorers, int minShouldMatch, boolean needsScores)
-
-
Method Detail
-
cost
private static long cost(java.util.Collection<BulkScorer> scorers, int minShouldMatch)
-
cost
public long cost()
Description copied from class:BulkScorer
Same asDocIdSetIterator.cost()
for bulk scorers.- Specified by:
cost
in classBulkScorer
-
scoreWindowIntoBitSetAndReplay
private void scoreWindowIntoBitSetAndReplay(LeafCollector collector, Bits acceptDocs, int base, int min, int max, BooleanScorer.BulkScorerAndDoc[] scorers, int numScorers) throws java.io.IOException
- Throws:
java.io.IOException
-
advance
private BooleanScorer.BulkScorerAndDoc advance(int min) throws java.io.IOException
- Throws:
java.io.IOException
-
scoreWindowMultipleScorers
private void scoreWindowMultipleScorers(LeafCollector collector, Bits acceptDocs, int windowBase, int windowMin, int windowMax, int maxFreq) throws java.io.IOException
- Throws:
java.io.IOException
-
scoreWindowSingleScorer
private void scoreWindowSingleScorer(BooleanScorer.BulkScorerAndDoc bulkScorer, LeafCollector collector, Bits acceptDocs, int windowMin, int windowMax, int max) throws java.io.IOException
- Throws:
java.io.IOException
-
scoreWindow
private BooleanScorer.BulkScorerAndDoc scoreWindow(BooleanScorer.BulkScorerAndDoc top, LeafCollector collector, Bits acceptDocs, int min, int max) throws java.io.IOException
- Throws:
java.io.IOException
-
score
public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws java.io.IOException
Description copied from class:BulkScorer
Collects matching documents in a range and return an estimation of the next matching document which is on or aftermax
.The return value must be:
- >=
max
, DocIdSetIterator.NO_MORE_DOCS
if there are no more matches,- <= the first matching document that is >=
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; }
- Specified by:
score
in classBulkScorer
- Parameters:
collector
- The collector to which all matching documents are passed.acceptDocs
-Bits
that represents the allowed documents to match, ornull
if they are all allowed to match.min
- Score starting at, including, this documentmax
- Score up to, but not including, this doc- Returns:
- an under-estimation of the next matching doc after max
- Throws:
java.io.IOException
- >=
-
-