diff --git a/src/array/binary/mod.rs b/src/array/binary/mod.rs index 7247decb30..b51dde2852 100644 --- a/src/array/binary/mod.rs +++ b/src/array/binary/mod.rs @@ -221,6 +221,16 @@ impl BinaryArray { impl_mut_validity!(); impl_into_array!(); + /// Returns an option of a mutable reference to the values of this [`BinaryArray`]. + pub fn get_mut_values(&mut self) -> Option<&mut [u8]> { + self.values.get_mut_slice() + } + + /// Returns an option of a mutable reference to the values of this [`BinaryArray`]. + pub fn get_mut_offsets(&mut self) -> Option<&mut [O]> { + self.offsets.get_mut_slice() + } + /// Returns its internal representation #[must_use] pub fn into_inner(self) -> (DataType, OffsetsBuffer, Buffer, Option) { diff --git a/src/array/utf8/mod.rs b/src/array/utf8/mod.rs index 9440ae4330..261768ff52 100644 --- a/src/array/utf8/mod.rs +++ b/src/array/utf8/mod.rs @@ -240,6 +240,16 @@ impl Utf8Array { impl_mut_validity!(); impl_into_array!(); + /// Returns an option of a mutable reference to the values of this [`Utf8Array`]. + pub fn get_mut_values(&mut self) -> Option<&mut [u8]> { + self.values.get_mut_slice() + } + + /// Returns an option of a mutable reference to the values of this [`Utf8Array`]. + pub fn get_mut_offsets(&mut self) -> Option<&mut [O]> { + self.offsets.get_mut_slice() + } + /// Returns its internal representation #[must_use] pub fn into_inner(self) -> (DataType, OffsetsBuffer, Buffer, Option) { diff --git a/src/offset.rs b/src/offset.rs index 80b45d6680..8fa71d5c14 100644 --- a/src/offset.rs +++ b/src/offset.rs @@ -371,6 +371,16 @@ impl OffsetsBuffer { .map_left(Self) } + /// Returns a mutable reference to its slice, if possible. + /// + /// This operation returns [`Some`] iff this [`OffsetsBuffer`]: + /// * has not been cloned (i.e. [`Arc`]`::get_mut` yields [`Some`]) + /// * has not been imported from the c data interface (FFI) + #[inline] + pub fn get_mut_slice(&mut self) -> Option<&mut [O]> { + self.0.get_mut_slice() + } + /// Returns a reference to its internal [`Buffer`]. #[inline] pub fn buffer(&self) -> &Buffer {