alamb commented on a change in pull request #9926:
URL: https://github.com/apache/arrow/pull/9926#discussion_r608763472
##########
File path: rust/datafusion/src/physical_plan/limit.rs
##########
@@ -200,30 +200,39 @@ pub fn truncate_batch(batch: &RecordBatch, n: usize) ->
RecordBatch {
/// A Limit stream limits the stream to up to `limit` rows.
struct LimitStream {
+ /// The maximum number of rows to produce
limit: usize,
- input: SendableRecordBatchStream,
- // the current count
+ /// The input to read from. This is set to None once the limit is
+ /// reached to enable early termination
Review comment:
```suggestion
/// reached so the input's resources can be `drop`ed (released)
/// without waiting until the entire plan's execution is complete
```
##########
File path: rust/datafusion/src/physical_plan/limit.rs
##########
@@ -236,23 +245,29 @@ impl Stream for LimitStream {
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Option<Self::Item>> {
- self.input.poll_next_unpin(cx).map(|x| match x {
- Some(Ok(batch)) => Ok(self.stream_limit(batch)).transpose(),
- other => other,
- })
+ match &mut self.input {
Review comment:
> Isn't a SendableRecordBatchStream a small struct?
It is a trait, so there are various things that implement it. Some, like the
`ParquetStream`
https://github.com/apache/arrow/blob/b6982df45dfd0cebf2b34deaec62801f87242bc5/rust/datafusion/src/physical_plan/parquet.rs#L876,
could have substantial resources
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]