From 1dbb7b3a471a0972db17b0ddbd3e973ca6714dc6 Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Sat, 22 Oct 2022 21:05:28 -0700 Subject: [PATCH] Provide freeze_with_dictionary API --- arrow-data/src/transform/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arrow-data/src/transform/mod.rs b/arrow-data/src/transform/mod.rs index c34376aaba29..31a3729d26b6 100644 --- a/arrow-data/src/transform/mod.rs +++ b/arrow-data/src/transform/mod.rs @@ -637,6 +637,18 @@ impl<'a> MutableArrayData<'a> { unsafe { self.data.freeze(self.dictionary).build_unchecked() } } + /// Creates a [ArrayData] from the pushed regions up to this point, consuming `self`, + /// with the provided dictionary values `ArrayData`, without any validation + /// + /// # Safety + /// + /// As this doesn't validate the provided dictionary `ArrayData` values, the input + /// dictionary values *must* form a valid Arrow dictionary array, or undefined behavior + /// can results. + pub unsafe fn freeze_with_dictionary(self, dictionary: ArrayData) -> ArrayData { + self.data.freeze(Some(dictionary)).build_unchecked() + } + /// Creates a [ArrayDataBuilder] from the pushed regions up to this point, consuming `self`. /// This is useful for extending the default behavior of MutableArrayData. pub fn into_builder(self) -> ArrayDataBuilder {