liyafan82 commented on a change in pull request #7290: URL: https://github.com/apache/arrow/pull/7290#discussion_r439334686
########## File path: java/vector/src/main/codegen/templates/UnionVector.java ########## @@ -325,12 +361,45 @@ private void allocateTypeBuffer() { typeBuffer.setZero(0, typeBuffer.capacity()); } + private void allocateValidityBuffer() { + validityBuffer = allocator.buffer(validityBufferAllocationSizeInBytes); + validityBuffer.readerIndex(0); + validityBuffer.setZero(0, validityBuffer.capacity()); + } + @Override public void reAlloc() { internalStruct.reAlloc(); + reallocValidityBuffer(); reallocTypeBuffer(); } + private void reallocValidityBuffer() { + final long currentBufferCapacity = validityBuffer.capacity(); + long newAllocationSize = currentBufferCapacity * 2; + if (newAllocationSize == 0) { + if (validityBufferAllocationSizeInBytes > 0) { + newAllocationSize = validityBufferAllocationSizeInBytes; + } else { + newAllocationSize = DataSizeRoundingUtil.divideBy8Ceil(BaseValueVector.INITIAL_VALUE_ALLOCATION) * 2; + } Review comment: do we need to multiply by 2 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org