@@ -26,6 +26,7 @@ mod value;
2626use datafusion_common:: HashMap ;
2727pub use datafusion_common:: format:: { MetricCategory , MetricType } ;
2828use parking_lot:: Mutex ;
29+ use std:: vec:: IntoIter ;
2930use std:: {
3031 borrow:: Cow ,
3132 fmt:: { self , Debug , Display } ,
@@ -225,6 +226,11 @@ impl MetricsSet {
225226 self . metrics . push ( metric)
226227 }
227228
229+ /// Extends the current list of metrics with the provided ones
230+ pub fn extend ( & mut self , metrics : impl Iterator < Item = Arc < Metric > > ) {
231+ self . metrics . extend ( metrics)
232+ }
233+
228234 /// Returns an iterator across all metrics
229235 pub fn iter ( & self ) -> impl Iterator < Item = & Arc < Metric > > {
230236 self . metrics . iter ( )
@@ -432,6 +438,15 @@ impl Display for MetricsSet {
432438 }
433439}
434440
441+ impl IntoIterator for MetricsSet {
442+ type Item = Arc < Metric > ;
443+ type IntoIter = IntoIter < Self :: Item > ;
444+
445+ fn into_iter ( self ) -> Self :: IntoIter {
446+ self . metrics . into_iter ( )
447+ }
448+ }
449+
435450/// A set of [`Metric`]s for an individual operator.
436451///
437452/// This structure is intended as a convenience for execution plan
@@ -465,6 +480,14 @@ impl ExecutionPlanMetricsSet {
465480 }
466481}
467482
483+ impl From < MetricsSet > for ExecutionPlanMetricsSet {
484+ fn from ( metrics : MetricsSet ) -> Self {
485+ Self {
486+ inner : Arc :: new ( Mutex :: new ( metrics) ) ,
487+ }
488+ }
489+ }
490+
468491/// `name=value` pairs identifying a metric. This concept is called various things
469492/// in various different systems:
470493///
0 commit comments