thinkharderdev commented on code in PR #5800:
URL: https://github.com/apache/arrow-datafusion/pull/5800#discussion_r1154681427
##########
datafusion/core/src/physical_plan/file_format/file_stream.rs:
##########
@@ -83,6 +83,11 @@ pub struct FileStream<F: FileOpener> {
baseline_metrics: BaselineMetrics,
}
+enum NextOpen {
+ Future(FileOpenFuture),
+ Reader(Result<BoxStream<'static, Result<RecordBatch, ArrowError>>>),
+}
Review Comment:
```suggestion
/// Represents the state of the next `FileOpenFuture`. Since we need to poll
/// this future while scanning the current file, we need to the result if it
/// is ready
enum NextOpen {
Pending(FileOpenFuture),
Ready(Result<BoxStream<'static, Result<RecordBatch, ArrowError>>>),
}
```
##########
datafusion/core/src/physical_plan/file_format/file_stream.rs:
##########
@@ -292,54 +300,75 @@ impl<F: FileOpener> FileStream<F> {
reader,
partition_values,
next,
- } => match ready!(reader.poll_next_unpin(cx)) {
- Some(result) => {
-
self.file_stream_metrics.time_scanning_until_data.stop();
- self.file_stream_metrics.time_scanning_total.stop();
- let result = result
- .and_then(|b| {
- self.pc_projector
- .project(b, partition_values)
- .map_err(|e|
ArrowError::ExternalError(e.into()))
- })
- .map(|batch| match &mut self.remain {
- Some(remain) => {
- if *remain > batch.num_rows() {
- *remain -= batch.num_rows();
- batch
- } else {
- let batch = batch.slice(0, *remain);
- self.state = FileStreamState::Limit;
- *remain = 0;
- batch
- }
- }
- None => batch,
- });
-
- if result.is_err() {
- self.state = FileStreamState::Error
+ } => {
+ if let Some((next_open_future, _)) = next {
+ if let NextOpen::Future(f) = next_open_future {
+ if let Poll::Ready(reader) = f.as_mut().poll(cx) {
+ *next_open_future = NextOpen::Reader(reader);
+ }
Review Comment:
```suggestion
// We need to poll the next `FileOpenFuture` here to
drive it forward
if let Some((next_open_future, _)) = next {
if let NextOpen::Future(f) = next_open_future {
if let Poll::Ready(reader) = f.as_mut().poll(cx)
{
*next_open_future = NextOpen::Reader(reader);
}
```
--
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]