lyne7-sc opened a new pull request, #19996: URL: https://github.com/apache/datafusion/pull/19996
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Part of https://github.com/apache/datafusion-comet/issues/2986 ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> The current implementation of `general_remove` is based on `filter + concat`, which creates intermediate arrays for each list row and can be relatively expensive. This PR introduces an alternative implementation based on `MutableArrayData`, which copies contiguous ranges from the original values buffer directly into the output array. The new approach is semantically equivalent to the existing implementation but reduces intermediate allocations and per-element overhead. ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> - Replaced `general_remove`'s filter-based implementation with `MutableArrayData` for more efficient memory usage. - Optimized the removal process by adding fast paths for rows where no matching elements need removal. ### Benchmark ``` group after before ----- ----- ------ array_remove_binary/remove/10 1.00 4.6±0.14ms ? ?/sec 2.41 11.0±0.34ms ? ?/sec array_remove_binary/remove/100 1.00 8.5±0.19ms ? ?/sec 1.95 16.6±0.42ms ? ?/sec array_remove_binary/remove/500 1.00 35.9±0.78ms ? ?/sec 1.43 51.4±1.10ms ? ?/sec array_remove_boolean/remove/10 1.00 3.7±0.05ms ? ?/sec 3.23 11.8±0.30ms ? ?/sec array_remove_boolean/remove/100 1.00 8.1±0.15ms ? ?/sec 2.18 17.6±0.35ms ? ?/sec array_remove_boolean/remove/500 1.00 26.6±0.43ms ? ?/sec 1.52 40.3±0.81ms ? ?/sec array_remove_decimal64/remove/10 1.00 3.9±0.07ms ? ?/sec 2.41 9.4±0.18ms ? ?/sec array_remove_decimal64/remove/100 1.00 6.7±0.19ms ? ?/sec 2.12 14.2±0.34ms ? ?/sec array_remove_decimal64/remove/500 1.00 40.3±0.75ms ? ?/sec 1.52 61.1±1.46ms ? ?/sec array_remove_f64/remove/10 1.00 3.8±0.10ms ? ?/sec 1.32 5.0±0.16ms ? ?/sec array_remove_f64/remove/100 1.00 4.8±0.34ms ? ?/sec 1.24 5.9±0.18ms ? ?/sec array_remove_f64/remove/500 1.00 22.3±0.68ms ? ?/sec 1.15 25.5±0.86ms ? ?/sec array_remove_fixed_size_binary/remove/10 1.00 4.7±0.09ms ? ?/sec 1.52 7.2±0.26ms ? ?/sec array_remove_fixed_size_binary/remove/100 1.00 8.0±0.32ms ? ?/sec 1.40 11.1±0.40ms ? ?/sec array_remove_fixed_size_binary/remove/500 1.00 45.4±0.97ms ? ?/sec 1.16 52.6±1.43ms ? ?/sec array_remove_int64/remove/10 1.00 3.9±0.11ms ? ?/sec 2.24 8.8±0.24ms ? ?/sec array_remove_int64/remove/100 1.00 5.5±0.18ms ? ?/sec 2.32 12.8±0.44ms ? ?/sec array_remove_int64/remove/500 1.00 25.5±1.06ms ? ?/sec 1.61 40.9±1.25ms ? ?/sec array_remove_strings/remove/10 1.00 4.5±0.10ms ? ?/sec 2.41 10.9±0.28ms ? ?/sec array_remove_strings/remove/100 1.00 8.5±0.37ms ? ?/sec 2.00 17.0±0.71ms ? ?/sec array_remove_strings/remove/500 1.00 35.9±0.84ms ? ?/sec 1.48 53.1±1.91ms ? ?/sec ``` ## Are these changes tested? Yes. Existing SLT for `array` continue to pass without modification. Benchmarks were added. <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> ## Are there any user-facing changes? No. <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
