@@ -30,21 +30,14 @@ use crate::arrow::array_reader::{
3030 FixedSizeListArrayReader , ListArrayReader , MapArrayReader , NullArrayReader ,
3131 PrimitiveArrayReader , RowGroups , StructArrayReader ,
3232} ;
33+ use crate :: arrow:: arrow_reader:: metrics:: ArrowReaderMetrics ;
3334use crate :: arrow:: schema:: { ParquetField , ParquetFieldType } ;
3435use crate :: arrow:: ProjectionMask ;
3536use crate :: basic:: Type as PhysicalType ;
3637use crate :: data_type:: { BoolType , DoubleType , FloatType , Int32Type , Int64Type , Int96Type } ;
3738use crate :: errors:: { ParquetError , Result } ;
3839use crate :: schema:: types:: { ColumnDescriptor , ColumnPath , Type } ;
3940
40- /// Builds [`ArrayReader`]s from parquet schema, projection mask, and RowGroups reader
41- pub struct ArrayReaderBuilder < ' a > {
42- /// Source of row group data
43- row_groups : & ' a dyn RowGroups ,
44- /// Optional cache options for the array reader
45- cache_options : Option < & ' a CacheOptions < ' a > > ,
46- }
47-
4841/// Builder for [`CacheOptions`]
4942#[ derive( Debug , Clone ) ]
5043pub struct CacheOptionsBuilder < ' a > {
@@ -90,11 +83,22 @@ pub struct CacheOptions<'a> {
9083 pub role : CacheRole ,
9184}
9285
86+ /// Builds [`ArrayReader`]s from parquet schema, projection mask, and RowGroups reader
87+ pub struct ArrayReaderBuilder < ' a > {
88+ /// Source of row group data
89+ row_groups : & ' a dyn RowGroups ,
90+ /// Optional cache options for the array reader
91+ cache_options : Option < & ' a CacheOptions < ' a > > ,
92+ /// metrics
93+ metrics : & ' a ArrowReaderMetrics ,
94+ }
95+
9396impl < ' a > ArrayReaderBuilder < ' a > {
94- pub fn new ( row_groups : & ' a dyn RowGroups ) -> Self {
97+ pub fn new ( row_groups : & ' a dyn RowGroups , metrics : & ' a ArrowReaderMetrics ) -> Self {
9598 Self {
9699 row_groups,
97100 cache_options : None ,
101+ metrics,
98102 }
99103 }
100104
@@ -143,6 +147,7 @@ impl<'a> ArrayReaderBuilder<'a> {
143147 Arc :: clone ( & cache_options. cache ) ,
144148 col_idx,
145149 cache_options. role ,
150+ self . metrics . clone ( ) , // cheap clone
146151 ) ) ) )
147152 } else {
148153 Ok ( Some ( reader) )
@@ -453,7 +458,8 @@ mod tests {
453458 )
454459 . unwrap ( ) ;
455460
456- let array_reader = ArrayReaderBuilder :: new ( & file_reader)
461+ let metrics = ArrowReaderMetrics :: disabled ( ) ;
462+ let array_reader = ArrayReaderBuilder :: new ( & file_reader, & metrics)
457463 . build_array_reader ( fields. as_ref ( ) , & mask)
458464 . unwrap ( ) ;
459465
0 commit comments