@@ -43,55 +43,32 @@ use prost::Message;
43
43
44
44
use crate :: arrow_wrappers:: WrappedSchema ;
45
45
46
- // TODO: should we just make ExecutionMode repr(C)?
47
- #[ repr( C ) ]
48
- #[ allow( non_camel_case_types) ]
49
- #[ derive( Clone , StableAbi ) ]
50
- pub enum FFI_ExecutionMode {
51
- Bounded ,
52
- Unbounded ,
53
- PipelineBreaking ,
54
- }
55
-
56
- impl From < ExecutionMode > for FFI_ExecutionMode {
57
- fn from ( value : ExecutionMode ) -> Self {
58
- match value {
59
- ExecutionMode :: Bounded => FFI_ExecutionMode :: Bounded ,
60
- ExecutionMode :: Unbounded => FFI_ExecutionMode :: Unbounded ,
61
- ExecutionMode :: PipelineBreaking => FFI_ExecutionMode :: PipelineBreaking ,
62
- }
63
- }
64
- }
65
-
66
- impl From < FFI_ExecutionMode > for ExecutionMode {
67
- fn from ( value : FFI_ExecutionMode ) -> Self {
68
- match value {
69
- FFI_ExecutionMode :: Bounded => ExecutionMode :: Bounded ,
70
- FFI_ExecutionMode :: Unbounded => ExecutionMode :: Unbounded ,
71
- FFI_ExecutionMode :: PipelineBreaking => ExecutionMode :: PipelineBreaking ,
72
- }
73
- }
74
- }
75
-
46
+ /// A stable struct for sharing [`PlanProperties`] across FFI boundaries.
76
47
#[ repr( C ) ]
77
48
#[ derive( Debug , StableAbi ) ]
78
- #[ allow( missing_docs) ]
79
49
#[ allow( non_camel_case_types) ]
80
50
pub struct FFI_PlanProperties {
81
- // Returns protobuf serialized bytes of the partitioning
51
+ /// The output partitioning is a [`Partitioning`] protobuf message serialized
52
+ /// into bytes to pass across the FFI boundary.
82
53
pub output_partitioning :
83
54
unsafe extern "C" fn ( plan : & Self ) -> RResult < RVec < u8 > , RStr < ' static > > ,
84
55
56
+ /// Return the execution mode of the plan.
85
57
pub execution_mode : unsafe extern "C" fn ( plan : & Self ) -> FFI_ExecutionMode ,
86
58
87
- // PhysicalSortExprNodeCollection proto
59
+ /// The output ordering is a [`PhysicalSortExprNodeCollection`] protobuf message
60
+ /// serialized into bytes to pass across the FFI boundary.
88
61
pub output_ordering :
89
62
unsafe extern "C" fn ( plan : & Self ) -> RResult < RVec < u8 > , RStr < ' static > > ,
90
63
64
+ /// Return the schema of the plan.
91
65
pub schema : unsafe extern "C" fn ( plan : & Self ) -> WrappedSchema ,
92
66
67
+ /// Release the memory of the private data when it is no longer being used.
93
68
pub release : unsafe extern "C" fn ( arg : & mut Self ) ,
94
69
70
+ /// Internal data. This is only to be accessed by the provider of the plan.
71
+ /// The foreign library should never attempt to access this data.
95
72
pub private_data : * mut c_void ,
96
73
}
97
74
@@ -261,6 +238,36 @@ impl TryFrom<FFI_PlanProperties> for PlanProperties {
261
238
}
262
239
}
263
240
241
+ /// FFI safe version of [`ExecutionMode`].
242
+ #[ repr( C ) ]
243
+ #[ allow( non_camel_case_types) ]
244
+ #[ derive( Clone , StableAbi ) ]
245
+ pub enum FFI_ExecutionMode {
246
+ Bounded ,
247
+ Unbounded ,
248
+ PipelineBreaking ,
249
+ }
250
+
251
+ impl From < ExecutionMode > for FFI_ExecutionMode {
252
+ fn from ( value : ExecutionMode ) -> Self {
253
+ match value {
254
+ ExecutionMode :: Bounded => FFI_ExecutionMode :: Bounded ,
255
+ ExecutionMode :: Unbounded => FFI_ExecutionMode :: Unbounded ,
256
+ ExecutionMode :: PipelineBreaking => FFI_ExecutionMode :: PipelineBreaking ,
257
+ }
258
+ }
259
+ }
260
+
261
+ impl From < FFI_ExecutionMode > for ExecutionMode {
262
+ fn from ( value : FFI_ExecutionMode ) -> Self {
263
+ match value {
264
+ FFI_ExecutionMode :: Bounded => ExecutionMode :: Bounded ,
265
+ FFI_ExecutionMode :: Unbounded => ExecutionMode :: Unbounded ,
266
+ FFI_ExecutionMode :: PipelineBreaking => ExecutionMode :: PipelineBreaking ,
267
+ }
268
+ }
269
+ }
270
+
264
271
#[ cfg( test) ]
265
272
mod tests {
266
273
use datafusion:: physical_plan:: Partitioning ;
0 commit comments