java.lang.Object
org.apache.lucene.search.MaxScoreCache
Compute maximum scores based on
Impacts
and keep them in a cache in order not to run
expensive similarity score computations multiple times on the same data.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final float
private final ImpactsSource
private float[]
private int[]
private final Similarity.SimScorer
-
Constructor Summary
ConstructorsConstructorDescriptionMaxScoreCache
(ImpactsSource impactsSource, Similarity.SimScorer scorer) Sole constructor. -
Method Summary
Modifier and TypeMethodDescriptionint
advanceShallow
(int target) Implement the contract ofScorer.advanceShallow(int)
based on the wrappedImpactsSource
.private float
computeMaxScore
(List<Impact> impacts) private void
ensureCacheSize
(int size) private int
getLevel
(int upTo) Return the first level that includes all doc IDs up toupTo
, or -1 if there is no such level.float
getMaxScore
(int upTo) Return the maximum score up to upTo included.private float
getMaxScoreForLevel
(int level) Return the maximum score for the givenlevel
.(package private) float
private int
getSkipLevel
(Impacts impacts, float minScore) Return the maximum level at which scores are all less thanminScore
, or -1 if none.(package private) int
getSkipUpTo
(float minScore) Return the an inclusive upper bound of documents that all have a score that is less thanminScore
, or-1
if the current document may be competitive.
-
Field Details
-
impactsSource
-
scorer
-
globalMaxScore
private final float globalMaxScore -
maxScoreCache
private float[] maxScoreCache -
maxScoreCacheUpTo
private int[] maxScoreCacheUpTo
-
-
Constructor Details
-
MaxScoreCache
Sole constructor.
-
-
Method Details
-
advanceShallow
Implement the contract ofScorer.advanceShallow(int)
based on the wrappedImpactsSource
.- Throws:
IOException
- See Also:
-
ensureCacheSize
private void ensureCacheSize(int size) -
computeMaxScore
-
getMaxScore
Return the maximum score up to upTo included.- Throws:
IOException
- See Also:
-
getLevel
Return the first level that includes all doc IDs up toupTo
, or -1 if there is no such level.- Throws:
IOException
-
getMaxScoreForLevelZero
- Throws:
IOException
-
getMaxScoreForLevel
Return the maximum score for the givenlevel
.- Throws:
IOException
-
getSkipLevel
Return the maximum level at which scores are all less thanminScore
, or -1 if none.- Throws:
IOException
-
getSkipUpTo
Return the an inclusive upper bound of documents that all have a score that is less thanminScore
, or-1
if the current document may be competitive.- Throws:
IOException
-