@@ -8,8 +8,8 @@ use crate::protocol::set_distributed_channel_resolver;
88use crate :: work_unit_feed:: set_distributed_work_unit_feed;
99use crate :: worker_resolver:: set_distributed_worker_resolver;
1010use crate :: {
11- ChannelResolver , DistributedConfig , TaskEstimator , WorkUnitFeed , WorkUnitFeedProvider ,
12- WorkerResolver , get_distributed_worker_resolver,
11+ ChannelResolver , DistributedConfig , LocalWorkerContext , TaskEstimator , WorkUnitFeed ,
12+ WorkUnitFeedProvider , WorkerResolver , get_distributed_worker_resolver,
1313} ;
1414use datafusion:: common:: DataFusionError ;
1515use datafusion:: config:: ConfigExtension ;
@@ -600,6 +600,17 @@ pub trait DistributedExt: Sized {
600600 & mut self ,
601601 dynamic_bytes_per_partition : usize ,
602602 ) -> Result < ( ) , DataFusionError > ;
603+
604+ /// Target throughput in bytes per partition per second used by the dynamic task count
605+ /// allocator to decide how many tasks to assign to each stage based on runtime statistics.
606+ fn with_distributed_local_worker_context (
607+ self ,
608+ local_worker_context : LocalWorkerContext ,
609+ ) -> Self ;
610+
611+ /// Same as [DistributedExt::with_distributed_local_worker_context] but with an
612+ /// in-place mutation.
613+ fn set_distributed_local_worker_context ( & mut self , local_worker_context : LocalWorkerContext ) ;
603614}
604615
605616/// Trait to have a unified interface for getting structs & properties from SessionConfig that are used in distributed context.
@@ -768,6 +779,10 @@ impl DistributedExt for SessionConfig {
768779 Ok ( ( ) )
769780 }
770781
782+ fn set_distributed_local_worker_context ( & mut self , local_worker_context : LocalWorkerContext ) {
783+ self . set_extension ( Arc :: new ( local_worker_context) ) ;
784+ }
785+
771786 delegate ! {
772787 to self {
773788 #[ call( set_distributed_option_extension) ]
@@ -859,6 +874,10 @@ impl DistributedExt for SessionConfig {
859874 #[ call( set_distributed_dynamic_bytes_per_partition) ]
860875 #[ expr( $?; Ok ( self ) ) ]
861876 fn with_distributed_dynamic_bytes_per_partition( mut self , dynamic_bytes_per_partition: usize ) -> Result <Self , DataFusionError >;
877+
878+ #[ call( set_distributed_local_worker_context) ]
879+ #[ expr( $; self ) ]
880+ fn with_distributed_local_worker_context( mut self , local_worker_context: LocalWorkerContext ) -> Self ;
862881 }
863882 }
864883}
@@ -987,6 +1006,11 @@ impl DistributedExt for SessionStateBuilder {
9871006 #[ call( set_distributed_dynamic_bytes_per_partition) ]
9881007 #[ expr( $?; Ok ( self ) ) ]
9891008 fn with_distributed_dynamic_bytes_per_partition( mut self , dynamic_bytes_per_partition: usize ) -> Result <Self , DataFusionError >;
1009+
1010+ fn set_distributed_local_worker_context( & mut self , local_worker_context: LocalWorkerContext ) ;
1011+ #[ call( set_distributed_local_worker_context) ]
1012+ #[ expr( $; self ) ]
1013+ fn with_distributed_local_worker_context( mut self , local_worker_context: LocalWorkerContext ) -> Self ;
9901014 }
9911015 }
9921016}
@@ -1117,6 +1141,11 @@ impl DistributedExt for SessionState {
11171141 #[ call( set_distributed_dynamic_bytes_per_partition) ]
11181142 #[ expr( $?; Ok ( self ) ) ]
11191143 fn with_distributed_dynamic_bytes_per_partition( mut self , dynamic_bytes_per_partition: usize ) -> Result <Self , DataFusionError >;
1144+
1145+ fn set_distributed_local_worker_context( & mut self , local_worker_context: LocalWorkerContext ) ;
1146+ #[ call( set_distributed_local_worker_context) ]
1147+ #[ expr( $; self ) ]
1148+ fn with_distributed_local_worker_context( mut self , local_worker_context: LocalWorkerContext ) -> Self ;
11201149 }
11211150 }
11221151}
@@ -1240,6 +1269,11 @@ impl DistributedExt for SessionContext {
12401269 #[ call( set_distributed_dynamic_bytes_per_partition) ]
12411270 #[ expr( $?; Ok ( self ) ) ]
12421271 fn with_distributed_dynamic_bytes_per_partition( self , dynamic_bytes_per_partition: usize ) -> Result <Self , DataFusionError >;
1272+
1273+ fn set_distributed_local_worker_context( & mut self , local_worker_context: LocalWorkerContext ) ;
1274+ #[ call( set_distributed_local_worker_context) ]
1275+ #[ expr( $; self ) ]
1276+ fn with_distributed_local_worker_context( self , local_worker_context: LocalWorkerContext ) -> Self ;
12431277 }
12441278 }
12451279}
0 commit comments