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 floatprivate final ImpactsSourceprivate float[]private int[]private final Similarity.SimScorer -
Constructor Summary
ConstructorsConstructorDescriptionMaxScoreCache(ImpactsSource impactsSource, Similarity.SimScorer scorer) Sole constructor. -
Method Summary
Modifier and TypeMethodDescriptionintadvanceShallow(int target) Implement the contract ofScorer.advanceShallow(int)based on the wrappedImpactsSource.private floatcomputeMaxScore(List<Impact> impacts) private voidensureCacheSize(int size) private intgetLevel(int upTo) Return the first level that includes all doc IDs up toupTo, or -1 if there is no such level.floatgetMaxScore(int upTo) Return the maximum score up to upTo included.private floatgetMaxScoreForLevel(int level) Return the maximum score for the givenlevel.(package private) floatprivate intgetSkipLevel(Impacts impacts, float minScore) Return the maximum level at which scores are all less thanminScore, or -1 if none.(package private) intgetSkipUpTo(float minScore) Return the an inclusive upper bound of documents that all have a score that is less thanminScore, or-1if 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-1if the current document may be competitive.- Throws:
IOException
-