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][ListView] Implementation of the ListView #40289

Closed
davisusanibar opened this issue Feb 29, 2024 · 1 comment
Closed

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

davisusanibar opened this issue Feb 29, 2024 · 1 comment

Comments

@davisusanibar
Copy link
Contributor

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

@vibhatha
Copy link
Collaborator

Closing this issue in favor of apache/arrow-java#102

@lidavidm lidavidm closed this as not planned Won't fix, can't repro, duplicate, stale Apr 18, 2024
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

3 participants