From 1d6ddc2a76483a6e7fc9b2c632f471a94f0e4f59 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Tue, 13 Jan 2026 10:42:37 -0500 Subject: [PATCH] Avoid a clone when creating BooleanArray from ArrayData --- arrow-array/src/array/boolean_array.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/arrow-array/src/array/boolean_array.rs b/arrow-array/src/array/boolean_array.rs index acea680ae374..641983700334 100644 --- a/arrow-array/src/array/boolean_array.rs +++ b/arrow-array/src/array/boolean_array.rs @@ -389,24 +389,21 @@ impl From>> for BooleanArray { impl From for BooleanArray { fn from(data: ArrayData) -> Self { + let (data_type, len, nulls, offset, mut buffers, _child_data) = data.into_parts(); assert_eq!( - data.data_type(), - &DataType::Boolean, - "BooleanArray expected ArrayData with type {} got {}", + data_type, DataType::Boolean, - data.data_type() + "BooleanArray expected ArrayData with type Boolean got {data_type:?}", ); assert_eq!( - data.buffers().len(), + buffers.len(), 1, "BooleanArray data should contain a single buffer only (values buffer)" ); - let values = BooleanBuffer::new(data.buffers()[0].clone(), data.offset(), data.len()); + let buffer = buffers.pop().expect("checked above"); + let values = BooleanBuffer::new(buffer, offset, len); - Self { - values, - nulls: data.nulls().cloned(), - } + Self { values, nulls } } }