Skip to content

ListViewVector#getElementEndIndex Returns Size not Index #470

Closed

Description

@nbauernfeind

This method is incorrectly implemented:

  @Override
  public int getElementEndIndex(int index) {
    return sizeBuffer.getInt(index * OFFSET_WIDTH);
  }

https://github.com/apache/arrow-java/blob/main/vector/src/main/java/org/apache/arrow/vector/complex/ListViewVector.java#L957-L960

The javadoc indicates this is an offset not a length:

  /** Get data vector end index with the given list index. */
  int getElementEndIndex(int index);

This issue exists in main as of 480e1be.

Activity

  1. vibhatha commented on Jan 2, 2025

    @vibhatha
    Contributor

    @nbauernfeind thanks for filing this issue. Would you like to make a PR?

  2. joyCurry30 commented on Jan 14, 2025

    @joyCurry30

    Can you assign to me ? I'd like to make a PR.

  3. kou commented on Jan 14, 2025

    @kou
    Member

    Done!

  4. POORVANGIKA commented on Jan 20, 2025

    @POORVANGIKA

    public int getElementEndIndex(int index) {
    // Retrieve the offset from the offset buffer instead of sizeBuffer
    return offsetBuffer.getInt((index + 1) * OFFSET_WIDTH);
    }

  5. added a commit that references this issue on Jan 23, 2025
  6. added 2 commits that reference this issue on Mar 11, 2025
  7. added this to the 18.3.0 milestone on Mar 12, 2025
  8. modified the milestones: 18.3.0, 18.4.0 on May 8, 2025
  9. added 2 commits that reference this issue on Feb 15, 2026
  10. axreldable commented on Feb 15, 2026

    @axreldable
    Contributor

    public int getElementEndIndex(int index) { // Retrieve the offset from the offset buffer instead of sizeBuffer return offsetBuffer.getInt((index + 1) * OFFSET_WIDTH); }

    It works for ListVector, but it doesn't work for ListViewVector, as offsets can be out of order according to the specification. So we need to determine the end index of the element based on its offset and size.

    public int getElementEndIndex(int index) {
      return offsetBuffer.getInt(index * OFFSET_WIDTH) + sizeBuffer.getInt(index * SIZE_WIDTH);
    }
    
  11. added 2 commits that reference this issue on Feb 16, 2026
  12. added 2 commits that reference this issue on Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions