Skip to content

Commit 878c8d5

Browse files
author
Yicong Huang
committed
fix: resotre allocation size
1 parent 7dbdcc4 commit 878c8d5

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ public List<ArrowBuf> getFieldBuffers() {
280280
// According to Arrow specification, offset buffer must have N+1 entries,
281281
// even when N=0, it should contain [0].
282282
if (offsetBuffer.capacity() == 0) {
283+
// Save and restore offsetAllocationSizeInBytes to avoid affecting subsequent allocateNew()
284+
long savedOffsetAllocationSize = offsetAllocationSizeInBytes;
283285
offsetBuffer = allocateOffsetBuffer(OFFSET_WIDTH);
286+
offsetAllocationSizeInBytes = savedOffsetAllocationSize;
284287
}
285288

286289
setReaderAndWriterIndex();

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,10 @@ public List<ArrowBuf> getFieldBuffers() {
238238
// According to Arrow specification, offset buffer must have N+1 entries,
239239
// even when N=0, it should contain [0].
240240
if (offsetBuffer.capacity() == 0) {
241+
// Save and restore offsetAllocationSizeInBytes to avoid affecting subsequent allocateNew()
242+
long savedOffsetAllocationSize = offsetAllocationSizeInBytes;
241243
offsetBuffer = allocateOffsetBuffer(OFFSET_WIDTH);
244+
offsetAllocationSizeInBytes = savedOffsetAllocationSize;
242245
}
243246

244247
setReaderAndWriterIndex();

0 commit comments

Comments
 (0)