@@ -645,58 +645,38 @@ impl DistributedExt for SessionConfig {
645645 & mut self ,
646646 bytes_per_partition : usize ,
647647 ) -> Result < ( ) , DataFusionError > {
648- let mut d_cfg = self
649- . get_extension :: < DistributedConfig > ( )
650- . map ( |a| a. as_ref ( ) . clone ( ) )
651- . unwrap_or_default ( ) ;
648+ let d_cfg = DistributedConfig :: from_config_options_mut ( self . options_mut ( ) ) ?;
652649 d_cfg. file_scan_config_bytes_per_partition = bytes_per_partition;
653- self . set_extension ( Arc :: new ( d_cfg) ) ;
654650 Ok ( ( ) )
655651 }
656652
657653 fn set_distributed_cardinality_effect_task_scale_factor (
658654 & mut self ,
659655 factor : f64 ,
660656 ) -> Result < ( ) , DataFusionError > {
661- let mut d_cfg = self
662- . get_extension :: < DistributedConfig > ( )
663- . map ( |a| a. as_ref ( ) . clone ( ) )
664- . unwrap_or_default ( ) ;
657+ let d_cfg = DistributedConfig :: from_config_options_mut ( self . options_mut ( ) ) ?;
665658 d_cfg. cardinality_task_count_factor = factor;
666- self . set_extension ( Arc :: new ( d_cfg) ) ;
667659 Ok ( ( ) )
668660 }
669661
670662 fn set_distributed_metrics_collection ( & mut self , enabled : bool ) -> Result < ( ) , DataFusionError > {
671- let mut d_cfg = self
672- . get_extension :: < DistributedConfig > ( )
673- . map ( |a| a. as_ref ( ) . clone ( ) )
674- . unwrap_or_default ( ) ;
663+ let d_cfg = DistributedConfig :: from_config_options_mut ( self . options_mut ( ) ) ?;
675664 d_cfg. collect_metrics = enabled;
676- self . set_extension ( Arc :: new ( d_cfg) ) ;
677665 Ok ( ( ) )
678666 }
679667
680668 fn set_distributed_children_isolator_unions (
681669 & mut self ,
682670 enabled : bool ,
683671 ) -> Result < ( ) , DataFusionError > {
684- let mut d_cfg = self
685- . get_extension :: < DistributedConfig > ( )
686- . map ( |a| a. as_ref ( ) . clone ( ) )
687- . unwrap_or_default ( ) ;
672+ let d_cfg = DistributedConfig :: from_config_options_mut ( self . options_mut ( ) ) ?;
688673 d_cfg. children_isolator_unions = enabled;
689- self . set_extension ( Arc :: new ( d_cfg) ) ;
690674 Ok ( ( ) )
691675 }
692676
693677 fn set_distributed_broadcast_joins ( & mut self , enabled : bool ) -> Result < ( ) , DataFusionError > {
694- let mut d_cfg = self
695- . get_extension :: < DistributedConfig > ( )
696- . map ( |a| a. as_ref ( ) . clone ( ) )
697- . unwrap_or_default ( ) ;
678+ let d_cfg = DistributedConfig :: from_config_options_mut ( self . options_mut ( ) ) ?;
698679 d_cfg. broadcast_joins = enabled;
699- self . set_extension ( Arc :: new ( d_cfg) ) ;
700680 Ok ( ( ) )
701681 }
702682
@@ -705,29 +685,21 @@ impl DistributedExt for SessionConfig {
705685 & mut self ,
706686 compression : Option < arrow_ipc:: CompressionType > ,
707687 ) -> Result < ( ) , DataFusionError > {
708- let mut d_cfg = self
709- . get_extension :: < DistributedConfig > ( )
710- . map ( |a| a. as_ref ( ) . clone ( ) )
711- . unwrap_or_default ( ) ;
688+ let d_cfg = DistributedConfig :: from_config_options_mut ( self . options_mut ( ) ) ?;
712689 d_cfg. compression = match compression {
713690 Some ( arrow_ipc:: CompressionType :: ZSTD ) => "zstd" . to_string ( ) ,
714691 Some ( arrow_ipc:: CompressionType :: LZ4_FRAME ) => "lz4" . to_string ( ) ,
715692 _ => "none" . to_string ( ) ,
716693 } ;
717- self . set_extension ( Arc :: new ( d_cfg) ) ;
718694 Ok ( ( ) )
719695 }
720696
721697 fn set_distributed_shuffle_batch_size (
722698 & mut self ,
723699 batch_size : usize ,
724700 ) -> Result < ( ) , DataFusionError > {
725- let mut d_cfg = self
726- . get_extension :: < DistributedConfig > ( )
727- . map ( |a| a. as_ref ( ) . clone ( ) )
728- . unwrap_or_default ( ) ;
701+ let d_cfg = DistributedConfig :: from_config_options_mut ( self . options_mut ( ) ) ?;
729702 d_cfg. shuffle_batch_size = batch_size;
730- self . set_extension ( Arc :: new ( d_cfg) ) ;
731703 Ok ( ( ) )
732704 }
733705
@@ -742,35 +714,23 @@ impl DistributedExt for SessionConfig {
742714 & mut self ,
743715 max_tasks_per_stage : usize ,
744716 ) -> Result < ( ) , DataFusionError > {
745- let mut d_cfg = self
746- . get_extension :: < DistributedConfig > ( )
747- . map ( |a| a. as_ref ( ) . clone ( ) )
748- . unwrap_or_default ( ) ;
717+ let d_cfg = DistributedConfig :: from_config_options_mut ( self . options_mut ( ) ) ?;
749718 d_cfg. max_tasks_per_stage = max_tasks_per_stage;
750- self . set_extension ( Arc :: new ( d_cfg) ) ;
751719 Ok ( ( ) )
752720 }
753721
754722 fn set_distributed_partial_reduce ( & mut self , enabled : bool ) -> Result < ( ) , DataFusionError > {
755- let mut d_cfg = self
756- . get_extension :: < DistributedConfig > ( )
757- . map ( |a| a. as_ref ( ) . clone ( ) )
758- . unwrap_or_default ( ) ;
723+ let d_cfg = DistributedConfig :: from_config_options_mut ( self . options_mut ( ) ) ?;
759724 d_cfg. partial_reduce = enabled;
760- self . set_extension ( Arc :: new ( d_cfg) ) ;
761725 Ok ( ( ) )
762726 }
763727
764728 fn set_distributed_worker_connection_buffer_budget_bytes (
765729 & mut self ,
766730 budget_bytes : usize ,
767731 ) -> Result < ( ) , DataFusionError > {
768- let mut d_cfg = self
769- . get_extension :: < DistributedConfig > ( )
770- . map ( |a| a. as_ref ( ) . clone ( ) )
771- . unwrap_or_default ( ) ;
732+ let d_cfg = DistributedConfig :: from_config_options_mut ( self . options_mut ( ) ) ?;
772733 d_cfg. worker_connection_buffer_budget_bytes = budget_bytes;
773- self . set_extension ( Arc :: new ( d_cfg) ) ;
774734 Ok ( ( ) )
775735 }
776736
@@ -787,25 +747,17 @@ impl DistributedExt for SessionConfig {
787747 }
788748
789749 fn set_distributed_dynamic_task_count ( & mut self , enabled : bool ) -> Result < ( ) , DataFusionError > {
790- let mut d_cfg = self
791- . get_extension :: < DistributedConfig > ( )
792- . map ( |a| a. as_ref ( ) . clone ( ) )
793- . unwrap_or_default ( ) ;
750+ let d_cfg = DistributedConfig :: from_config_options_mut ( self . options_mut ( ) ) ?;
794751 d_cfg. dynamic_task_count = enabled;
795- self . set_extension ( Arc :: new ( d_cfg) ) ;
796752 Ok ( ( ) )
797753 }
798754
799755 fn set_distributed_bytes_per_partition_per_second (
800756 & mut self ,
801757 bytes_per_partition_per_second : usize ,
802758 ) -> Result < ( ) , DataFusionError > {
803- let mut d_cfg = self
804- . get_extension :: < DistributedConfig > ( )
805- . map ( |a| a. as_ref ( ) . clone ( ) )
806- . unwrap_or_default ( ) ;
759+ let d_cfg = DistributedConfig :: from_config_options_mut ( self . options_mut ( ) ) ?;
807760 d_cfg. bytes_per_partition_per_second = bytes_per_partition_per_second;
808- self . set_extension ( Arc :: new ( d_cfg) ) ;
809761 Ok ( ( ) )
810762 }
811763
0 commit comments