akupchinskiy commented on code in PR #27047:
URL: https://github.com/apache/datafusion/pull/27047#discussion_r4739364027


##########
datafusion/functions-aggregate/src/first_last.rs:
##########
@@ -760,19 +733,14 @@ impl<S: ValueState> FirstLastGroupsAccumulator<S> {
             self.extreme_of_each_group_buf.0[group_idx] = idx_in_val;
         }
 
-        let mut ordering_buf = Vec::with_capacity(self.ordering_req.len());
-        // Take the buffer to appease the borrow checker; `update_state`
+        // Take the buffer to appease the borrow checker; `update_winners`
         // needs `&mut self`.
         let touched = std::mem::take(&mut self.touched_groups_buf);
-        for &group_idx in &touched {
-            let idx = self.extreme_of_each_group_buf.0[group_idx];
-            extract_row_at_idx_to_buf(
-                &values_and_order_cols[1..],
-                idx,
-                &mut ordering_buf,
-            )?;
-            self.update_state(group_idx, &ordering_buf, vals, idx)?;
-        }
+        let winners: Vec<(usize, usize)> = touched
+            .iter()
+            .map(|&g| (g, self.extreme_of_each_group_buf.0[g]))
+            .collect();
+        self.update_winners(&values_and_order_cols[1..], vals, &winners, 
true)?;

Review Comment:
   Done in 766e59a4d6: `Update::{Always, IfEarlier, IfLater}`.



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