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

feat: Support FixedSizedListArray for length kernel #4520

Merged

Conversation

Weijun-H
Copy link
Contributor

Which issue does this PR close?

Closes #4517

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Jul 13, 2023
@Weijun-H Weijun-H force-pushed the Support-FixedSizedListArray-for-length-kernel branch from ab3362d to b80afa0 Compare July 14, 2023 04:00
let length_list = array.len();
let buffer = Buffer::from_vec(vec![length; length_list]);

let data = unsafe {
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 use PrimitiveArray::new here?

@alexandreyc
Copy link
Contributor

Hello,

I just reviewed this PR and I have two suggestions:

  • Update length() documentation to include FixedSizeListArray
  • Is it really necessary for length_list_fixed_size to be generic over T? According to the spec, FixedSizeList always have 32-bit signed integers as the length of the lists.

Otherwise it looks good to me!

let length_list = array.len();
let buffer = Buffer::from_vec(vec![length; length_list]);

let data: PrimitiveArray<T> =
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove T and just use Int32Array?

{
let array = array.as_any().downcast_ref::<FixedSizeListArray>().unwrap();
let length_list = array.len();
let buffer = Buffer::from_vec(vec![length; length_list]);
Copy link
Contributor

Choose a reason for hiding this comment

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

This assumes T::Native is i32

let data: PrimitiveArray<T> =
PrimitiveArray::new(buffer.into(), array.nulls().cloned());

make_array(data.into())
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
make_array(data.into())
Arc::new(data)

where
T: ArrowPrimitiveType,
{
let array = array.as_any().downcast_ref::<FixedSizeListArray>().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
let array = array.as_any().downcast_ref::<FixedSizeListArray>().unwrap();
let array = array.as_fixed_size_list();

@tustvold tustvold merged commit 730941f into apache:master Jul 19, 2023
17 checks passed
@alamb
Copy link
Contributor

alamb commented Jul 19, 2023

Thank you @Weijun-H and @tustvold

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.

Support FixedSizedListArray for length kernel
4 participants