alexanderbianchi commented on code in PR #124:
URL:
https://github.com/apache/datafusion-iceberg/pull/124#discussion_r4637122280
##########
crates/datafusion/src/read/scan.rs:
##########
@@ -240,12 +243,32 @@ impl DataSource for IcebergDataSource {
task_context: &context,
},
)?;
+ let files_opened = MetricBuilder::new(&self.metrics)
+ .with_category(MetricCategory::Rows)
+ .counter("files_opened", partition);
+ let bytes_scanned = MetricBuilder::new(&self.metrics)
+ .with_type(MetricType::Summary)
+ .with_category(MetricCategory::Bytes)
+ .gauge("bytes_scanned", partition);
+
+ // Count tasks as the reader pulls them, including read-ahead for
LIMIT.
+ // Update reader bytes on batches and EOF, even when no rows match.
let stream = self
.reader
.clone()
- .read(tasks)
+ .read(tasks.inspect_ok(move |_| files_opened.add(1)).boxed())
Review Comment:
Alternative, if this is too fancy
```rust
use futures::stream::poll_fn;
use futures::StreamExt;
...
let tasks = tasks.inspect_ok(move |_| files_opened.add(1)).boxed();
let result = self
.reader
.clone()
.read(tasks)
.map_err(to_datafusion_error)?;
let reader_metrics = result.metrics().clone();
let mut batches = result.stream().map_err(to_datafusion_error);
let stream = poll_fn(move |cx| {
let poll = batches.poll_next_unpin(cx);
if poll.is_ready() {
bytes_scanned.set(reader_metrics.bytes_read() as usize);
}
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]