@@ -3,14 +3,15 @@ use crate::channel_resolver_ext::set_distributed_channel_resolver;
33use crate :: config_extension_ext:: {
44 set_distributed_option_extension, set_distributed_option_extension_from_headers,
55} ;
6- use crate :: protobuf:: set_distributed_user_codec;
6+ use crate :: protobuf:: { set_distributed_user_codec, set_distributed_user_codec_arc } ;
77use datafusion:: common:: DataFusionError ;
88use datafusion:: config:: ConfigExtension ;
99use datafusion:: execution:: { SessionState , SessionStateBuilder } ;
1010use datafusion:: prelude:: { SessionConfig , SessionContext } ;
1111use datafusion_proto:: physical_plan:: PhysicalExtensionCodec ;
1212use delegate:: delegate;
1313use http:: HeaderMap ;
14+ use std:: sync:: Arc ;
1415
1516/// Extends DataFusion with distributed capabilities.
1617pub trait DistributedExt : Sized {
@@ -167,6 +168,12 @@ pub trait DistributedExt: Sized {
167168 /// Same as [DistributedExt::with_distributed_user_codec] but with an in-place mutation
168169 fn set_distributed_user_codec < T : PhysicalExtensionCodec + ' static > ( & mut self , codec : T ) ;
169170
171+ /// Same as [DistributedExt::with_distributed_user_codec] but with a dynamic argument.
172+ fn with_distributed_user_codec_arc ( self , codec : Arc < dyn PhysicalExtensionCodec > ) -> Self ;
173+
174+ /// Same as [DistributedExt::set_distributed_user_codec] but with a dynamic argument.
175+ fn set_distributed_user_codec_arc ( & mut self , codec : Arc < dyn PhysicalExtensionCodec > ) ;
176+
170177 /// Injects a [ChannelResolver] implementation for Distributed DataFusion to resolve worker
171178 /// nodes. When running in distributed mode, setting a [ChannelResolver] is required.
172179 ///
@@ -234,6 +241,10 @@ impl DistributedExt for SessionConfig {
234241 set_distributed_user_codec ( self , codec)
235242 }
236243
244+ fn set_distributed_user_codec_arc ( & mut self , codec : Arc < dyn PhysicalExtensionCodec > ) {
245+ set_distributed_user_codec_arc ( self , codec)
246+ }
247+
237248 fn set_distributed_channel_resolver < T : ChannelResolver + Send + Sync + ' static > (
238249 & mut self ,
239250 resolver : T ,
@@ -255,6 +266,10 @@ impl DistributedExt for SessionConfig {
255266 #[ expr( $; self ) ]
256267 fn with_distributed_user_codec<T : PhysicalExtensionCodec + ' static >( mut self , codec: T ) -> Self ;
257268
269+ #[ call( set_distributed_user_codec_arc) ]
270+ #[ expr( $; self ) ]
271+ fn with_distributed_user_codec_arc( mut self , codec: Arc <dyn PhysicalExtensionCodec >) -> Self ;
272+
258273 #[ call( set_distributed_channel_resolver) ]
259274 #[ expr( $; self ) ]
260275 fn with_distributed_channel_resolver<T : ChannelResolver + Send + Sync + ' static >( mut self , resolver: T ) -> Self ;
@@ -280,6 +295,11 @@ impl DistributedExt for SessionStateBuilder {
280295 #[ expr( $; self ) ]
281296 fn with_distributed_user_codec<T : PhysicalExtensionCodec + ' static >( mut self , codec: T ) -> Self ;
282297
298+ fn set_distributed_user_codec_arc( & mut self , codec: Arc <dyn PhysicalExtensionCodec >) ;
299+ #[ call( set_distributed_user_codec_arc) ]
300+ #[ expr( $; self ) ]
301+ fn with_distributed_user_codec_arc( mut self , codec: Arc <dyn PhysicalExtensionCodec >) -> Self ;
302+
283303 fn set_distributed_channel_resolver<T : ChannelResolver + Send + Sync + ' static >( & mut self , resolver: T ) ;
284304 #[ call( set_distributed_channel_resolver) ]
285305 #[ expr( $; self ) ]
@@ -306,6 +326,11 @@ impl DistributedExt for SessionState {
306326 #[ expr( $; self ) ]
307327 fn with_distributed_user_codec<T : PhysicalExtensionCodec + ' static >( mut self , codec: T ) -> Self ;
308328
329+ fn set_distributed_user_codec_arc( & mut self , codec: Arc <dyn PhysicalExtensionCodec >) ;
330+ #[ call( set_distributed_user_codec_arc) ]
331+ #[ expr( $; self ) ]
332+ fn with_distributed_user_codec_arc( mut self , codec: Arc <dyn PhysicalExtensionCodec >) -> Self ;
333+
309334 fn set_distributed_channel_resolver<T : ChannelResolver + Send + Sync + ' static >( & mut self , resolver: T ) ;
310335 #[ call( set_distributed_channel_resolver) ]
311336 #[ expr( $; self ) ]
@@ -332,6 +357,11 @@ impl DistributedExt for SessionContext {
332357 #[ expr( $; self ) ]
333358 fn with_distributed_user_codec<T : PhysicalExtensionCodec + ' static >( self , codec: T ) -> Self ;
334359
360+ fn set_distributed_user_codec_arc( & mut self , codec: Arc <dyn PhysicalExtensionCodec >) ;
361+ #[ call( set_distributed_user_codec_arc) ]
362+ #[ expr( $; self ) ]
363+ fn with_distributed_user_codec_arc( mut self , codec: Arc <dyn PhysicalExtensionCodec >) -> Self ;
364+
335365 fn set_distributed_channel_resolver<T : ChannelResolver + Send + Sync + ' static >( & mut self , resolver: T ) ;
336366 #[ call( set_distributed_channel_resolver) ]
337367 #[ expr( $; self ) ]
0 commit comments