stefanvodita opened a new issue, #12839:
URL: https://github.com/apache/lucene/issues/12839

   ### Description
   
   `ArrayUtils` provides methods to grow arrays, overallocating exponentially, 
with the possibility of requesting a minimum size.
   Sometimes we have an upper limit to the number of elements that would go 
into that array. In those situations, it would be nice to have a method that 
grows up to a limit.
   For example, `DirectoryTaxonomyReader.getBulkOrdinals` dynamically grows an 
array pointing to ordinals missing from the cache 
([code](https://github.com/apache/lucene/blob/981339be0413730598631c1f578ba8a6493061b9/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java#L354)).
 But we know ahead of time there can't be more missing ordinals than there are 
ordinals in the taxonomy. We can limit the array growth to avoid overallocating.
   This pattern might be applicable in multiple places. `TermsAutomatonScorer` 
seems to use a [similar 
pattern](https://github.com/apache/lucene/blob/981339be0413730598631c1f578ba8a6493061b9/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/TermAutomatonScorer.java#L294).
   
   The API could look like this:
   ```
   public static int[] growInRange(int[] array, int minLength, int maxLength)
   ```


-- 
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.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

Reply via email to