- java.lang.Object
-
- org.apache.lucene.search.MaxScoreCache
-
public 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 float
globalMaxScore
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 int
advanceShallow(int target)
Implement the contract ofScorer.advanceShallow(int)
based on the wrappedImpactsSource
.private float
computeMaxScore(java.util.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
getMaxScoreForLevelZero()
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
-
globalMaxScore
private final float globalMaxScore
-
maxScoreCache
private float[] maxScoreCache
-
maxScoreCacheUpTo
private int[] maxScoreCacheUpTo
-
-
Constructor Detail
-
MaxScoreCache
public MaxScoreCache(ImpactsSource impactsSource, Similarity.SimScorer scorer)
Sole constructor.
-
-
Method Detail
-
advanceShallow
public int advanceShallow(int target) throws java.io.IOException
Implement the contract ofScorer.advanceShallow(int)
based on the wrappedImpactsSource
.- Throws:
java.io.IOException
- See Also:
Scorer.advanceShallow(int)
-
ensureCacheSize
private void ensureCacheSize(int size)
-
computeMaxScore
private float computeMaxScore(java.util.List<Impact> impacts)
-
getMaxScore
public float getMaxScore(int upTo) throws java.io.IOException
Return the maximum score up to upTo included.- Throws:
java.io.IOException
- See Also:
Scorer.getMaxScore(int)
-
getLevel
private 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
-
getMaxScoreForLevelZero
float getMaxScoreForLevelZero() throws java.io.IOException
- Throws:
java.io.IOException
-
getMaxScoreForLevel
private 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
-
-