Skip to content

Commit 9f7d00a

Browse files
committed
cargo_fmt_rebase_main
1 parent 0319ade commit 9f7d00a

4 files changed

Lines changed: 27 additions & 7 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion/ffi/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ datafusion-functions-aggregate = { workspace = true }
7878
datafusion-functions-aggregate-common = { workspace = true }
7979
datafusion-functions-window = { workspace = true }
8080
doc-comment = { workspace = true }
81+
libloading = "0.8"
8182

8283
[features]
8384
integration-tests = [

datafusion/ffi/src/execution_plan.rs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::config::FFI_ConfigOptions;
3434
use crate::execution::FFI_TaskContext;
3535
use crate::plan_properties::FFI_PlanProperties;
3636
use crate::record_batch_stream::FFI_RecordBatchStream;
37-
use crate::util::FFIResult;
37+
use crate::util::{FFIResult, FfiOption};
3838
use 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+
128147
unsafe 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

datafusion/ffi/src/proto/physical_extension_codec.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
use std::any::Any;
1819
use std::ffi::c_void;
1920
use std::sync::Arc;
2021

@@ -29,7 +30,6 @@ use datafusion_proto::physical_plan::PhysicalExtensionCodec;
2930
use stabby::slice::Slice as StabbySlice;
3031
use stabby::str::Str as StabbyStr;
3132
use stabby::vec::Vec as StabbyVec;
32-
use std::{any::Any, ffi::c_void, sync::Arc};
3333
use tokio::runtime::Handle;
3434

3535
use crate::execution::FFI_TaskContextProvider;
@@ -149,7 +149,6 @@ unsafe extern "C" fn try_decode_fn_wrapper(
149149
rresult_return!(codec.try_decode(buf.as_ref(), &inputs, task_ctx.as_ref()));
150150

151151
FfiResult::Ok(FFI_ExecutionPlan::new(plan, runtime))
152-
153152
}
154153

155154
unsafe extern "C" fn try_encode_fn_wrapper(

0 commit comments

Comments
 (0)