mbutrovich opened a new pull request, #9692: URL: https://github.com/apache/arrow-rs/pull/9692
# Which issue does this PR close? - Closes #NNN. # Rationale for this change Several DataFusion PRs ([#21464](https://github.com/apache/datafusion/pull/21464), [#21468](https://github.com/apache/datafusion/pull/21468), [#21471](https://github.com/apache/datafusion/pull/21471), [#21475](https://github.com/apache/datafusion/pull/21475), [#21477](https://github.com/apache/datafusion/pull/21477), [#21482](https://github.com/apache/datafusion/pull/21482), [#21532](https://github.com/apache/datafusion/pull/21532)) optimize NULL handling in scalar functions by replacing row-by-row null buffer construction with bulk `NullBuffer::union`. When 3+ null buffers need combining, they chain binary `union` calls, each allocating a new `BooleanBuffer`. For N inputs this means N-1 allocations. `NullBuffer::union_many` reduces this to 1 allocation (clone + in-place ANDs). For example, from [#21482](https://github.com/apache/datafusion/pull/21482): Before: ```rust [array.nulls(), from_array.nulls(), to_array.nulls(), stride.and_then(|s| s.nulls())] .into_iter() .fold(None, |acc, nulls| NullBuffer::union(acc.as_ref(), nulls)) ``` After: ```rust NullBuffer::union_many(&[ array.nulls(), from_array.nulls(), to_array.nulls(), stride.and_then(|s| s.nulls()), ]) ``` # What changes are included in this PR? - `BooleanBuffer::bitand_many(&[&BooleanBuffer])`: bitwise AND of multiple buffers (1 clone + N-2 in-place ANDs = 1 allocation). - `NullBuffer::union_many(&[Option<&NullBuffer>])`: thin wrapper that filters `None`s and delegates to `bitand_many`. # Are these changes tested? Yes. 3 tests for `bitand_many`, 6 tests for `union_many`. # Are there any user-facing changes? Two new public methods on `BooleanBuffer` and `NullBuffer`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
