You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ne...@apache.org on 2022/02/19 15:58:01 UTC
[arrow-rs] branch master updated: Cleanup: remove some dead / test only code (#1331)
This is an automated email from the ASF dual-hosted git repository.
nevime pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new c0351f8 Cleanup: remove some dead / test only code (#1331)
c0351f8 is described below
commit c0351f84e61172f8403c468868919ec01538ce09
Author: Andrew Lamb <an...@nerdnetworks.org>
AuthorDate: Sat Feb 19 10:57:52 2022 -0500
Cleanup: remove some dead / test only code (#1331)
---
arrow/src/array/data.rs | 23 ------------
arrow/src/compute/util.rs | 93 ++++++++++++++++++-----------------------------
2 files changed, 35 insertions(+), 81 deletions(-)
diff --git a/arrow/src/array/data.rs b/arrow/src/array/data.rs
index d2db0d0..cbbc56a 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 3f168c1..62c3be6 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<Option<Buffer>> {
- 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<Option<Buffer>> {
+ 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::<S>::from(list_data)
}
- #[allow(dead_code)]
- pub(crate) fn build_fixed_size_list<T>(
- data: Vec<Option<Vec<T::Native>>>,
- length: <Int32Type as ArrowPrimitiveType>::Native,
- ) -> FixedSizeListArray
- where
- T: ArrowPrimitiveType,
- PrimitiveArray<T>: From<Vec<Option<T::Native>>>,
- {
- let data = data
- .into_iter()
- .map(|subarray| {
- subarray.map(|item| {
- item.into_iter()
- .map(Some)
- .collect::<Vec<Option<T::Native>>>()
- })
- })
- .collect();
- build_fixed_size_list_nullable(data, length)
- }
-
pub(crate) fn build_fixed_size_list_nullable<T>(
list_values: Vec<Option<Vec<Option<T::Native>>>>,
length: <Int32Type as ArrowPrimitiveType>::Native,