Skip to content

Commit 0d89f0a

Browse files
Use (valueCount + 1) * OFFSET_WIDTH instead of offsetAllocationSizeInBytes
Addresses review feedback from bodduv: LargeListVector.clear() sets offsetAllocationSizeInBytes = offsetBuffer.capacity(), which is 0 after the buffer is released. Using offsetAllocationSizeInBytes would allocate a 0-byte buffer in that case. (valueCount + 1) * OFFSET_WIDTH is always the correct minimum size (at least OFFSET_WIDTH when valueCount == 0) and matches the writerIndex that setReaderAndWriterIndex() just set. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Change-Id: Iae6b0a2578deb0f7fd8ca7ae36a0a7e3fc595765
1 parent 18b45a6 commit 0d89f0a

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

vector/src/main/java/org/apache/arrow/vector/complex/LargeListVector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public List<ArrowBuf> getFieldBuffers() {
280280
if (offsetBuffer.capacity() == 0 && offsetBuffer.writerIndex() > 0) {
281281
long writerIdx = offsetBuffer.writerIndex();
282282
offsetBuffer.getReferenceManager().release();
283-
offsetBuffer = allocateOffsetBuffer(offsetAllocationSizeInBytes);
283+
offsetBuffer = allocateOffsetBuffer((long) (valueCount + 1) * OFFSET_WIDTH);
284284
offsetBuffer.writerIndex(writerIdx);
285285
}
286286
result.add(offsetBuffer);

vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public List<ArrowBuf> getFieldBuffers() {
238238
if (offsetBuffer.capacity() == 0 && offsetBuffer.writerIndex() > 0) {
239239
long writerIdx = offsetBuffer.writerIndex();
240240
offsetBuffer.getReferenceManager().release();
241-
offsetBuffer = allocateOffsetBuffer(offsetAllocationSizeInBytes);
241+
offsetBuffer = allocateOffsetBuffer((long) (valueCount + 1) * OFFSET_WIDTH);
242242
offsetBuffer.writerIndex(writerIdx);
243243
}
244244
result.add(offsetBuffer);

0 commit comments

Comments
 (0)