-
Notifications
You must be signed in to change notification settings - Fork 4.1k
ARROW-11239: [Rust] Show some unit test failures #9193
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
Changes from all commits
f8ceb40
b811768
bdadb4c
91927ce
5391893
9f3989c
e20ee33
a79b156
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ use crate::buffer::Buffer; | |
| use crate::datatypes::DataType; | ||
| use crate::{bitmap::Bitmap, datatypes::ArrowNativeType}; | ||
|
|
||
| use super::equal::equal; | ||
| use super::{equal::equal, MutableArrayData}; | ||
|
|
||
| #[inline] | ||
| pub(crate) fn count_nulls( | ||
|
|
@@ -219,17 +219,15 @@ impl ArrayData { | |
| /// | ||
| /// Panics if `offset + length > self.len()`. | ||
| pub fn slice(&self, offset: usize, length: usize) -> ArrayData { | ||
| assert!((offset + length) <= self.len()); | ||
|
|
||
| let mut new_data = self.clone(); | ||
|
|
||
| new_data.len = length; | ||
| new_data.offset = offset + self.offset; | ||
|
|
||
| new_data.null_count = | ||
| count_nulls(new_data.null_buffer(), new_data.offset, new_data.len); | ||
| self.copy_range(offset, length) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the attempt to implement slice with MutableArrayData, but triggers ARROW-11263 |
||
| } | ||
|
|
||
| new_data | ||
| fn copy_range(&self, offset: usize, length: usize) -> ArrayData { | ||
| assert!((offset + length) <= self.len()); | ||
| let arrays = vec![self]; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this hints the right direction:
The problem is: there are still 5 failures due to "not yet implemented" or "not supported"
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Totally wrong, the benchmark of |
||
| let mut mutable = MutableArrayData::new(arrays, false, length); | ||
| mutable.extend(0, offset, offset + length); | ||
| mutable.freeze() | ||
| } | ||
|
|
||
| /// Returns the `buffer` as a slice of type `T` starting at self.offset | ||
|
|
@@ -428,28 +426,45 @@ mod tests { | |
| bit_util::set_bit(&mut bit_v, 0); | ||
| bit_util::set_bit(&mut bit_v, 3); | ||
| bit_util::set_bit(&mut bit_v, 10); | ||
| let data_vec = vec![0_u8; 64]; // align to 64 bytes | ||
| let data = ArrayData::builder(DataType::Int32) | ||
| .len(16) | ||
| .null_bit_buffer(Buffer::from(bit_v)) | ||
| .add_buffer(Buffer::from(data_vec)) | ||
| .build(); | ||
| let data = data.as_ref(); | ||
| let new_data = data.slice(1, 15); | ||
| assert_eq!(data.len() - 1, new_data.len()); | ||
| assert_eq!(1, new_data.offset()); | ||
| assert_eq!(0, new_data.offset()); | ||
| assert_eq!(data.null_count(), new_data.null_count()); | ||
|
|
||
| // slice of a slice (removes one null) | ||
| let new_data = new_data.slice(1, 14); | ||
| assert_eq!(data.len() - 2, new_data.len()); | ||
| assert_eq!(2, new_data.offset()); | ||
| assert_eq!(0, new_data.offset()); | ||
| assert_eq!(data.null_count() - 1, new_data.null_count()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_equality() { | ||
| let int_data = ArrayData::builder(DataType::Int32).build(); | ||
| let float_data = ArrayData::builder(DataType::Float32).build(); | ||
| assert_ne!(int_data, float_data); | ||
| #[should_panic(expected = "index out of bounds: the len is 0 but the index is 0")] | ||
| fn test_slice_equality() { | ||
| let mut bit_v: [u8; 1] = [0; 1]; | ||
| bit_util::set_bit(&mut bit_v, 1); | ||
| let data = ArrayData::builder(DataType::Int32) | ||
| .len(2) | ||
| .null_bit_buffer(Buffer::from(bit_v)) | ||
| .build(); | ||
| let data_slice = data.slice(1, 1); | ||
|
|
||
| let mut bit_v: [u8; 1] = [0; 1]; | ||
| bit_util::set_bit(&mut bit_v, 0); | ||
| let arc_data = ArrayData::builder(DataType::Int32) | ||
| .len(1) | ||
| .null_bit_buffer(Buffer::from(bit_v)) | ||
| .build(); | ||
| let expected = arc_data.as_ref(); | ||
|
|
||
| assert_eq!(&data_slice, expected); | ||
| } | ||
|
|
||
| #[test] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://issues.apache.org/jira/projects/ARROW/issues/ARROW-11263