Dandandan commented on code in PR #17528: URL: https://github.com/apache/datafusion/pull/17528#discussion_r2346850435
########## datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs: ########## @@ -870,9 +879,11 @@ impl SortedSearch { cur_window_expr_out_result_len }); argmin(out_col_counts).map_or(0, |(min_idx, minima)| { - for (row, count) in counts.swap_remove(min_idx).into_iter() { - let partition_batch = &mut partition_buffers[row]; - partition_batch.n_out_row = count; + let mut counts = counts.swap_remove(min_idx); + for (partition_key, partition_batch) in partition_buffers.iter_mut() { + if let Some(count) = counts.remove(partition_key) { Review Comment: Isn't this `O(n^2)` ########## datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs: ########## @@ -870,9 +879,11 @@ impl SortedSearch { cur_window_expr_out_result_len }); argmin(out_col_counts).map_or(0, |(min_idx, minima)| { - for (row, count) in counts.swap_remove(min_idx).into_iter() { - let partition_batch = &mut partition_buffers[row]; - partition_batch.n_out_row = count; + let mut counts = counts.swap_remove(min_idx); + for (partition_key, partition_batch) in partition_buffers.iter_mut() { + if let Some(count) = counts.remove(partition_key) { Review Comment: Isn't this `O(n^2)`? -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org