Skip to content

Commit 650e976

Browse files
committed
Standardize naming for FFI structs
1 parent 0b5bb1a commit 650e976

File tree

2 files changed

+52
-52
lines changed

2 files changed

+52
-52
lines changed

src/ffi/execution_plan.rs

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ use prost::{DecodeError, Message};
2424
#[derive(Debug)]
2525
#[allow(missing_docs)]
2626
#[allow(non_camel_case_types)]
27-
pub struct FFIExecutionPlan {
27+
pub struct FFI_ExecutionPlan {
2828
pub properties:
29-
Option<unsafe extern "C" fn(plan: *const FFIExecutionPlan) -> FFIPlanProperties>,
29+
Option<unsafe extern "C" fn(plan: *const FFI_ExecutionPlan) -> FFI_PlanProperties>,
3030
pub children: Option<
3131
unsafe extern "C" fn(
32-
plan: *const FFIExecutionPlan,
32+
plan: *const FFI_ExecutionPlan,
3333
num_children: &mut usize,
34-
out: &mut *const FFIExecutionPlan,
34+
out: &mut *const FFI_ExecutionPlan,
3535
) -> i32,
3636
>,
3737

@@ -43,24 +43,24 @@ pub struct ExecutionPlanPrivateData {
4343
pub last_error: Option<CString>,
4444
}
4545

46-
unsafe extern "C" fn properties_fn_wrapper(plan: *const FFIExecutionPlan) -> FFIPlanProperties {
46+
unsafe extern "C" fn properties_fn_wrapper(plan: *const FFI_ExecutionPlan) -> FFI_PlanProperties {
4747
let private_data = (*plan).private_data as *const ExecutionPlanPrivateData;
4848
let properties = (*private_data).plan.properties();
4949
properties.into()
5050
}
5151

5252
unsafe extern "C" fn children_fn_wrapper(
53-
plan: *const FFIExecutionPlan,
53+
plan: *const FFI_ExecutionPlan,
5454
num_children: &mut usize,
55-
out: &mut *const FFIExecutionPlan,
55+
out: &mut *const FFI_ExecutionPlan,
5656
) -> i32 {
5757
let private_data = (*plan).private_data as *const ExecutionPlanPrivateData;
5858

5959
let children = (*private_data).plan.children();
6060
*num_children = children.len();
61-
let children: Vec<FFIExecutionPlan> = children
61+
let children: Vec<FFI_ExecutionPlan> = children
6262
.into_iter()
63-
.map(|child| FFIExecutionPlan::new(child.clone()))
63+
.map(|child| FFI_ExecutionPlan::new(child.clone()))
6464
.collect();
6565
*out = children.as_ptr();
6666

@@ -72,7 +72,7 @@ unsafe extern "C" fn children_fn_wrapper(
7272
// in the provider's side.
7373
#[derive(Debug)]
7474
pub struct ExportedExecutionPlan {
75-
plan: *const FFIExecutionPlan,
75+
plan: *const FFI_ExecutionPlan,
7676
properties: PlanProperties,
7777
children: Vec<Arc<dyn ExecutionPlan>>,
7878
}
@@ -88,13 +88,13 @@ impl DisplayAs for ExportedExecutionPlan {
8888
) -> std::fmt::Result {
8989
write!(
9090
f,
91-
"FFIExecutionPlan(number_of_children={})",
91+
"FFI_ExecutionPlan(number_of_children={})",
9292
self.children.len(),
9393
)
9494
}
9595
}
9696

97-
impl FFIExecutionPlan {
97+
impl FFI_ExecutionPlan {
9898
pub fn new(plan: Arc<dyn ExecutionPlan + Send>) -> Self {
9999
let private_data = Box::new(ExecutionPlanPrivateData {
100100
plan,
@@ -123,25 +123,25 @@ impl ExportedExecutionPlan {
123123
/// # Safety
124124
///
125125
/// The caller must ensure the pointer provided points to a valid implementation
126-
/// of FFIExecutionPlan
127-
pub unsafe fn new(plan: *const FFIExecutionPlan) -> Result<Self> {
126+
/// of FFI_ExecutionPlan
127+
pub unsafe fn new(plan: *const FFI_ExecutionPlan) -> Result<Self> {
128128
let properties = unsafe {
129129
let properties_fn = (*plan).properties.ok_or(DataFusionError::NotImplemented(
130-
"properties not implemented on FFIExecutionPlan".to_string(),
130+
"properties not implemented on FFI_ExecutionPlan".to_string(),
131131
))?;
132132
properties_fn(plan).try_into()?
133133
};
134134

135135
let children = unsafe {
136136
let children_fn = (*plan).children.ok_or(DataFusionError::NotImplemented(
137-
"children not implemented on FFIExecutionPlan".to_string(),
137+
"children not implemented on FFI_ExecutionPlan".to_string(),
138138
))?;
139139
let mut num_children = 0;
140-
let mut children_ptr: *const FFIExecutionPlan = null();
140+
let mut children_ptr: *const FFI_ExecutionPlan = null();
141141

142142
if children_fn(plan, &mut num_children, &mut children_ptr) != 0 {
143143
return Err(DataFusionError::Plan(
144-
"Error getting children for FFIExecutionPlan".to_string(),
144+
"Error getting children for FFI_ExecutionPlan".to_string(),
145145
));
146146
}
147147

@@ -197,7 +197,7 @@ impl ExecutionPlan for ExportedExecutionPlan {
197197
}
198198
}
199199

200-
impl DisplayAs for FFIExecutionPlan {
200+
impl DisplayAs for FFI_ExecutionPlan {
201201
fn fmt_as(
202202
&self,
203203
t: datafusion::physical_plan::DisplayFormatType,
@@ -210,61 +210,61 @@ impl DisplayAs for FFIExecutionPlan {
210210
#[repr(C)]
211211
#[derive(Debug)]
212212
#[allow(missing_docs)]
213-
pub struct FFIPlanProperties {
213+
pub struct FFI_PlanProperties {
214214
// We will build equivalence properties from teh schema and ordersing (new_with_orderings). This is how we do ti in dataset_exec
215-
// pub eq_properties: Option<unsafe extern "C" fn(plan: *const FFIPlanProperties) -> EquivalenceProperties>,
215+
// pub eq_properties: Option<unsafe extern "C" fn(plan: *const FFI_PlanProperties) -> EquivalenceProperties>,
216216

217217
// Returns protobuf serialized bytes of the partitioning
218218
pub output_partitioning: Option<
219219
unsafe extern "C" fn(
220-
plan: *const FFIPlanProperties,
220+
plan: *const FFI_PlanProperties,
221221
buffer_size: &mut usize,
222222
buffer_bytes: &mut *mut u8,
223223
) -> i32,
224224
>,
225225

226226
pub execution_mode:
227-
Option<unsafe extern "C" fn(plan: *const FFIPlanProperties) -> FFIExecutionMode>,
227+
Option<unsafe extern "C" fn(plan: *const FFI_PlanProperties) -> FFI_ExecutionMode>,
228228

229229
// PhysicalSortExprNodeCollection proto
230230
pub output_ordering: Option<
231231
unsafe extern "C" fn(
232-
plan: *const FFIPlanProperties,
232+
plan: *const FFI_PlanProperties,
233233
buffer_size: &mut usize,
234234
buffer_bytes: &mut *mut u8,
235235
) -> i32,
236236
>,
237237

238-
pub schema: Option<unsafe extern "C" fn(plan: *const FFIPlanProperties) -> FFI_ArrowSchema>,
238+
pub schema: Option<unsafe extern "C" fn(plan: *const FFI_PlanProperties) -> FFI_ArrowSchema>,
239239
}
240240

241-
impl From<&PlanProperties> for FFIPlanProperties {
241+
impl From<&PlanProperties> for FFI_PlanProperties {
242242
fn from(value: &PlanProperties) -> Self {
243243
todo!()
244244
}
245245
}
246246

247-
impl TryFrom<FFIPlanProperties> for PlanProperties {
247+
impl TryFrom<FFI_PlanProperties> for PlanProperties {
248248
type Error = DataFusionError;
249249

250-
fn try_from(value: FFIPlanProperties) -> std::result::Result<Self, Self::Error> {
250+
fn try_from(value: FFI_PlanProperties) -> std::result::Result<Self, Self::Error> {
251251
unsafe {
252252
let schema_fn = value.schema.ok_or(DataFusionError::NotImplemented(
253-
"schema() not implemented on FFIPlanProperties".to_string(),
253+
"schema() not implemented on FFI_PlanProperties".to_string(),
254254
))?;
255255
let ffi_schema = schema_fn(&value);
256256
let schema: Schema = (&ffi_schema).try_into()?;
257257

258258
let ordering_fn = value
259259
.output_ordering
260260
.ok_or(DataFusionError::NotImplemented(
261-
"output_ordering() not implemented on FFIPlanProperties".to_string(),
261+
"output_ordering() not implemented on FFI_PlanProperties".to_string(),
262262
))?;
263263
let mut buff_size = 0;
264264
let mut buff = null_mut();
265265
if ordering_fn(&value, &mut buff_size, &mut buff) != 0 {
266266
return Err(DataFusionError::Plan(
267-
"Error occurred during FFI call to output_ordering in FFIPlanProperties"
267+
"Error occurred during FFI call to output_ordering in FFI_PlanProperties"
268268
.to_string(),
269269
));
270270
}
@@ -287,11 +287,11 @@ impl TryFrom<FFIPlanProperties> for PlanProperties {
287287
value
288288
.output_partitioning
289289
.ok_or(DataFusionError::NotImplemented(
290-
"output_partitioning() not implemented on FFIPlanProperties".to_string(),
290+
"output_partitioning() not implemented on FFI_PlanProperties".to_string(),
291291
))?;
292292
if partitioning_fn(&value, &mut buff_size, &mut buff) != 0 {
293293
return Err(DataFusionError::Plan(
294-
"Error occurred during FFI call to output_partitioning in FFIPlanProperties"
294+
"Error occurred during FFI call to output_partitioning in FFI_PlanProperties"
295295
.to_string(),
296296
));
297297
}
@@ -309,7 +309,7 @@ impl TryFrom<FFIPlanProperties> for PlanProperties {
309309
.unwrap();
310310

311311
let execution_mode_fn = value.execution_mode.ok_or(DataFusionError::NotImplemented(
312-
"execution_mode() not implemented on FFIPlanProperties".to_string(),
312+
"execution_mode() not implemented on FFI_PlanProperties".to_string(),
313313
))?;
314314
let execution_mode = execution_mode_fn(&value).into();
315315

@@ -319,38 +319,38 @@ impl TryFrom<FFIPlanProperties> for PlanProperties {
319319
Ok(Self::new(eq_properties, partitioning, execution_mode))
320320
}
321321
}
322-
// fn from(value: FFIPlanProperties) -> Self {
322+
// fn from(value: FFI_PlanProperties) -> Self {
323323
// let schema = self.schema()
324324

325325
// let equiv_prop = EquivalenceProperties::new_with_orderings(schema, orderings);
326326
// }
327327
}
328328

329329
#[repr(C)]
330-
pub enum FFIExecutionMode {
330+
pub enum FFI_ExecutionMode {
331331
Bounded,
332332

333333
Unbounded,
334334

335335
PipelineBreaking,
336336
}
337337

338-
impl From<ExecutionMode> for FFIExecutionMode {
338+
impl From<ExecutionMode> for FFI_ExecutionMode {
339339
fn from(value: ExecutionMode) -> Self {
340340
match value {
341-
ExecutionMode::Bounded => FFIExecutionMode::Bounded,
342-
ExecutionMode::Unbounded => FFIExecutionMode::Unbounded,
343-
ExecutionMode::PipelineBreaking => FFIExecutionMode::PipelineBreaking,
341+
ExecutionMode::Bounded => FFI_ExecutionMode::Bounded,
342+
ExecutionMode::Unbounded => FFI_ExecutionMode::Unbounded,
343+
ExecutionMode::PipelineBreaking => FFI_ExecutionMode::PipelineBreaking,
344344
}
345345
}
346346
}
347347

348-
impl From<FFIExecutionMode> for ExecutionMode {
349-
fn from(value: FFIExecutionMode) -> Self {
348+
impl From<FFI_ExecutionMode> for ExecutionMode {
349+
fn from(value: FFI_ExecutionMode) -> Self {
350350
match value {
351-
FFIExecutionMode::Bounded => ExecutionMode::Bounded,
352-
FFIExecutionMode::Unbounded => ExecutionMode::Unbounded,
353-
FFIExecutionMode::PipelineBreaking => ExecutionMode::PipelineBreaking,
351+
FFI_ExecutionMode::Bounded => ExecutionMode::Bounded,
352+
FFI_ExecutionMode::Unbounded => ExecutionMode::Unbounded,
353+
FFI_ExecutionMode::PipelineBreaking => ExecutionMode::PipelineBreaking,
354354
}
355355
}
356356
}

src/ffi/table_provider.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use datafusion::{
2323
use tokio::runtime::Runtime;
2424

2525
use super::{
26-
execution_plan::{ExecutionPlanPrivateData, ExportedExecutionPlan, FFIExecutionPlan},
26+
execution_plan::{ExecutionPlanPrivateData, ExportedExecutionPlan, FFI_ExecutionPlan},
2727
session_config::{FFI_SessionConfig, SessionConfigPrivateData},
2828
};
2929
use datafusion::error::Result;
@@ -44,7 +44,7 @@ pub struct FFI_TableProvider {
4444
n_filters: c_int,
4545
filters: *const *const c_char,
4646
limit: c_int,
47-
out: *mut FFIExecutionPlan,
47+
out: *mut FFI_ExecutionPlan,
4848
) -> c_int,
4949
>,
5050
pub private_data: *mut c_void,
@@ -73,7 +73,7 @@ unsafe extern "C" fn provider_scan(
7373
n_filters: c_int,
7474
filters: *const *const c_char,
7575
limit: c_int,
76-
mut out: *mut FFIExecutionPlan,
76+
mut out: *mut FFI_ExecutionPlan,
7777
) -> c_int {
7878
let config = unsafe { (*session_config).private_data as *const SessionConfigPrivateData };
7979
let session = SessionStateBuilder::new()
@@ -135,7 +135,7 @@ impl ExportedTableProvider {
135135
projections: Option<&Vec<usize>>,
136136
filters: Vec<String>,
137137
limit: Option<usize>,
138-
) -> Result<FFIExecutionPlan> {
138+
) -> Result<FFI_ExecutionPlan> {
139139
let private_data = self.get_private_data();
140140
let provider = &private_data.provider;
141141

@@ -155,10 +155,10 @@ impl ExportedTableProvider {
155155
// last_error: None,
156156
// });
157157

158-
// Ok(FFIExecutionPlan {
158+
// Ok(FFI_ExecutionPlan {
159159
// private_data: Box::into_raw(plan_ptr) as *mut c_void,
160160
// })
161-
Ok(FFIExecutionPlan::new(plan))
161+
Ok(FFI_ExecutionPlan::new(plan))
162162
}
163163
}
164164

@@ -273,7 +273,7 @@ impl TableProvider for FFI_TableProvider {
273273
None => -1,
274274
};
275275

276-
let mut out = FFIExecutionPlan::empty();
276+
let mut out = FFI_ExecutionPlan::empty();
277277

278278
let plan = unsafe {
279279
let err_code = scan_fn(

0 commit comments

Comments
 (0)