Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java] Users are required to initialize VariableLengthVectors.offsetVector before calling VariableLengthVectors.mutator.getSafe #16128

Closed
asfimport opened this issue Jan 14, 2017 · 2 comments

Comments

@asfimport
Copy link

https://github.com/apache/arrow/blob/master/java/vector/src/main/codegen/templates/VariableLengthVectors.java#L492

Here VariableLengthVectors.getMutator().setSafe() calls:

offsetVector.getAccessor().get(index)

however, index 0 of offsetVector (which is always 0) is not initialized by VariableLengthVectors.

As a result, user of the VariableLengthVectors needs to manually initialize
the class by calling:

VariableLengthVectors.getOffsetVector().getMutator().setSafe(0, 0)

I wonder if this is necessary or should VariableLengthVectors initialize this for the user

Reporter: Li Jin / @icexelloss

Note: This issue was originally created as ARROW-485. Please see the migration documentation for further details.

@asfimport
Copy link
Author

Jacques Nadeau / @jacques-n:
There should be better documentation on this. In order to use vectors, the correct order of operations are:

  1. allocateNew() (allocate memory for the vector)
  2. Set one or more values using getMutator().setSafe(i, val). Note, this has to be monotonically increasing position but allows index skips.
  3. call set valueCount(n) where n is the number of valid indices in the vector
  4. read or serialize data

I believe that if you follow these operations, you will not have a problem here. I'm guessing you're trying to use a vector before allocating (1).

@asfimport
Copy link
Author

Li Jin / @icexelloss:
Thanks, this is super helpful. I am going to follow the steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant