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

github-merge-queue[bot] 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 6b34163d51 chore: reuse allocations in partition (#11324)
6b34163d51 is described below

commit 6b34163d51aa59f7cac2edcb74e8bd1ddc6b9120
Author: Raz Luvaton <[email protected]>
AuthorDate: Tue Oct 6 15:54:40 2026 +0000

    chore: reuse allocations in partition (#11324)
    
    # Which issue does this PR close?
    
    None
    
    # Rationale for this change
    
    No need to add extra allocation of the boolean buffer, we can reuse the
    existing one
    
    # What changes are included in this PR?
    changed partition to use mutable bit ops
    
    # Are these changes tested?
    Existing tests
    
    # Are there any user-facing changes?
    No
---
 arrow-ord/src/partition.rs | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arrow-ord/src/partition.rs b/arrow-ord/src/partition.rs
index eab0d874fd..cc9c30f6c7 100644
--- a/arrow-ord/src/partition.rs
+++ b/arrow-ord/src/partition.rs
@@ -143,10 +143,14 @@ pub fn partition(columns: &[ArrayRef]) -> 
Result<Partitions, ArrowError> {
     }
 
     let acc = find_boundaries(&columns[0])?;
-    let acc = columns
-        .iter()
-        .skip(1)
-        .try_fold(acc, |acc, c| find_boundaries(c.as_ref()).map(|b| &acc | 
&b))?;
+    let acc = columns.iter().skip(1).try_fold(acc, |mut acc, c| {
+        find_boundaries(c.as_ref()).map(|b| {
+            // Do OrAssign to try to reuse the existing buffer if possible
+            acc |= &b;
+
+            acc
+        })
+    })?;
 
     Ok(Partitions(Some(acc)))
 }

Reply via email to