arrow-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Siddharth Teotia <>
Subject Re: [Java] Strange reset() method in FixedValueVectors
Date Fri, 28 Jul 2017 22:59:15 GMT
Hi Li

For template, the initial allocation will happen
based on the value of allocationSizeInBytes. For example, for a 4 byte
IntVector, this will be 16KB of memory which is equivalent to
INITIAL_VALUE_ALLOCATION * ${type_width} in the code. So if the user
invokes fixed_vector.allocateNew(), it will try to allocate memory based on
this value of allocationSizeInBytes.

The functions allocateNew(), allocateNewSafe(), realloc() consume the
current value of allocationSizeInBytes and decide the actual size of memory
to allocate (or re-allocate). They also change the value of
allocationSizeInBytes after the allocation (or re-allocation) has been done

The reset() function does allocationSizeInBytes = INITIAL_VALUE_ALLOCATION
so that subsequent usage of alloc/realloc functions can start from this
base-value (value at the time vector was instantiated)

However, I think reset() method should instead do allocationSizeInBytes =
INITIAL_VALUE_ALLOCATION * ${type_width} to reset to the actual initial

For template, these vectors actually delegate
most of the calls to the underlying bit vector and value vector (which
could be fixed-width or variable width). For this reason, I think the
reset() method should call values.reset() on the corresponding value
vector. Right now it resets only the bit vector.

I hope this answer some of your questions.


On Fri, Jul 28, 2017 at 8:55 AM, Li Jin <> wrote:

> Hi All,
> I encountered this weirdness in Arrow Java codebase that I hope someone can
> help me understand.
> This reset method of FixedValueVectors sets the allocation size to
> I am wondering why it does that and how does it handle the case where the
> vector is expanded through realloc.
> src/main/codegen/templates/
> For comparison, reset() in NullableValueVectors doesn't do that:
> src/main/codegen/templates/
> Appreciate the help!
> Li

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message