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

Improve take kernel performance on primitive arrays, fix bad null index handling (#4404) #4405

Merged
merged 2 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arrow-buffer/src/buffer/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ impl BooleanBuffer {
/// # Panics
///
/// Panics if `i >= self.len()`
#[inline]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is vital for the performance of take_bits

pub fn value(&self, idx: usize) -> bool {
assert!(idx < self.len);
unsafe { self.value_unchecked(idx) }
Expand Down
6 changes: 6 additions & 0 deletions arrow-buffer/src/buffer/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ impl<T: ArrowNativeType> From<Vec<T>> for ScalarBuffer<T> {
}
}

impl<T: ArrowNativeType> FromIterator<T> for ScalarBuffer<T> {
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
iter.into_iter().collect::<Vec<_>>().into()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

An important thing to note is that Vec: FromIterator has a specialization for TrustedLen iterators, such as those from slices. This allows us to not need Buffer::try_from_trusted_len_iter

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add this (very interesting) information as a comment inline?

}
}

impl<'a, T: ArrowNativeType> IntoIterator for &'a ScalarBuffer<T> {
type Item = &'a T;
type IntoIter = std::slice::Iter<'a, T>;
Expand Down
Loading