- java.lang.Object
-
- org.apache.lucene.search.BulkScorer
-
- org.apache.lucene.search.BlockMaxConjunctionBulkScorer
-
final class BlockMaxConjunctionBulkScorer extends BulkScorer
BulkScorer implementation ofBlockMaxConjunctionScorer
that focuses on top-level conjunctions over clauses that do not have two-phase iterators. Use aWeight.DefaultBulkScorer
around aBlockMaxConjunctionScorer
if you need two-phase support. Another difference withBlockMaxConjunctionScorer
is that this scorer computes scores on the fly in order to be able to skip evaluating more clauses if the total score would be under the minimum competitive score anyway. This generally works well because computing a score is cheaper than decoding a block of postings.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
BlockMaxConjunctionBulkScorer.DocAndScore
-
Field Summary
Fields Modifier and Type Field Description private DocIdSetIterator[]
iterators
private DocIdSetIterator
lead1
private DocIdSetIterator
lead2
private int
maxDoc
private BlockMaxConjunctionBulkScorer.DocAndScore
scorable
private Scorer
scorer1
private Scorer
scorer2
private Scorer[]
scorers
private double[]
sumOfOtherClauses
-
Constructor Summary
Constructors Constructor Description BlockMaxConjunctionBulkScorer(int maxDoc, java.util.List<Scorer> scorers)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private float
computeMaxScore(int windowMin, int windowMax)
long
cost()
Same asDocIdSetIterator.cost()
for bulk scorers.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 void
scoreWindow(LeafCollector collector, Bits acceptDocs, int min, int max, float maxWindowScore)
-
Methods inherited from class org.apache.lucene.search.BulkScorer
score
-
-
-
-
Field Detail
-
scorers
private final Scorer[] scorers
-
iterators
private final DocIdSetIterator[] iterators
-
lead1
private final DocIdSetIterator lead1
-
lead2
private final DocIdSetIterator lead2
-
scorer1
private final Scorer scorer1
-
scorer2
private final Scorer scorer2
-
scorable
private final BlockMaxConjunctionBulkScorer.DocAndScore scorable
-
sumOfOtherClauses
private final double[] sumOfOtherClauses
-
maxDoc
private final int maxDoc
-
-
Constructor Detail
-
BlockMaxConjunctionBulkScorer
BlockMaxConjunctionBulkScorer(int maxDoc, java.util.List<Scorer> scorers) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
computeMaxScore
private float computeMaxScore(int windowMin, int windowMax) 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
- >=
-
scoreWindow
private void scoreWindow(LeafCollector collector, Bits acceptDocs, int min, int max, float maxWindowScore) throws java.io.IOException
- Throws:
java.io.IOException
-
cost
public long cost()
Description copied from class:BulkScorer
Same asDocIdSetIterator.cost()
for bulk scorers.- Specified by:
cost
in classBulkScorer
-
-