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 73dbd557b6 Allocate a zeroed buffer for FixedSizeBinaryArray::null 
(#8901)
73dbd557b6 is described below

commit 73dbd557b60d35782bcd1bc31d8ea52b9420fc05
Author: Tobias Schwarzinger <[email protected]>
AuthorDate: Sat Nov 22 13:42:50 2025 +0100

    Allocate a zeroed buffer for FixedSizeBinaryArray::null (#8901)
    
    # Which issue does this PR close?
    
    - Closes #8900 .
    
    # Rationale for this change
    
    This causes the values buffer to have the expected length after creating
    the null array.
    
    # What changes are included in this PR?
    
    Use `MutableBuffer::new_null` instead of `MutableBuffer::new`
    
    # Are these changes tested?
    
    Yes, additional constructor test
    
    # Are there any user-facing changes?
    
    Yes, the buffer will now be correctly initialized when calling
    `FixedSizeBinaryArray::new_null`
---
 arrow-array/src/array/fixed_size_binary_array.rs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arrow-array/src/array/fixed_size_binary_array.rs 
b/arrow-array/src/array/fixed_size_binary_array.rs
index 9507fc556b..95f47a423a 100644
--- a/arrow-array/src/array/fixed_size_binary_array.rs
+++ b/arrow-array/src/array/fixed_size_binary_array.rs
@@ -119,10 +119,10 @@ impl FixedSizeBinaryArray {
     /// * `size < 0`
     /// * `size * len` would overflow `usize`
     pub fn new_null(size: i32, len: usize) -> Self {
-        let capacity = size.to_usize().unwrap().checked_mul(len).unwrap();
+        let capacity_in_bytes = 
size.to_usize().unwrap().checked_mul(len).unwrap();
         Self {
             data_type: DataType::FixedSizeBinary(size),
-            value_data: MutableBuffer::new(capacity).into(),
+            value_data: MutableBuffer::new_null(capacity_in_bytes * 8).into(),
             nulls: Some(NullBuffer::new_null(len)),
             value_length: size,
             len,
@@ -983,6 +983,10 @@ mod tests {
         let nulls = NullBuffer::new_null(5);
         FixedSizeBinaryArray::new(2, buffer.clone(), Some(nulls));
 
+        let null_array = FixedSizeBinaryArray::new_null(4, 3);
+        assert_eq!(null_array.len(), 3);
+        assert_eq!(null_array.values().len(), 12);
+
         let a = FixedSizeBinaryArray::new(3, buffer.clone(), None);
         assert_eq!(a.len(), 3);
 

Reply via email to