ariel-miculas commented on PR #23777:
URL: https://github.com/apache/datafusion/pull/23777#issuecomment-5202143409
> Perhaps we can use something like RecordBatchMemoryCounter (with internal
buffer tracking to avoid double-counting) to replace the below Counter:
That's kind of what I'm doing, except I've wrapped
`RecordBatchMemoryCounter` in a newtype struct:
```
#[derive(Debug, Default)]
pub struct RecordBatchMemoryMetrics(RecordBatchMemoryCounter);
impl RecordBatchMemoryMetrics {
pub fn new() -> Self {
Self::default()
}
/// Similar to RecordBatch.record_output, but deduplicating across
batches to avoid
/// output_size inflation due to shared memory
pub fn record_output(&mut self, batch: &RecordBatch, bm:
&BaselineMetrics) {
bm.record_output(batch.num_rows());
let n_bytes = self.0.count_batch(batch);
bm.output_bytes.add(n_bytes);
bm.output_batches.add(1);
}
}
```
Unless I've missed something from your explanation.
--
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]