comphead opened a new pull request, #26251:
URL: https://github.com/apache/datafusion/pull/26251

   ## Which issue does this PR close?
   
   - N/A
   
   ## Rationale for this change
   
   A few iterator chains do more work than needed. Some build an intermediate 
`Vec` only to iterate it again, some use several adaptors where one would do, 
and some reimplement `rfind`, `rposition`, `last` or `to_vec` by hand. Each 
case is small, but the simpler forms avoid allocations and clones and are 
easier to read.
   
   ## What changes are included in this PR?
   
   - `invariants.rs`: a `map`, `collect::<Result<Vec>>`, `into_iter`, `flatten` 
chain becomes one `flat_map` over `column_refs()`. Columns are no longer cloned.
   - `window_agg_exec.rs`: drop a 
`collect::<Vec<_>>().into_iter().collect::<Result<_>>()` round trip.
   - `sql/utils.rs`: `take_while`, `to_owned`, `cloned` and `map(unwrap)` 
become a single `map_while`.
   - `sql/statement.rs`: `iter().last()` becomes `last()`. `rev().position()` 
with manual index math becomes `rposition`.
   - `aggregates/mod.rs`: merge two consecutive `filter` calls.
   - `bytes_view.rs`: `iter().rev().find()` becomes `rfind()`.
   - `information_schema.rs` and `ffi/config/mod.rs`: fuse `filter_map` 
followed by `map`.
   - `file_scan_config/proto.rs`: `iter().cloned().collect::<Vec<_>>()` becomes 
`to_vec()`.
   
   ## What is the testing strategy for this PR?
   
   No behavior change, so existing tests cover it. Passed locally:
   - `cargo fmt --all` and `cargo clippy -D warnings` on the touched crates.
   - Lib and integration tests for `datafusion-sql`, `datafusion-expr`, 
`datafusion-ffi`, `datafusion-datasource`, and the `datafusion-physical-plan` 
lib tests.
   - sqllogictests matching `information_schema`, `window` and `aggregate`.
   
   I did not run the full workspace suite or any benchmarks.
   
   ## Are there any user-facing changes?
   
   No.
   


-- 
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]

Reply via email to