dungba88 commented on code in PR #12844: URL: https://github.com/apache/lucene/pull/12844#discussion_r1412105704
########## lucene/core/src/java/org/apache/lucene/util/hnsw/NeighborArray.java: ########## @@ -32,17 +32,20 @@ * @lucene.internal */ public class NeighborArray { + private static final int INITIAL_CAPACITY = 10; private final boolean scoresDescOrder; + private final int maxSize; private int size; float[] score; int[] node; private int sortedNodeSize; public final ReadWriteLock rwlock = new ReentrantReadWriteLock(true); public NeighborArray(int maxSize, boolean descOrder) { - node = new int[maxSize]; - score = new float[maxSize]; + node = new int[INITIAL_CAPACITY]; Review Comment: I was new to this class, just curious what happen if INITIAL_CAPACITY > maxSize. I thought maxSize is the maximum size that we ever needed. But looking at previous code, it seems the array can still be expanded even if we already fully pre-allocated it with maxSize, from the line `node = ArrayUtil.grow(node);`. Is it just because it was initial grow on-demand, then change to full prelocation, but didn't clean that up. If it's indeed the maximum size that we ever need, maybe `Math.min(INITIAL_CAPACITY, maxSize)` would be better. -- 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