@@ -34,7 +34,7 @@ use crate::config::FFI_ConfigOptions;
3434use crate :: execution:: FFI_TaskContext ;
3535use crate :: plan_properties:: FFI_PlanProperties ;
3636use crate :: record_batch_stream:: FFI_RecordBatchStream ;
37- use crate :: util:: FFIResult ;
37+ use crate :: util:: { FFIResult , FfiOption } ;
3838use crate :: { df_result, rresult, rresult_return} ;
3939
4040/// A stable struct for sharing a [`ExecutionPlan`] across FFI boundaries.
@@ -48,7 +48,7 @@ pub struct FFI_ExecutionPlan {
4848 pub children : unsafe extern "C" fn ( plan : & Self ) -> StabbyVec < FFI_ExecutionPlan > ,
4949
5050 pub with_new_children :
51- unsafe extern "C" fn ( plan : & Self , children : RVec < Self > ) -> FFIResult < Self > ,
51+ unsafe extern "C" fn ( plan : & Self , children : StabbyVec < Self > ) -> FFIResult < Self > ,
5252
5353 /// Return the plan name.
5454 pub name : unsafe extern "C" fn ( plan : & Self ) -> StabbyString ,
@@ -65,7 +65,8 @@ pub struct FFI_ExecutionPlan {
6565 plan : & Self ,
6666 target_partitions : usize ,
6767 config : FFI_ConfigOptions ,
68- ) -> FFIResult < ROption < FFI_ExecutionPlan > > ,
68+ )
69+ -> FFIResult < FfiOption < FFI_ExecutionPlan > > ,
6970
7071 /// Used to create a clone on the provider of the execution plan. This should
7172 /// only need to be called by the receiver of the plan.
@@ -125,6 +126,24 @@ unsafe extern "C" fn children_fn_wrapper(
125126 }
126127}
127128
129+ unsafe extern "C" fn with_new_children_fn_wrapper (
130+ plan : & FFI_ExecutionPlan ,
131+ children : StabbyVec < FFI_ExecutionPlan > ,
132+ ) -> FFIResult < FFI_ExecutionPlan > {
133+ let runtime = plan. runtime ( ) ;
134+ let inner_plan = Arc :: clone ( plan. inner ( ) ) ;
135+
136+ let children: Result < Vec < Arc < dyn ExecutionPlan > > > = children
137+ . iter ( )
138+ . map ( <Arc < dyn ExecutionPlan > >:: try_from)
139+ . collect ( ) ;
140+
141+ let children = rresult_return ! ( children) ;
142+ let new_plan = rresult_return ! ( inner_plan. with_new_children( children) ) ;
143+
144+ crate :: ffi_option:: FfiResult :: Ok ( FFI_ExecutionPlan :: new ( new_plan, runtime) )
145+ }
146+
128147unsafe extern "C" fn execute_fn_wrapper (
129148 plan : & FFI_ExecutionPlan ,
130149 partition : usize ,
@@ -146,7 +165,7 @@ unsafe extern "C" fn repartitioned_fn_wrapper(
146165 plan : & FFI_ExecutionPlan ,
147166 target_partitions : usize ,
148167 config : FFI_ConfigOptions ,
149- ) -> FFIResult < ROption < FFI_ExecutionPlan > > {
168+ ) -> FFIResult < FfiOption < FFI_ExecutionPlan > > {
150169 let maybe_config: Result < ConfigOptions , DataFusionError > = config. try_into ( ) ;
151170 let config = rresult_return ! ( maybe_config) ;
152171 let runtime = plan. runtime ( ) ;
@@ -370,7 +389,7 @@ impl ExecutionPlan for ForeignExecutionPlan {
370389 let children = children
371390 . into_iter ( )
372391 . map ( |child| FFI_ExecutionPlan :: new ( child, None ) )
373- . collect :: < RVec < _ > > ( ) ;
392+ . collect :: < StabbyVec < _ > > ( ) ;
374393 let new_plan =
375394 unsafe { df_result ! ( ( self . plan. with_new_children) ( & self . plan, children) ) ? } ;
376395
0 commit comments