ConeyLiu commented on code in PR #13815:
URL: https://github.com/apache/arrow/pull/13815#discussion_r940864168
##########
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:
I think the reallocation may not meet the memory request if the `dataLength`
is larger than two times of `valueBuffer.capacity()`. That I think the while
loop is needed here.
--
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]