Package org.apache.lucene.search
Class MaxScoreCache
- java.lang.Object
-
- org.apache.lucene.search.MaxScoreCache
-
final class MaxScoreCache extends java.lang.Object
Compute maximum scores based onImpacts
and 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 ImpactsSource
impactsSource
private float[]
maxScoreCache
private int[]
maxScoreCacheUpTo
private Similarity.SimScorer
scorer
-
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 float
computeMaxScore(java.util.List<Impact> impacts)
private void
ensureCacheSize(int size)
(package private) int
getLevel(int upTo)
Return the first level that includes all doc IDs up toupTo
, or -1 if there is no such level.(package private) float
getMaxScoreForLevel(int level)
Return the maximum score for the givenlevel
.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 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.IOException
Return 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.IOException
Return 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.IOException
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:
java.io.IOException
-
-