Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -571,10 +571,13 @@ public void reallocDataBuffer(long desiredAllocSize) {
return;
}

final long newAllocationSize = CommonUtil.nextPowerOfTwo(desiredAllocSize);
final long newAllocationSize =
Math.min(CommonUtil.nextPowerOfTwo(desiredAllocSize), MAX_BUFFER_SIZE);
assert newAllocationSize >= 1;

checkDataBufferSize(newAllocationSize);
if (newAllocationSize < desiredAllocSize) {
checkDataBufferSize(desiredAllocSize);
}

final ArrowBuf newBuf = allocator.buffer(newAllocationSize);
newBuf.setBytes(0, valueBuffer, 0, valueBuffer.capacity());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,15 +550,18 @@ public void reallocViewBuffer(long desiredAllocSize) {
if (desiredAllocSize == 0) {
return;
}
long newAllocationSize = CommonUtil.nextPowerOfTwo(desiredAllocSize);
long newAllocationSize = Math.min(CommonUtil.nextPowerOfTwo(desiredAllocSize), MAX_BUFFER_SIZE);
assert newAllocationSize >= 1;

checkDataBufferSize(newAllocationSize);
// for each set operation, we have to allocate 16 bytes
// here we are adjusting the desired allocation-based allocation size
// to align with the 16bytes requirement.
newAllocationSize = roundUpToMultipleOf16(newAllocationSize);

if (newAllocationSize < desiredAllocSize) {
checkDataBufferSize(desiredAllocSize);
}

final ArrowBuf newBuf = allocator.buffer(newAllocationSize);
newBuf.setBytes(0, viewBuffer, 0, viewBuffer.capacity());

Expand Down Expand Up @@ -587,10 +590,13 @@ public void reallocViewDataBuffer(long desiredAllocSize) {
return;
}

final long newAllocationSize = CommonUtil.nextPowerOfTwo(desiredAllocSize);
final long newAllocationSize =
Math.min(CommonUtil.nextPowerOfTwo(desiredAllocSize), MAX_BUFFER_SIZE);
assert newAllocationSize >= 1;

checkDataBufferSize(newAllocationSize);
if (newAllocationSize < desiredAllocSize) {
checkDataBufferSize(desiredAllocSize);
}

final ArrowBuf newBuf = allocator.buffer(newAllocationSize);
dataBuffers.add(newBuf);
Expand Down
Loading