mikemccand commented on code in PR #12653: URL: https://github.com/apache/lucene/pull/12653#discussion_r1367036009
########## lucene/core/src/java/org/apache/lucene/codecs/MultiLevelSkipListWriter.java: ########## @@ -63,24 +63,23 @@ public abstract class MultiLevelSkipListWriter { /** for every skip level a different buffer is used */ private ByteBuffersDataOutput[] skipBuffer; + /** Length of the window at which the skips are placed on skip level 1 */ + private final long windowLength; + /** Creates a {@code MultiLevelSkipListWriter}. */ protected MultiLevelSkipListWriter( int skipInterval, int skipMultiplier, int maxSkipLevels, int df) { this.skipInterval = skipInterval; this.skipMultiplier = skipMultiplier; - int numberOfSkipLevels; + int numberOfSkipLevels = 1; // calculate the maximum number of skip levels for this document frequency - if (df <= skipInterval) { - numberOfSkipLevels = 1; - } else { - numberOfSkipLevels = 1 + MathUtil.log(df / skipInterval, skipMultiplier); - } - - // make sure it does not exceed maxSkipLevels - if (numberOfSkipLevels > maxSkipLevels) { - numberOfSkipLevels = maxSkipLevels; + if (df > skipInterval) { + // also make sure it does not exceed maxSkipLevels + numberOfSkipLevels = + Math.min(1 + MathUtil.log(df / skipInterval, skipMultiplier), maxSkipLevels); } Review Comment: > Actually it was not the instance variable that you are thinking of and rather was a local variable with duplicate name(i.e. `numberOfSkipLevels`) which was totally unnecessary here so I cleaned that up as well. Aha! That explains my confusion. Such shadowing (`x` and `this.x` being different) is so confusing/dangerous. Thanks for cleaning it up! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org