You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by dh...@apache.org on 2026/01/14 12:28:39 UTC
(arrow-rs) branch main updated: Avoid a clone when creating `BooleanArray` from ArrayData (#9159)
This is an automated email from the ASF dual-hosted git repository.
dheres pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 1295fea44a Avoid a clone when creating `BooleanArray` from ArrayData (#9159)
1295fea44a is described below
commit 1295fea44a8ab5901a85b0ec6ff695e4c49b9b71
Author: Andrew Lamb <an...@nerdnetworks.org>
AuthorDate: Wed Jan 14 07:28:34 2026 -0500
Avoid a clone when creating `BooleanArray` from ArrayData (#9159)
# Which issue does this PR close?
- Part of https://github.com/apache/arrow-rs/issues/9061
- broken out of https://github.com/apache/arrow-rs/pull/9058
# Rationale for this change
Let's make arrow-rs the fastest we can and the fewer allocations the
better
# What changes are included in this PR?
Apply pattern from https://github.com/apache/arrow-rs/pull/9114
# Are these changes tested?
Existing tests
# Are there any user-facing changes?
No
---
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 acea680ae3..6419837003 100644
--- a/arrow-array/src/array/boolean_array.rs
+++ b/arrow-array/src/array/boolean_array.rs
@@ -389,24 +389,21 @@ impl From<Vec<Option<bool>>> for BooleanArray {
impl From<ArrayData> 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 }
}
}