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

Implement take kernel for byte view array. #5602

Merged
merged 4 commits into from
Apr 9, 2024

Conversation

RinChanNOWWW
Copy link
Contributor

@RinChanNOWWW RinChanNOWWW commented Apr 8, 2024

Which issue does this PR close?

Closes #5511.

Rationale for this change

Necessary feature.

What changes are included in this PR?

  • Implement take kernel for StringViewArray and ByteViewArray.
  • Add unit tests for the kernel.

Are there any user-facing changes?

No.

@github-actions github-actions bot added the arrow Changes to the arrow crate label Apr 8, 2024
@RinChanNOWWW RinChanNOWWW marked this pull request as ready for review April 8, 2024 12:31
@@ -779,6 +779,34 @@ pub trait AsArray: private::Sealed {
self.as_bytes_opt().expect("binary array")
}

/// Downcast this to a [`StringViewArray`] returning `None` if not possible
fn as_string_view(&self) -> &StringViewArray {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a breaking change as the trait is sealed

Comment on lines +451 to +452
let new_views = take_native(array.views(), indices);
let new_nulls = take_nulls(array.nulls(), indices);
Copy link
Contributor

Choose a reason for hiding this comment

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

It's beautiful how these traits just magically work

@tustvold
Copy link
Contributor

tustvold commented Apr 9, 2024

I took the liberty of switching to use ArrayData equality and renaming the AsArray method to byte_view. Whilst bytes is perhaps more consistent with the as_bytes() method, I think it is better to be consistent with the naming of the type (as_bytes is probably named incorrectly)

@tustvold tustvold merged commit 144c9c7 into apache:master Apr 9, 2024
25 checks passed
@alamb
Copy link
Contributor

alamb commented Apr 9, 2024

Thank you @RinChanNOWWW and @tustvold

FYI @ariesdevil and @XiangpengHao -- its happening!

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.

take kernel support for StringViewArray and BinaryViewArray
3 participants