From 500377b8e70744a57b26cb279ec1dab2f8a366bb Mon Sep 17 00:00:00 2001 From: Raphael Taylor-Davies Date: Mon, 3 Apr 2023 11:36:24 +0100 Subject: [PATCH] Deprecate combine_option_bitmap --- arrow-data/src/bit_mask.rs | 3 +++ arrow-string/src/concat_elements.rs | 14 ++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/arrow-data/src/bit_mask.rs b/arrow-data/src/bit_mask.rs index 94ea57259ac8..d978f2b74618 100644 --- a/arrow-data/src/bit_mask.rs +++ b/arrow-data/src/bit_mask.rs @@ -68,6 +68,7 @@ pub fn set_bits( /// Combines the null bitmaps of multiple arrays using a bitwise `and` operation. /// /// This function is useful when implementing operations on higher level arrays. +#[deprecated(note = "Use NullBuffer::union")] pub fn combine_option_bitmap( arrays: &[&ArrayData], len_in_bits: usize, @@ -247,6 +248,7 @@ mod tests { } #[test] + #[allow(deprecated)] fn test_combine_option_bitmap() { let none_bitmap = make_data_with_null_bit_buffer(8, 0, None); let some_bitmap = @@ -298,6 +300,7 @@ mod tests { } #[test] + #[allow(deprecated)] fn test_combine_option_bitmap_with_offsets() { let none_bitmap = make_data_with_null_bit_buffer(8, 0, None); let bitmap0 = diff --git a/arrow-string/src/concat_elements.rs b/arrow-string/src/concat_elements.rs index 4da9e2539e7e..a6e02d04dd3f 100644 --- a/arrow-string/src/concat_elements.rs +++ b/arrow-string/src/concat_elements.rs @@ -21,7 +21,6 @@ use arrow_array::builder::BufferBuilder; use arrow_array::types::ByteArrayType; use arrow_array::*; use arrow_buffer::{ArrowNativeType, NullBuffer}; -use arrow_data::bit_mask::combine_option_bitmap; use arrow_data::ArrayDataBuilder; use arrow_schema::{ArrowError, DataType}; @@ -125,14 +124,9 @@ pub fn concat_elements_utf8_many( ))); } - let output_bitmap = combine_option_bitmap( - arrays - .iter() - .map(|a| a.data()) - .collect::>() - .as_slice(), - size, - ); + let nulls = arrays + .iter() + .fold(None, |acc, a| NullBuffer::union(acc.as_ref(), a.nulls())); let data_values = arrays .iter() @@ -170,7 +164,7 @@ pub fn concat_elements_utf8_many( .len(size) .add_buffer(output_offsets.finish()) .add_buffer(output_values.finish()) - .null_bit_buffer(output_bitmap); + .nulls(nulls); // SAFETY - offsets valid by construction Ok(unsafe { builder.build_unchecked() }.into())