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

Add GenericListViewArray for ListView & LargeListView #5723

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Kikkon
Copy link
Contributor

@Kikkon Kikkon commented May 5, 2024

Which issue does this PR close?

A part of #5501

Rationale for this change

What changes are included in this PR?

Add GenericListViewArray implement

Are there any user-facing changes?

@Kikkon
Copy link
Contributor Author

Kikkon commented Jun 11, 2024

@tustvold If you have time, I would appreciate it if you could help me review this PR. Thanks!

Comment on lines 300 to 309
/// Creates a [`GenericListViewArray`] from an iterator of primitive values
///
pub fn from_iter_primitive<T, P, I>(_iter: I) -> Self
where
T: ArrowPrimitiveType,
P: IntoIterator<Item = Option<<T as ArrowPrimitiveType>::Native>>,
I: IntoIterator<Item = Option<P>>,
{
panic!("Not yet implemented, wait list view array builder to be implemented")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could just not provide this for now

};
let iter = std::iter::repeat(size).take(value.len());
let mut offsets = Vec::with_capacity(iter.size_hint().0);
offsets.push(OffsetSize::usize_as(0));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct?

Comment on lines 594 to 596
.as_any()
.downcast_ref::<Int32Array>()
.unwrap()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.as_any()
.downcast_ref::<Int32Array>()
.unwrap()
.as_primitive::<Int32Type>()

And the same elsewhere

Comment on lines 429 to 417
acc = acc.checked_add(size).expect("usize overflow");
offsets.push(OffsetSize::usize_as(acc));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
acc = acc.checked_add(size).expect("usize overflow");
offsets.push(OffsetSize::usize_as(acc));
offsets.push(OffsetSize::usize_as(acc));
acc = acc.checked_add(size).expect("usize overflow");

.iter()
.map(|x| x.map(|x| x.as_primitive::<Int32Type>().values().to_vec()))
.collect();
assert_eq!(values, vec![Some(vec![1, 2, 3]), None, Some(vec![4, 5, 6])])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add tests of the offsets and sizes buffers, I think they're currently not quite correct

Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, been swamped and then sick, but this is looking almost there

@Kikkon
Copy link
Contributor Author

Kikkon commented Jun 16, 2024

Thank you for taking the time to review my code despite being busy and unwell.

@Kikkon Kikkon requested a review from tustvold June 16, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants