Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-10660

precompute the max level in LogMergePolicy

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 9.2
    • 9.4
    • core/index
    • None
    • New

    Description

      I notice LogMergePolicy#findMerges will always calculate  max level on the right side when find the next segments to merge.

       

      I think we could calculate the max levels only once, and when we need the max level, we could simply

      float maxLevel = maxLevels[start];
      

      and the precomputed code looks like below, compare each level in levels from right to left

      float[] maxLevels = new float[numMergeableSegments + 1];
      maxLevels[numMergeableSegments] = -1.0f;
      for (int i = numMergeableSegments - 1; i >= 0; i--) {
            maxLevels[i] = Math.max(levels.get(i).level, maxLevels[i + 1]);
      }
      

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tangdh tang donghai
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m