Skip to content

Conversation

@davisusanibar
Copy link
Contributor

@davisusanibar davisusanibar commented Feb 29, 2024

Rationale for this change

Arrow Java implementation for #37877

What changes are included in this PR?

As a proposal:
Create ListViewVector that inherits from ListVector, mainly for adding new sizes buffer, then allocating nullability, offsetbuffer, sizesbuffer, and child data vector. ListViewVector overrides functionality such as: allocateNew, startNewValue, endValue, setValueCount, getObject, and getWriter.

These are the main activities:

  • Add ListViewVector datatype support
  • Add builders support using Vector
  • Add builders support using Writer
  • Add visitors into C Data Interface
  • Add unit test for JDBC changes
  • Add unit test for Flight SQL changes
  • Improve error handling rules (ie 0 <= offsets[i] + size[i] <= length of the child array)
  • Add operations to supportTransferPair
  • Add operations to support Nested ListViewVector
  • Add LargeListViewVector datatype support
  • Unit test for builders support using Vector
  • Unit test for builders support using Writers
  • Increase coverage unit test
  • Update documentation

Are these changes tested?

Every commit adding new functionality is accompanied by unit tests.

public void testListView() throws Exception {
    // values = [12, -7, 25, 0, -127, 127, 50]
    // offsets = [0, 7, 3, 0]
    // sizes = [3, 0, 4, 0]
    // data to get thru listview: [[12,-7,25], null, [0,-127,127,50], []]
    try (ListViewVector listViewVector = ListViewVector.empty("input", allocator);
         IntVector inVector =
             (IntVector) listViewVector.addOrGetVector(FieldType.nullable(Types.MinorType.INT.getType()))
                 .getVector()) {

      listViewVector.allocateNew();
      inVector.allocateNew();

      inVector.setSafe(0, 12);
      inVector.setSafe(1, -7);
      inVector.setSafe(2, 25);
      inVector.setSafe(3, 0);
      inVector.setSafe(4, -127);
      inVector.setSafe(5, 127);
      inVector.setSafe(6, 50);

      listViewVector.startNewValue(0, 0);
      listViewVector.endValue(0, 3);

      listViewVector.setNull(1);

      listViewVector.startNewValue(2, 3);
      listViewVector.endValue(2, 4);

      listViewVector.startNewValue(3, 0);
      listViewVector.endValue(3, 0);

      listViewVector.setValueCount(4);

      assertEquals(inVector.toString(), "[12, -7, 25, 0, -127, 127, 50]");
      assertEquals(listViewVector.toString(), "[[12,-7,25], null, [0,-127,127,50], []]");
    }
  }

Are there any user-facing changes?

No

@github-actions
Copy link

⚠️ GitHub issue #40289 has been automatically assigned in GitHub to PR creator.

@davisusanibar
Copy link
Contributor Author

In order to define a better alternative solution, the current pull request has been closed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant