@@ -717,7 +717,7 @@ impl MultiPartitionShuffleRepartitioner {
717717 & mut self . partition_indices ,
718718 vec ! [ vec![ ] ; num_output_partitions] ,
719719 ) ;
720- PartitionedBatchesProducer :: new ( buffered_batches, indices, self . batch_size )
720+ PartitionedBatchesProducer :: new ( buffered_batches, indices, self . batch_size , self . metrics . repart_time . clone ( ) )
721721 }
722722
723723 fn spill ( & mut self ) -> Result < ( ) > {
@@ -1046,18 +1046,21 @@ struct PartitionedBatchesProducer {
10461046 buffered_batches : Vec < RecordBatch > ,
10471047 partition_indices : Vec < Vec < ( u32 , u32 ) > > ,
10481048 batch_size : usize ,
1049+ repart_time : Time
10491050}
10501051
10511052impl PartitionedBatchesProducer {
10521053 fn new (
10531054 buffered_batches : Vec < RecordBatch > ,
10541055 indices : Vec < Vec < ( u32 , u32 ) > > ,
10551056 batch_size : usize ,
1057+ repart_time : Time ,
10561058 ) -> Self {
10571059 Self {
10581060 partition_indices : indices,
10591061 buffered_batches,
10601062 batch_size,
1063+ repart_time
10611064 }
10621065 }
10631066
@@ -1066,6 +1069,7 @@ impl PartitionedBatchesProducer {
10661069 & self . partition_indices [ partition_id] ,
10671070 & self . buffered_batches ,
10681071 self . batch_size ,
1072+ & self . repart_time
10691073 )
10701074 }
10711075}
@@ -1075,13 +1079,15 @@ struct PartitionedBatchIterator<'a> {
10751079 batch_size : usize ,
10761080 indices : Vec < ( usize , usize ) > ,
10771081 pos : usize ,
1082+ repart_time : & ' a Time ,
10781083}
10791084
10801085impl < ' a > PartitionedBatchIterator < ' a > {
10811086 fn new (
10821087 indices : & ' a [ ( u32 , u32 ) ] ,
10831088 buffered_batches : & ' a [ RecordBatch ] ,
10841089 batch_size : usize ,
1090+ repart_time : & ' a Time ,
10851091 ) -> Self {
10861092 if indices. is_empty ( ) {
10871093 // Avoid unnecessary allocations when the partition is empty
@@ -1090,18 +1096,24 @@ impl<'a> PartitionedBatchIterator<'a> {
10901096 batch_size,
10911097 indices : vec ! [ ] ,
10921098 pos : 0 ,
1099+ repart_time
10931100 } ;
10941101 }
1102+
1103+ let mut time = repart_time. timer ( ) ;
10951104 let record_batches = buffered_batches. iter ( ) . collect :: < Vec < _ > > ( ) ;
10961105 let current_indices = indices
10971106 . iter ( )
10981107 . map ( |( i_batch, i_row) | ( * i_batch as usize , * i_row as usize ) )
10991108 . collect :: < Vec < _ > > ( ) ;
1109+ time. stop ( ) ;
1110+
11001111 Self {
11011112 record_batches,
11021113 batch_size,
11031114 indices : current_indices,
11041115 pos : 0 ,
1116+ repart_time
11051117 }
11061118 }
11071119}
@@ -1114,6 +1126,8 @@ impl Iterator for PartitionedBatchIterator<'_> {
11141126 return None ;
11151127 }
11161128
1129+ let _time = self . repart_time . timer ( ) ;
1130+
11171131 let indices_end = std:: cmp:: min ( self . pos + self . batch_size , self . indices . len ( ) ) ;
11181132 let indices = & self . indices [ self . pos ..indices_end] ;
11191133 match interleave_record_batch ( & self . record_batches , indices) {
@@ -1248,6 +1262,7 @@ impl<S: Borrow<ShuffleBlockWriter>, W: Write> BufBatchWriter<S, W> {
12481262 let mut write_timer = write_time. timer ( ) ;
12491263 self . writer . write_all ( & self . buffer ) ?;
12501264 write_timer. stop ( ) ;
1265+
12511266 self . buffer . clear ( ) ;
12521267 }
12531268 Ok ( bytes_written)
@@ -1260,6 +1275,7 @@ impl<S: Borrow<ShuffleBlockWriter>, W: Write> BufBatchWriter<S, W> {
12601275 }
12611276 self . writer . flush ( ) ?;
12621277 write_timer. stop ( ) ;
1278+
12631279 self . buffer . clear ( ) ;
12641280 Ok ( ( ) )
12651281 }
0 commit comments