From 7a9bf3aef44fa985bebf09b9bc97bbd9bb2bdb5f Mon Sep 17 00:00:00 2001 From: Raphael Taylor-Davies Date: Thu, 13 Apr 2023 17:30:23 +0100 Subject: [PATCH] Add new_unchecked --- arrow-array/src/array/byte_array.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arrow-array/src/array/byte_array.rs b/arrow-array/src/array/byte_array.rs index ffabb6e174f5..662490c9dda0 100644 --- a/arrow-array/src/array/byte_array.rs +++ b/arrow-array/src/array/byte_array.rs @@ -106,6 +106,24 @@ impl GenericByteArray { }) } + /// Create a new [`GenericByteArray`] from the provided parts, without validation + /// + /// # Safety + /// + /// Safe if [`Self::try_new`] would not error + pub fn new_unchecked( + offsets: OffsetBuffer, + values: Buffer, + nulls: Option, + ) -> Self { + Self { + data_type: T::DATA_TYPE, + value_offsets: offsets, + value_data: values, + nulls, + } + } + /// Create a new [`GenericByteArray`] of length `len` where all values are null pub fn new_null(len: usize) -> Self { Self {