diff --git a/arrow/src/array/data.rs b/arrow/src/array/data.rs index d2db0d0c8844..cbbc56a2456a 100644 --- a/arrow/src/array/data.rs +++ b/arrow/src/array/data.rs @@ -198,29 +198,6 @@ pub(crate) fn new_buffers(data_type: &DataType, capacity: usize) -> [MutableBuff } } -/// Ensures that at least `min_size` elements of type `data_type` can -/// be stored in a buffer of `buffer_size`. -/// -/// `buffer_index` is used in error messages to identify which buffer -/// had the invalid index -#[allow(dead_code)] -fn ensure_size( - data_type: &DataType, - min_size: usize, - buffer_size: usize, - buffer_index: usize, -) -> Result<()> { - // if min_size is zero, may not have buffers (e.g. NullArray) - if min_size > 0 && buffer_size < min_size { - Err(ArrowError::InvalidArgumentError(format!( - "Need at least {} bytes in buffers[{}] in array of type {:?}, but got {}", - buffer_size, buffer_index, data_type, min_size - ))) - } else { - Ok(()) - } -} - /// Maps 2 [`MutableBuffer`]s into a vector of [Buffer]s whose size depends on `data_type`. #[inline] pub(crate) fn into_buffers( diff --git a/arrow/src/compute/util.rs b/arrow/src/compute/util.rs index 3f168c13191e..62c3be62f55a 100644 --- a/arrow/src/compute/util.rs +++ b/arrow/src/compute/util.rs @@ -18,7 +18,7 @@ //! Common utilities for computation kernels. use crate::array::*; -use crate::buffer::{buffer_bin_and, buffer_bin_or, Buffer}; +use crate::buffer::{buffer_bin_and, Buffer}; use crate::datatypes::*; use crate::error::{ArrowError, Result}; use num::{One, ToPrimitive, Zero}; @@ -58,41 +58,6 @@ pub(super) fn combine_option_bitmap( } } -/// Compares the null bitmaps of two arrays using a bitwise `or` operation. -/// -/// This function is useful when implementing operations on higher level arrays. -#[allow(clippy::unnecessary_wraps)] -#[allow(dead_code)] -pub(super) fn compare_option_bitmap( - left_data: &ArrayData, - right_data: &ArrayData, - len_in_bits: usize, -) -> Result> { - let left_offset_in_bits = left_data.offset(); - let right_offset_in_bits = right_data.offset(); - - let left = left_data.null_buffer(); - let right = right_data.null_buffer(); - - match left { - None => match right { - None => Ok(None), - Some(r) => Ok(Some(r.bit_slice(right_offset_in_bits, len_in_bits))), - }, - Some(l) => match right { - None => Ok(Some(l.bit_slice(left_offset_in_bits, len_in_bits))), - - Some(r) => Ok(Some(buffer_bin_or( - l, - left_offset_in_bits, - r, - right_offset_in_bits, - len_in_bits, - ))), - }, - } -} - /// Takes/filters a list array's inner data using the offsets of the list array. /// /// Where a list array has indices `[0,2,5,10]`, taking indices of `[2,0]` returns @@ -176,10 +141,44 @@ pub(super) mod tests { use std::sync::Arc; + use crate::buffer::buffer_bin_or; use crate::datatypes::DataType; use crate::util::bit_util; use crate::{array::ArrayData, buffer::MutableBuffer}; + /// Compares the null bitmaps of two arrays using a bitwise `or` operation. + /// + /// This function is useful when implementing operations on higher level arrays. + pub(super) fn compare_option_bitmap( + left_data: &ArrayData, + right_data: &ArrayData, + len_in_bits: usize, + ) -> Result> { + let left_offset_in_bits = left_data.offset(); + let right_offset_in_bits = right_data.offset(); + + let left = left_data.null_buffer(); + let right = right_data.null_buffer(); + + match left { + None => match right { + None => Ok(None), + Some(r) => Ok(Some(r.bit_slice(right_offset_in_bits, len_in_bits))), + }, + Some(l) => match right { + None => Ok(Some(l.bit_slice(left_offset_in_bits, len_in_bits))), + + Some(r) => Ok(Some(buffer_bin_or( + l, + left_offset_in_bits, + r, + right_offset_in_bits, + len_in_bits, + ))), + }, + } + } + fn make_data_with_null_bit_buffer( len: usize, offset: usize, @@ -344,28 +343,6 @@ pub(super) mod tests { GenericListArray::::from(list_data) } - #[allow(dead_code)] - pub(crate) fn build_fixed_size_list( - data: Vec>>, - length: ::Native, - ) -> FixedSizeListArray - where - T: ArrowPrimitiveType, - PrimitiveArray: From>>, - { - let data = data - .into_iter() - .map(|subarray| { - subarray.map(|item| { - item.into_iter() - .map(Some) - .collect::>>() - }) - }) - .collect(); - build_fixed_size_list_nullable(data, length) - } - pub(crate) fn build_fixed_size_list_nullable( list_values: Vec>>>, length: ::Native,