arrow-dev mailing list archives

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

For FixedValueVectors.java 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
successfully.

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
value.

For NullableValueVectors.java 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.

Thanks
Siddharth

On Fri, Jul 28, 2017 at 8:55 AM, Li Jin <ice.xelloss@gmail.com> 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
> INITIAL_VALUE_ALLOCATION.
> I am wondering why it does that and how does it handle the case where the
> vector is expanded through realloc.
>
> https://github.com/apache/arrow/blob/master/java/vector/
> src/main/codegen/templates/FixedValueVectors.java#L165
>
> For comparison, reset() in NullableValueVectors doesn't do that:
>
> https://github.com/apache/arrow/blob/master/java/vector/
> src/main/codegen/templates/NullableValueVectors.java#L285
>
> Appreciate the help!
>
> Li
>

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