tang donghai created LUCENE-10660: ------------------------------------- Summary: precompute the max level in LogMergePolicy Key: LUCENE-10660 URL: https://issues.apache.org/jira/browse/LUCENE-10660 Project: Lucene - Core Issue Type: Improvement Components: core/index Affects Versions: 9.2 Reporter: tang donghai
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 {code:java} float maxLevel = maxLevels[start]; {code} and the precomputed code looks like below, compare each level in levels from right to left {code:java} 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]); } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org