@@ -19,7 +19,6 @@ use datafusion_physical_plan::metrics::{
1919 Count , ExecutionPlanMetricsSet , Gauge , MetricBuilder , MetricCategory , MetricType ,
2020 PruningMetrics , RatioMergeStrategy , RatioMetrics , Time ,
2121} ;
22- use std:: sync:: { Arc , OnceLock } ;
2322
2423/// Stores metrics about the parquet execution for a particular parquet file.
2524///
@@ -68,11 +67,6 @@ pub struct ParquetFileMetrics {
6867 pub page_index_rows_pruned : PruningMetrics ,
6968 /// Total pages filtered or matched by parquet page index
7069 pub page_index_pages_pruned : PruningMetrics ,
71- /// Lazily registered counter for pages whose page-index pruning was skipped
72- /// because the containing row group was fully matched by row-group statistics.
73- ///
74- /// These pages are still scanned; only page-index predicate evaluation is skipped.
75- page_index_pages_skipped_by_fully_matched : LazyParquetSummaryCount ,
7670 /// Total time spent evaluating parquet page index filters
7771 pub page_index_eval_time : Time ,
7872 /// Total time spent reading and parsing metadata from the footer
@@ -210,12 +204,6 @@ impl ParquetFileMetrics {
210204 row_pushdown_eval_time,
211205 page_index_rows_pruned,
212206 page_index_pages_pruned,
213- page_index_pages_skipped_by_fully_matched : LazyParquetSummaryCount :: new (
214- "page_index_pages_skipped_by_fully_matched" ,
215- partition,
216- filename,
217- metrics,
218- ) ,
219207 statistics_eval_time,
220208 bloom_filter_eval_time,
221209 page_index_eval_time,
@@ -228,48 +216,25 @@ impl ParquetFileMetrics {
228216
229217 /// Record pages whose page-index pruning was skipped because the containing
230218 /// row group was fully matched by row-group statistics.
231- pub ( crate ) fn add_page_index_pages_skipped_by_fully_matched ( & self , n : usize ) {
232- if n == 0 {
233- return ;
234- }
235-
236- self . page_index_pages_skipped_by_fully_matched . add ( n) ;
237- }
238- }
239-
240- #[ derive( Debug , Clone ) ]
241- struct LazyParquetSummaryCount {
242- count : Arc < OnceLock < Count > > ,
243- name : & ' static str ,
244- partition : usize ,
245- filename : String ,
246- metrics : ExecutionPlanMetricsSet ,
247- }
248-
249- impl LazyParquetSummaryCount {
250- fn new (
251- name : & ' static str ,
219+ ///
220+ /// The counter is only registered when there is a non-zero value. This keeps
221+ /// [`ParquetFileMetrics::new`] from cloning the filename and metrics set for
222+ /// files that never use this metric.
223+ pub ( crate ) fn add_page_index_pages_skipped_by_fully_matched (
224+ metrics : & ExecutionPlanMetricsSet ,
252225 partition : usize ,
253226 filename : & str ,
254- metrics : & ExecutionPlanMetricsSet ,
255- ) -> Self {
256- Self {
257- count : Arc :: new ( OnceLock :: new ( ) ) ,
258- name,
259- partition,
260- filename : filename. to_string ( ) ,
261- metrics : metrics. clone ( ) ,
227+ n : usize ,
228+ ) {
229+ if n == 0 {
230+ return ;
262231 }
263- }
264232
265- fn add ( & self , n : usize ) {
266- let count = self . count . get_or_init ( || {
267- MetricBuilder :: new ( & self . metrics )
268- . with_new_label ( "filename" , self . filename . clone ( ) )
269- . with_type ( MetricType :: Summary )
270- . with_category ( MetricCategory :: Rows )
271- . counter ( self . name , self . partition )
272- } ) ;
233+ let count = MetricBuilder :: new ( metrics)
234+ . with_new_label ( "filename" , filename. to_string ( ) )
235+ . with_type ( MetricType :: Summary )
236+ . with_category ( MetricCategory :: Rows )
237+ . counter ( "page_index_pages_skipped_by_fully_matched" , partition) ;
273238 count. add ( n) ;
274239 }
275240}
0 commit comments