Antoine Pitrou created ARROW-17919:
--------------------------------------

             Summary: [Java] Potentially inefficient variable-width vector 
reallocation
                 Key: ARROW-17919
                 URL: https://issues.apache.org/jira/browse/ARROW-17919
             Project: Apache Arrow
          Issue Type: Wish
          Components: Java
            Reporter: Antoine Pitrou


In a several places in the Java codebase you can see this kind of pattern:
{code:java}
    while (vector.getDataBuffer().capacity() < toCapacity) {
      vector.reallocDataBuffer();
    }
{code}

In the event that a much larger capacity is requested, this will spuriously 
make several reallocations (doubling the capacity each time).

It would probably be more efficient to reallocate directly to satisfy the 
desired capacity.

Coincidentally, there's a {{reallocDataBuffer}} overload that seems to do just 
that.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to