zhuqi-lucas commented on code in PR #14499: URL: https://github.com/apache/datafusion/pull/14499#discussion_r1942554373
########## datafusion/physical-plan/src/stream.rs: ########## @@ -444,18 +444,44 @@ impl Stream for EmptyRecordBatchStream { pub(crate) struct ObservedStream { inner: SendableRecordBatchStream, baseline_metrics: BaselineMetrics, + fetch: Option<usize>, + produced: usize, } impl ObservedStream { pub fn new( inner: SendableRecordBatchStream, baseline_metrics: BaselineMetrics, + fetch: Option<usize>, ) -> Self { Self { inner, baseline_metrics, + fetch, + produced: 0, } } + + fn limit_reached( Review Comment: We may can add a follow-up to reuse LimitStream which is used by SortPreservingMergeExec ```rust impl Stream for LimitStream { type Item = Result<RecordBatch>; fn poll_next( mut self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Self::Item>> { let fetch_started = self.skip == 0; let poll = match &mut self.input { Some(input) => { let poll = if fetch_started { input.poll_next_unpin(cx) } else { self.poll_and_skip(cx) }; poll.map(|x| match x { Some(Ok(batch)) => Ok(self.stream_limit(batch)).transpose(), other => other, }) } // Input has been cleared None => Poll::Ready(None), }; self.baseline_metrics.record_poll(poll) } } ``` -- 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