Package org.apache.lucene.search
Class MaxScoreCache
- java.lang.Object
-
- org.apache.lucene.search.MaxScoreCache
-
final class MaxScoreCache extends java.lang.ObjectCompute maximum scores based onImpactsand keep them in a cache in order not to run expensive similarity score computations multiple times on the same data.
-
-
Field Summary
Fields Modifier and Type Field Description private ImpactsSourceimpactsSourceprivate float[]maxScoreCacheprivate int[]maxScoreCacheUpToprivate Similarity.SimScorerscorer
-
Constructor Summary
Constructors Constructor Description MaxScoreCache(ImpactsSource impactsSource, Similarity.SimScorer scorer)Sole constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private floatcomputeMaxScore(java.util.List<Impact> impacts)private voidensureCacheSize(int size)(package private) intgetLevel(int upTo)Return the first level that includes all doc IDs up toupTo, or -1 if there is no such level.(package private) floatgetMaxScoreForLevel(int level)Return the maximum score for the givenlevel.private 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 Detail
-
impactsSource
private final ImpactsSource impactsSource
-
scorer
private final Similarity.SimScorer scorer
-
maxScoreCache
private float[] maxScoreCache
-
maxScoreCacheUpTo
private int[] maxScoreCacheUpTo
-
-
Constructor Detail
-
MaxScoreCache
public MaxScoreCache(ImpactsSource impactsSource, Similarity.SimScorer scorer)
Sole constructor.
-
-
Method Detail
-
ensureCacheSize
private void ensureCacheSize(int size)
-
computeMaxScore
private float computeMaxScore(java.util.List<Impact> impacts)
-
getLevel
int getLevel(int upTo) throws java.io.IOExceptionReturn the first level that includes all doc IDs up toupTo, or -1 if there is no such level.- Throws:
java.io.IOException
-
getMaxScoreForLevel
float getMaxScoreForLevel(int level) throws java.io.IOExceptionReturn the maximum score for the givenlevel.- Throws:
java.io.IOException
-
getSkipLevel
private int getSkipLevel(Impacts impacts, float minScore) throws java.io.IOException
Return the maximum level at which scores are all less thanminScore, or -1 if none.- Throws:
java.io.IOException
-
getSkipUpTo
int getSkipUpTo(float minScore) throws java.io.IOExceptionReturn 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:
java.io.IOException
-
-