@@ -66,6 +66,8 @@ pub(super) struct BucketedAggregation {
6666 bucket_splits : metrics:: Count ,
6767 /// Number of times the rows of a bucket were replaced by their aggregated state
6868 bucket_compactions : metrics:: Count ,
69+ /// Time spent routing rows into buckets, excluding compaction.
70+ bucket_routing_time : metrics:: Time ,
6971}
7072
7173/// What [`BucketedAggregation::output_stream`] works with while it runs.
@@ -92,6 +94,8 @@ impl BucketedAggregation {
9294 MetricBuilder :: new ( & agg. metrics ) . counter ( "bucket_splits" , partition) ;
9395 let bucket_compactions =
9496 MetricBuilder :: new ( & agg. metrics ) . counter ( "bucket_compactions" , partition) ;
97+ let bucket_routing_time = MetricBuilder :: new ( & agg. metrics )
98+ . subset_time ( "bucket_routing_time" , partition) ;
9599 Self {
96100 threshold,
97101 agg,
@@ -102,9 +106,19 @@ impl BucketedAggregation {
102106 spill_manager,
103107 bucket_splits,
104108 bucket_compactions,
109+ bucket_routing_time,
105110 }
106111 }
107112
113+ pub ( super ) fn route (
114+ & self ,
115+ buckets : & mut FinalBuckets ,
116+ batch : & RecordBatch ,
117+ ) -> Result < ( ) > {
118+ let _timer = self . bucket_routing_time . timer ( ) ;
119+ buckets. route ( batch)
120+ }
121+
108122 /// True if a schema of partial state rows can be bucketed.
109123 ///
110124 /// Bucketing turns the state of a table into rows and merges those rows
@@ -167,7 +181,7 @@ impl BucketedAggregation {
167181 self . bucket_splits . add ( 1 ) ;
168182 buckets. expect_kept ( kept) ;
169183 if let Some ( state) = state {
170- buckets . route ( & state) ?;
184+ self . route ( & mut buckets , & state) ?;
171185 }
172186 Ok ( buckets)
173187 }
@@ -308,7 +322,7 @@ impl BucketedAggregation {
308322 let held_bytes = waiting_bytes + source_bytes;
309323
310324 if let Some ( sub_buckets) = sub_buckets. as_mut ( ) {
311- sub_buckets . route ( & batch) ?;
325+ self . route ( sub_buckets , & batch) ?;
312326 self . compact ( sub_buckets, & mut compaction_table) ?;
313327 self . reserve ( & output. reservation , held_bytes, sub_buckets) ?;
314328 continue ;
0 commit comments