alamb commented on code in PR #19002:
URL: https://github.com/apache/datafusion/pull/19002#discussion_r2600227695


##########
datafusion/physical-plan/src/repartition/mod.rs:
##########
@@ -1531,6 +1542,46 @@ impl PerPartitionStream {
             }
         }
     }
+
+    fn poll_next_and_coalesce(
+        self: &mut Pin<&mut Self>,
+        cx: &mut Context<'_>,
+        coalescer: &mut LimitedBatchCoalescer,
+    ) -> Poll<Option<Result<RecordBatch>>> {
+        let cloned_time = self.baseline_metrics.elapsed_compute().clone();
+        let mut completed = false;
+
+        loop {
+            if let Some(batch) = coalescer.next_completed_batch() {
+                return Poll::Ready(Some(Ok(batch)));
+            }
+            if completed {
+                return Poll::Ready(None);
+            }
+            let inner_poll = self.poll_next_inner(cx);
+            let _timer = cloned_time.timer();
+
+            match inner_poll {

Review Comment:
   FWIW I think we can use the `ready` macro here to reduce some of this boiler 
plate -- https://docs.rs/futures/latest/futures/macro.ready.html
   
   So like 
   ```rust
   match ready!(inner_poll) {
     None => ..
     Some(...) => ...
   }
   ```
   
   (ready handles the `return Poll::Pending` stuff)



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