This is an automated email from the ASF dual-hosted git repository.

alamb 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 827be42280 Avoid a clone when creating `FixedSizeBinaryArray` from 
ArrayData (#9186)
827be42280 is described below

commit 827be422809d88af4d75b381c18dbf361769352b
Author: Andrew Lamb <[email protected]>
AuthorDate: Wed Jan 21 10:25:56 2026 -0500

    Avoid a clone when creating `FixedSizeBinaryArray` from ArrayData (#9186)
    
    # 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/fixed_size_binary_array.rs | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/arrow-array/src/array/fixed_size_binary_array.rs 
b/arrow-array/src/array/fixed_size_binary_array.rs
index b94e168cfe..f736d1f1eb 100644
--- a/arrow-array/src/array/fixed_size_binary_array.rs
+++ b/arrow-array/src/array/fixed_size_binary_array.rs
@@ -497,24 +497,25 @@ impl FixedSizeBinaryArray {
 
 impl From<ArrayData> for FixedSizeBinaryArray {
     fn from(data: ArrayData) -> Self {
+        let (data_type, len, nulls, offset, buffers, _child_data) = 
data.into_parts();
+
         assert_eq!(
-            data.buffers().len(),
+            buffers.len(),
             1,
             "FixedSizeBinaryArray data should contain 1 buffer only (values)"
         );
-        let value_length = match data.data_type() {
-            DataType::FixedSizeBinary(len) => *len,
+        let value_length = match data_type {
+            DataType::FixedSizeBinary(len) => len,
             _ => panic!("Expected data type to be FixedSizeBinary"),
         };
 
         let size = value_length as usize;
-        let value_data =
-            data.buffers()[0].slice_with_length(data.offset() * size, 
data.len() * size);
+        let value_data = buffers[0].slice_with_length(offset * size, len * 
size);
 
         Self {
-            data_type: data.data_type().clone(),
-            nulls: data.nulls().cloned(),
-            len: data.len(),
+            data_type,
+            nulls,
+            len,
             value_data,
             value_length,
         }

Reply via email to