msfroh commented on code in PR #12995: URL: https://github.com/apache/lucene/pull/12995#discussion_r1444070455
########## lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/TaxonomyIndexArrays.java: ########## @@ -153,12 +203,13 @@ private void initParents(IndexReader reader, int first) throws IOException { * <p><b>NOTE:</b> you should call this method from a thread-safe code. */ TaxonomyIndexArrays add(int ordinal, int parentOrdinal) { - if (ordinal >= parents.length) { - int[] newarray = ArrayUtil.grow(parents, ordinal + 1); - newarray[ordinal] = parentOrdinal; - return new TaxonomyIndexArrays(newarray); + if (ordinal >= parents.length()) { + int[][] newParents = allocateChunkedArray(ArrayUtil.oversize(ordinal + 1, Integer.BYTES)); Review Comment: This is actually consistent with the old behavior: ``` int[] newarray = ArrayUtil.grow(parents, ordinal + 1); newarray[ordinal] = parentOrdinal; return new TaxonomyIndexArrays(newarray); ``` That call to `ArrayUtil.grow` would oversize the array, leaving some spare extra elements at the end. It confused me when I saw it. Then I realized that this kind of instance of the array is only used on the write path and (as far as I can tell) is never passed to the `TaxonomyIndexArrays(IndexReader reader, TaxonomyIndexArrays copyFrom)` constructor. So, yes, it "wastes" (really "pre-allocates") some extra space at the end, so the length doesn't reflect the number of assigned ordinals, but that's okay because the writer's source of truth is the `nextId` value. -- 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