Class MaxScoreCache


  • public final class MaxScoreCache
    extends java.lang.Object
    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 Detail

      • globalMaxScore

        private final float globalMaxScore
      • maxScoreCache

        private float[] maxScoreCache
      • maxScoreCacheUpTo

        private int[] maxScoreCacheUpTo
    • Method Detail

      • 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 to upTo, 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 given level.
        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 than minScore, 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 than minScore, or -1 if the current document may be competitive.
        Throws:
        java.io.IOException