pepijnve commented on code in PR #16322:
URL: https://github.com/apache/datafusion/pull/16322#discussion_r2137392057


##########
datafusion/physical-plan/src/sorts/merge.rs:
##########
@@ -216,36 +212,50 @@ impl<C: CursorValues> SortPreservingMergeStream<C> {
         // Once all partitions have set their corresponding cursors for the 
loser tree,
         // we skip the following block. Until then, this function may be 
called multiple
         // times and can return Poll::Pending if any partition returns 
Poll::Pending.
+
         if self.loser_tree.is_empty() {
-            while let Some(&partition_idx) = 
self.uninitiated_partitions.front() {
+            // Manual indexing since we're iterating over the vector and 
shrinking it in the loop
+            let mut idx = 0;
+            while idx < self.uninitiated_partitions.len() {

Review Comment:
   I'm not sure I understand what you mean. When some streams are not ready, 
this function will still return pending and will be called again when one of 
the streams wakes the task. So the loop can still be hit multiple times and the 
current code intentionally does not poll streams that have already returned 
ready.



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

Reply via email to