zhuqi-lucas commented on code in PR #16196: URL: https://github.com/apache/datafusion/pull/16196#discussion_r2115086432
########## datafusion/physical-plan/src/aggregates/no_grouping.rs: ########## @@ -77,6 +77,9 @@ impl AggregateStream { let baseline_metrics = BaselineMetrics::new(&agg.metrics, partition); let input = agg.input.execute(partition, Arc::clone(&context))?; + // Wrap no‐grouping aggregates in our YieldStream Review Comment: Thank you @alamb , good suggestion, addressed it in latest PR. ########## datafusion/physical-plan/src/aggregates/no_grouping.rs: ########## @@ -170,6 +173,65 @@ impl AggregateStream { } } +/// A stream that yields batches of data, yielding control back to the executor Review Comment: Thank you @alamb , good suggestion, addressed it in latest PR. ########## datafusion/physical-plan/src/aggregates/no_grouping.rs: ########## @@ -170,6 +173,65 @@ impl AggregateStream { } } +/// A stream that yields batches of data, yielding control back to the executor +pub struct YieldStream { + inner: SendableRecordBatchStream, + batches_processed: usize, + buffer: Option<Result<RecordBatch>>, +} + +impl YieldStream { + pub fn new(inner: SendableRecordBatchStream) -> Self { + Self { + inner, + batches_processed: 0, + buffer: None, + } + } +} + +// Stream<Item = Result<RecordBatch>> to poll_next_unpin +impl Stream for YieldStream { + type Item = Result<RecordBatch>; + + fn poll_next( + mut self: std::pin::Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll<Option<Self::Item>> { + const YIELD_BATCHES: usize = 64; Review Comment: Thank you @alamb , good suggestion, addressed it in latest PR. -- 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