pitrou commented on code in PR #13815:
URL: https://github.com/apache/arrow/pull/13815#discussion_r940963715


##########
java/vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthVector.java:
##########
@@ -1250,8 +1251,10 @@ protected final void handleSafe(int index, int 
dataLength) {
     while (index >= getValueCapacity()) {
       reallocValidityAndOffsetBuffers();
     }
-    final int startOffset = lastSet < 0 ? 0 : getStartOffset(lastSet + 1);
-    while (valueBuffer.capacity() < (startOffset + dataLength)) {
+    final long startOffset = lastSet < 0 ? 0 : getStartOffset(lastSet + 1);
+    final long targetCapacity = startOffset + dataLength;
+    checkDataBufferSize(targetCapacity);
+    while (valueBuffer.capacity() < targetCapacity) {
       reallocDataBuffer();
     }

Review Comment:
   Yes. My point is that it's wasteful to reallocate several times in a row, 
instead of reallocating directly to the desired target capacity. Anyway, this 
was already the case before.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to