diff --git a/arrow-array/src/builder/generic_list_view_builder.rs b/arrow-array/src/builder/generic_list_view_builder.rs index 25d961d25ed9..92487e0cea84 100644 --- a/arrow-array/src/builder/generic_list_view_builder.rs +++ b/arrow-array/src/builder/generic_list_view_builder.rs @@ -597,13 +597,13 @@ mod tests { .as_any_mut() .downcast_mut::>>() .expect("should be an (Large)ListViewBuilder") - .append(true,3); + .append(true, 3); builder .values() .as_any_mut() .downcast_mut::>>() .expect("should be an (Large)ListViewBuilder") - .append(false,0); + .append(false, 0); builder .values() .as_any_mut() @@ -619,10 +619,10 @@ mod tests { .as_any_mut() .downcast_mut::>>() .expect("should be an (Large)ListViewBuilder") - .append(true,1); - builder.append(true,3); + .append(true, 1); + builder.append(true, 3); - builder.append(false,0); + builder.append(false, 0); builder .values() @@ -649,8 +649,8 @@ mod tests { .as_any_mut() .downcast_mut::>>() .expect("should be an (Large)ListViewBuilder") - .append(true,2); - builder.append(true,1); + .append(true, 2); + builder.append(true, 1); let l1 = builder.finish(); assert_eq!(4, l1.len()); @@ -688,7 +688,9 @@ mod tests { } #[test] - #[should_panic(expected = "Non-nullable field of ListViewArray \\\"item\\\" cannot contain nulls")] + #[should_panic( + expected = "Non-nullable field of ListViewArray \\\"item\\\" cannot contain nulls" + )] fn test_checks_nullability() { let field = Arc::new(Field::new("item", DataType::Int32, false)); let mut builder = ListViewBuilder::new(Int32Builder::new()).with_field(field.clone()); diff --git a/arrow-array/src/builder/mod.rs b/arrow-array/src/builder/mod.rs index 109492de18ea..dccba9b35f83 100644 --- a/arrow-array/src/builder/mod.rs +++ b/arrow-array/src/builder/mod.rs @@ -180,8 +180,8 @@ mod generic_byte_run_builder; pub use generic_byte_run_builder::*; mod generic_bytes_view_builder; pub use generic_bytes_view_builder::*; -mod union_builder; mod generic_list_view_builder; +mod union_builder; pub use generic_list_view_builder::*; pub use union_builder::*; diff --git a/arrow-array/src/builder/struct_builder.rs b/arrow-array/src/builder/struct_builder.rs index 52ed42cab6cf..b3adea27e6eb 100644 --- a/arrow-array/src/builder/struct_builder.rs +++ b/arrow-array/src/builder/struct_builder.rs @@ -259,7 +259,9 @@ pub fn make_builder(datatype: &DataType, capacity: usize) -> Box { let builder = make_builder(field.data_type(), capacity); - Box::new(LargeListViewBuilder::with_capacity(builder, capacity).with_field(field.clone())) + Box::new( + LargeListViewBuilder::with_capacity(builder, capacity).with_field(field.clone()), + ) } DataType::Map(field, _) => match field.data_type() { DataType::Struct(fields) => { diff --git a/arrow-array/src/record_batch.rs b/arrow-array/src/record_batch.rs index 5fcfaa0b2709..c56b1fd308cf 100644 --- a/arrow-array/src/record_batch.rs +++ b/arrow-array/src/record_batch.rs @@ -626,7 +626,9 @@ mod tests { use std::collections::HashMap; use super::*; - use crate::{BooleanArray, Int32Array, Int64Array, Int8Array, ListArray, StringArray, StringViewArray}; + use crate::{ + BooleanArray, Int32Array, Int64Array, Int8Array, ListArray, StringArray, StringViewArray, + }; use arrow_buffer::{Buffer, ToByteSlice}; use arrow_data::{ArrayData, ArrayDataBuilder}; use arrow_schema::Fields; diff --git a/arrow-buffer/src/buffer/size.rs b/arrow-buffer/src/buffer/size.rs index 02c100d1223f..ff314cc2d975 100644 --- a/arrow-buffer/src/buffer/size.rs +++ b/arrow-buffer/src/buffer/size.rs @@ -15,14 +15,13 @@ // specific language governing permissions and limitations // under the License. -use std::ops::Deref; use crate::{ArrowNativeType, MutableBuffer, ScalarBuffer}; +use std::ops::Deref; #[derive(Debug, Clone)] pub struct SizeBuffer(ScalarBuffer); impl SizeBuffer { - /// Create a new [`SizeBuffer`] containing `len` `0` values pub fn new_zeroed(len: usize) -> Self { let len_bytes = len.checked_mul(std::mem::size_of::()).expect("overflow"); @@ -54,8 +53,8 @@ impl SizeBuffer { /// assert_eq!(offsets.as_ref(), &[1, 3, 5]); /// ``` pub fn from_lengths(lengths: I) -> Self - where - I: IntoIterator, + where + I: IntoIterator, { let iter = lengths.into_iter(); let mut out = Vec::with_capacity(iter.size_hint().0); @@ -90,7 +89,6 @@ impl SizeBuffer { } } - impl Deref for SizeBuffer { type Target = [T]; diff --git a/arrow-data/src/data.rs b/arrow-data/src/data.rs index 0d832a453693..5c752459d1ab 100644 --- a/arrow-data/src/data.rs +++ b/arrow-data/src/data.rs @@ -948,7 +948,7 @@ impl ArrayData { &self, values_length: usize, ) -> Result<(), ArrowError> { - let sizes = self.typed_sizes::()?; + let sizes = self.typed_sizes::()?; if sizes.is_empty() { return Ok(()); } @@ -1702,13 +1702,16 @@ impl DataTypeLayout { /// Describes a list view type pub fn new_list_view() -> Self { Self { - buffers: vec![BufferSpec::FixedWidth { - byte_width: mem::size_of::(), - alignment: mem::align_of::(), - },BufferSpec::FixedWidth { - byte_width: mem::size_of::(), - alignment: mem::align_of::(), - }], + buffers: vec![ + BufferSpec::FixedWidth { + byte_width: mem::size_of::(), + alignment: mem::align_of::(), + }, + BufferSpec::FixedWidth { + byte_width: mem::size_of::(), + alignment: mem::align_of::(), + }, + ], can_contain_null_mask: true, variadic: true, } diff --git a/arrow-data/src/equal/list_view.rs b/arrow-data/src/equal/list_view.rs index 1b0dc6619d00..ffa3ff4e8d1c 100644 --- a/arrow-data/src/equal/list_view.rs +++ b/arrow-data/src/equal/list_view.rs @@ -15,10 +15,10 @@ // specific language governing permissions and limitations // under the License. -use num::Integer; -use arrow_buffer::ArrowNativeType; -use crate::ArrayData; use crate::data::count_nulls; +use crate::ArrayData; +use arrow_buffer::ArrowNativeType; +use num::Integer; use super::equal_range; @@ -34,7 +34,6 @@ pub(super) fn list_view_equal( let lhs_sizes = lhs.buffer::(1); let rhs_sizes = rhs.buffer::(1); for i in 0..len { - // compare offsets and sizes let lhs_pos = lhs_start + i; let rhs_pos = rhs_start + i; @@ -45,14 +44,12 @@ pub(super) fn list_view_equal( if lhs_size != rhs_size { return false; } - // compare nulls let lhs_null_count = count_nulls(lhs.nulls(), lhs_offset_start, lhs_size); let rhs_null_count = count_nulls(rhs.nulls(), rhs_offset_start, lhs_size); if lhs_null_count != rhs_null_count { return false; } - // compare values if !equal_range( &lhs.child_data()[0], diff --git a/arrow-data/src/equal/mod.rs b/arrow-data/src/equal/mod.rs index 0c721a595eb4..65bd6eea704c 100644 --- a/arrow-data/src/equal/mod.rs +++ b/arrow-data/src/equal/mod.rs @@ -20,6 +20,7 @@ //! depend on dynamic casting of `Array`. use crate::data::ArrayData; +use crate::equal::list_view::list_view_equal; use arrow_buffer::i256; use arrow_schema::{DataType, IntervalUnit}; use half::f16; @@ -30,6 +31,7 @@ mod dictionary; mod fixed_binary; mod fixed_list; mod list; +mod list_view; mod null; mod primitive; mod run; @@ -37,7 +39,6 @@ mod structure; mod union; mod utils; mod variable_size; -mod list_view; // these methods assume the same type, len and null count. // For this reason, they are not exposed and are instead used @@ -53,7 +54,6 @@ use primitive::primitive_equal; use structure::struct_equal; use union::union_equal; use variable_size::variable_sized_equal; -use crate::equal::list_view::list_view_equal; use self::run::run_equal;