mkleen commented on code in PR #23490:
URL: https://github.com/apache/datafusion/pull/23490#discussion_r3593783198
##########
datafusion/datasource/src/file_sink_config.rs:
##########
@@ -28,10 +28,72 @@ use datafusion_common_runtime::SpawnedTask;
use datafusion_execution::object_store::ObjectStoreUrl;
use datafusion_execution::{SendableRecordBatchStream, TaskContext};
use datafusion_expr::dml::InsertOp;
+use datafusion_physical_plan::metrics::{
+ Count, ExecutionPlanMetricsSet, MetricBuilder, MetricCategory, MetricsSet,
Time,
+};
use async_trait::async_trait;
use object_store::ObjectStore;
+/// Common metrics exposed by file sinks.
+#[derive(Debug)]
+pub struct FileSinkMetrics {
+ metrics: ExecutionPlanMetricsSet,
+ rows_written: Count,
+ bytes_written: Count,
+ elapsed_compute: Time,
+}
+
+impl FileSinkMetrics {
+ /// Create a new set of file sink metrics.
+ pub fn new() -> Self {
+ let metrics = ExecutionPlanMetricsSet::new();
+ let rows_written = MetricBuilder::new(&metrics)
+ .with_category(MetricCategory::Rows)
+ .global_counter("rows_written");
+ let bytes_written = MetricBuilder::new(&metrics)
+ .with_category(MetricCategory::Bytes)
+ .global_counter("bytes_written");
+ let elapsed_compute = MetricBuilder::new(&metrics).elapsed_compute(0);
+ Self {
+ metrics,
+ rows_written,
+ bytes_written,
+ elapsed_compute,
+ }
+ }
+
+ /// Return the number of rows written.
+ pub fn rows_written(&self) -> &Count {
+ &self.rows_written
+ }
+
+ /// Return the number of bytes written.
+ ///
+ /// The exact meaning is format-specific. For stateless sinks, this is the
+ /// number of serialized bytes passed to the writer before any stream-level
+ /// compression is applied.
+ pub fn bytes_written(&self) -> &Count {
Review Comment:
This is a little bit confusing. This reports the uncompressed size, but in
Parquet it's the compressed row-group size. A gzipped CSV will report the
uncompressed size. Do you think we could have the actual size written
(compressed) ?
https://github.com/apache/datafusion/blob/main/datafusion/datasource-parquet/src/sink.rs#L268
--
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]