Skip to content

[Java][ListView] Implementation of the ListView #40289

@davisusanibar

Description

@davisusanibar

Describe the enhancement requested

C++, Go, and Python all support ListView. The goal of this enhancement is to expand the Arrow Java format input for ListView.

This could be an initial proposal for ListViewVector based on current LisVector implementation:

Using ListViewVector:

...
// 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], []]
...
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); // (0=index, 0=offset)
listViewVector.endValue(0, 3); //(0=index, 3=number of items)

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], []]");

Using Writers:

// 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], []]
...
UnionListViewWriter writer = inVector.getWriter();
writer.allocate();

writer.setPosition(0);
writer.startList(0); // (0=offset)
writer.bigInt().writeBigInt(12);
writer.bigInt().writeBigInt(-7);
writer.bigInt().writeBigInt(25);
writer.endList(3); // (3=number of items)


writer.setPosition(2);
writer.startList(3);
writer.bigInt().writeBigInt(0);
writer.bigInt().writeBigInt(-127);
writer.bigInt().writeBigInt(127);
writer.bigInt().writeBigInt(50);
writer.endList(4);

writer.setPosition(3);
writer.startList(0);
writer.endList(0);

writer.setValueCount(4);

...

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

Component(s)

Java

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions