diff --git a/arrow/src/array/array_boolean.rs b/arrow/src/array/array_boolean.rs index 90de4cdd9d2..824f7c0832c 100644 --- a/arrow/src/array/array_boolean.rs +++ b/arrow/src/array/array_boolean.rs @@ -22,6 +22,7 @@ use std::{any::Any, fmt}; use super::*; use super::{array::print_long_array, raw_pointer::RawPtrBox}; +use crate::bitmap::Bitmap; use crate::buffer::{Buffer, MutableBuffer}; use crate::util::bit_util; @@ -109,6 +110,12 @@ impl BooleanArray { debug_assert!(i < self.len()); unsafe { self.value_unchecked(i) } } + + /// Returns (_, _, offset, length) + pub fn into_parts(self) -> (Buffer, Option, usize, usize) { + let data = self.data; + data.into_1_dimensional_parts() + } } impl Array for BooleanArray { diff --git a/arrow/src/array/array_primitive.rs b/arrow/src/array/array_primitive.rs index 7f220f7724a..79919e41c21 100644 --- a/arrow/src/array/array_primitive.rs +++ b/arrow/src/array/array_primitive.rs @@ -146,6 +146,10 @@ impl PrimitiveArray { ); PrimitiveArray::from(data) } + + pub fn into_data(self) -> ArrayData { + self.data + } } impl Array for PrimitiveArray { diff --git a/arrow/src/array/data.rs b/arrow/src/array/data.rs index 2c957d29077..41ae6fc29f4 100644 --- a/arrow/src/array/data.rs +++ b/arrow/src/array/data.rs @@ -478,6 +478,15 @@ impl ArrayData { Self::new(data_type.clone(), 0, Some(0), None, 0, buffers, child_data) } + + pub fn into_1_dimensional_parts(self) -> (Buffer, Option, usize, usize) { + let offset: usize = self.offset; + let length: usize = self.len; + let buffers: Vec = self.buffers; + let bitmap: Option = self.null_bitmap; + let buffer0: Buffer = buffers.into_iter().next().unwrap(); + (buffer0, bitmap, offset, length) + } } impl PartialEq for ArrayData {