Skip to content

Commit 70a5478

Browse files
committed
cargo_fmt_fix_test_accessor_method
1 parent d0ab1fb commit 70a5478

10 files changed

Lines changed: 32 additions & 74 deletions

File tree

datafusion/ffi/src/config/extension_options.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ pub struct FFI_ExtensionOptions {
4747
pub cloned: unsafe extern "C" fn(&Self) -> FFI_ExtensionOptions,
4848

4949
/// Set the given `key`, `value` pair
50-
pub set: unsafe extern "C" fn(
51-
&mut Self,
52-
key: SStr,
53-
value: SStr,
54-
) -> FFIResult<()>,
50+
pub set: unsafe extern "C" fn(&mut Self, key: SStr, value: SStr) -> FFIResult<()>,
5551

5652
/// Returns the [`ConfigEntry`] stored in this [`ExtensionOptions`]
5753
pub entries: unsafe extern "C" fn(&Self) -> SVec<(SString, SString)>,

datafusion/ffi/src/execution/task_ctx.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,14 @@ pub struct FFI_TaskContext {
4848
pub session_config: unsafe extern "C" fn(&Self) -> FFI_SessionConfig,
4949

5050
/// Returns a vec of name-function pairs for scalar functions.
51-
pub scalar_functions:
52-
unsafe extern "C" fn(&Self) -> SVec<(SString, FFI_ScalarUDF)>,
51+
pub scalar_functions: unsafe extern "C" fn(&Self) -> SVec<(SString, FFI_ScalarUDF)>,
5352

5453
/// Returns a vec of name-function pairs for aggregate functions.
5554
pub aggregate_functions:
5655
unsafe extern "C" fn(&Self) -> SVec<(SString, FFI_AggregateUDF)>,
5756

5857
/// Returns a vec of name-function pairs for window functions.
59-
pub window_functions:
60-
unsafe extern "C" fn(&Self) -> SVec<(SString, FFI_WindowUDF)>,
58+
pub window_functions: unsafe extern "C" fn(&Self) -> SVec<(SString, FFI_WindowUDF)>,
6159

6260
/// Release the memory of the private data when it is no longer being used.
6361
pub release: unsafe extern "C" fn(arg: &mut Self),
@@ -92,9 +90,7 @@ unsafe extern "C" fn session_id_fn_wrapper(ctx: &FFI_TaskContext) -> SString {
9290
}
9391
}
9492

95-
unsafe extern "C" fn task_id_fn_wrapper(
96-
ctx: &FFI_TaskContext,
97-
) -> FfiOption<SString> {
93+
unsafe extern "C" fn task_id_fn_wrapper(ctx: &FFI_TaskContext) -> FfiOption<SString> {
9894
unsafe {
9995
let ctx = ctx.inner();
10096
ctx.task_id().map(|s| s.as_str().into()).into()

datafusion/ffi/src/physical_expr/mod.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,8 @@ pub struct FFI_PhysicalExpr {
7777

7878
pub children: unsafe extern "C" fn(&Self) -> SVec<FFI_PhysicalExpr>,
7979

80-
pub new_with_children: unsafe extern "C" fn(
81-
&Self,
82-
children: &SVec<FFI_PhysicalExpr>,
83-
) -> FFIResult<Self>,
80+
pub new_with_children:
81+
unsafe extern "C" fn(&Self, children: &SVec<FFI_PhysicalExpr>) -> FFIResult<Self>,
8482

8583
pub evaluate_bounds: unsafe extern "C" fn(
8684
&Self,
@@ -99,13 +97,12 @@ pub struct FFI_PhysicalExpr {
9997
children: SVec<FFI_Distribution>,
10098
) -> FFIResult<FFI_Distribution>,
10199

102-
pub propagate_statistics: unsafe extern "C" fn(
103-
&Self,
104-
parent: FFI_Distribution,
105-
children: SVec<FFI_Distribution>,
106-
) -> FFIResult<
107-
FfiOption<SVec<FFI_Distribution>>,
108-
>,
100+
pub propagate_statistics:
101+
unsafe extern "C" fn(
102+
&Self,
103+
parent: FFI_Distribution,
104+
children: SVec<FFI_Distribution>,
105+
) -> FFIResult<FfiOption<SVec<FFI_Distribution>>>,
109106

110107
pub get_properties: unsafe extern "C" fn(
111108
&Self,
@@ -360,9 +357,7 @@ unsafe extern "C" fn get_properties_fn_wrapper(
360357
)
361358
}
362359

363-
unsafe extern "C" fn fmt_sql_fn_wrapper(
364-
expr: &FFI_PhysicalExpr,
365-
) -> FFIResult<SString> {
360+
unsafe extern "C" fn fmt_sql_fn_wrapper(expr: &FFI_PhysicalExpr) -> FFIResult<SString> {
366361
let expr = expr.inner();
367362
let result = fmt_sql(expr.as_ref()).to_string();
368363
FfiResult::Ok(result.into())

datafusion/ffi/src/session/mod.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,15 @@ pub(crate) struct FFI_SessionRef {
9494
schema: WrappedSchema,
9595
) -> FFIResult<FFI_PhysicalExpr>,
9696

97-
scalar_functions:
98-
unsafe extern "C" fn(&Self) -> SVec<(SString, FFI_ScalarUDF)>,
97+
scalar_functions: unsafe extern "C" fn(&Self) -> SVec<(SString, FFI_ScalarUDF)>,
9998

100-
aggregate_functions:
101-
unsafe extern "C" fn(&Self) -> SVec<(SString, FFI_AggregateUDF)>,
99+
aggregate_functions: unsafe extern "C" fn(&Self) -> SVec<(SString, FFI_AggregateUDF)>,
102100

103-
window_functions:
104-
unsafe extern "C" fn(&Self) -> SVec<(SString, FFI_WindowUDF)>,
101+
window_functions: unsafe extern "C" fn(&Self) -> SVec<(SString, FFI_WindowUDF)>,
105102

106103
table_options: unsafe extern "C" fn(&Self) -> SVec<(SString, SString)>,
107104

108-
default_table_options:
109-
unsafe extern "C" fn(&Self) -> SVec<(SString, SString)>,
105+
default_table_options: unsafe extern "C" fn(&Self) -> SVec<(SString, SString)>,
110106

111107
task_ctx: unsafe extern "C" fn(&Self) -> FFI_TaskContext,
112108

@@ -245,9 +241,7 @@ unsafe extern "C" fn window_functions_fn_wrapper(
245241
.collect()
246242
}
247243

248-
fn table_options_to_rhash(
249-
mut options: TableOptions,
250-
) -> SVec<(SString, SString)> {
244+
fn table_options_to_rhash(mut options: TableOptions) -> SVec<(SString, SString)> {
251245
// It is important that we mutate options here and set current format
252246
// to None so that when we call `entries()` we get ALL format entries.
253247
// We will pass current_format as a special case and strip it on the
@@ -466,9 +460,7 @@ impl Clone for FFI_SessionRef {
466460
}
467461
}
468462

469-
fn table_options_from_rhashmap(
470-
options: SVec<(SString, SString)>,
471-
) -> TableOptions {
463+
fn table_options_from_rhashmap(options: SVec<(SString, SString)>) -> TableOptions {
472464
let mut options: HashMap<String, String> = options
473465
.into_iter()
474466
.map(|kv_pair| (kv_pair.0.to_string(), kv_pair.1.to_string()))

datafusion/ffi/src/table_provider.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ pub struct FFI_TableProvider {
123123
unsafe extern "C" fn(
124124
provider: &FFI_TableProvider,
125125
filters_serialized: SVec<u8>,
126-
)
127-
-> FFIResult<SVec<FfiTableProviderFilterPushDown>>,
126+
) -> FFIResult<SVec<FfiTableProviderFilterPushDown>>,
128127
>,
129128

130129
insert_into: unsafe extern "C" fn(

datafusion/ffi/src/udaf/accumulator.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,11 @@ pub struct FFI_Accumulator {
4545
) -> FFIResult<()>,
4646

4747
// Evaluate and return a ScalarValues as protobuf bytes
48-
pub evaluate:
49-
unsafe extern "C" fn(accumulator: &mut Self) -> FFIResult<SVec<u8>>,
48+
pub evaluate: unsafe extern "C" fn(accumulator: &mut Self) -> FFIResult<SVec<u8>>,
5049

5150
pub size: unsafe extern "C" fn(accumulator: &Self) -> usize,
5251

53-
pub state: unsafe extern "C" fn(
54-
accumulator: &mut Self,
55-
) -> FFIResult<SVec<SVec<u8>>>,
52+
pub state: unsafe extern "C" fn(accumulator: &mut Self) -> FFIResult<SVec<SVec<u8>>>,
5653

5754
pub merge_batch: unsafe extern "C" fn(
5855
accumulator: &mut Self,

datafusion/ffi/src/udtf.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ use crate::{df_result, rresult_return};
4646
pub struct FFI_TableFunction {
4747
/// Equivalent to the `call` function of the TableFunctionImpl.
4848
/// The arguments are Expr passed as protobuf encoded bytes.
49-
pub call: unsafe extern "C" fn(
50-
udtf: &Self,
51-
args: SVec<u8>,
52-
) -> FFIResult<FFI_TableProvider>,
49+
pub call:
50+
unsafe extern "C" fn(udtf: &Self, args: SVec<u8>) -> FFIResult<FFI_TableProvider>,
5351

5452
pub logical_codec: FFI_LogicalExtensionCodec,
5553

datafusion/ffi/src/util.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,8 @@ pub(crate) mod tests {
160160
const VALID_VALUE: &str = "valid_value";
161161
const ERROR_VALUE: &str = "error_value";
162162

163-
let ok_r_result: FFIResult<SString> =
164-
FfiResult::Ok(SString::from(VALID_VALUE));
165-
let err_r_result: FFIResult<SString> =
166-
FfiResult::Err(SString::from(ERROR_VALUE));
163+
let ok_r_result: FFIResult<SString> = FfiResult::Ok(SString::from(VALID_VALUE));
164+
let err_r_result: FFIResult<SString> = FfiResult::Err(SString::from(ERROR_VALUE));
167165

168166
let returned_ok_result = df_result!(ok_r_result);
169167
assert!(returned_ok_result.is_ok());

datafusion/ffi/tests/ffi_integration.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mod tests {
2626

2727
use arrow::datatypes::Schema;
2828
use datafusion::catalog::{TableProvider, TableProviderFactory};
29-
use datafusion::error::{DataFusionError, Result};
29+
use datafusion::error::Result;
3030
use datafusion_common::TableReference;
3131
use datafusion_common::ToDFSchema;
3232
use datafusion_expr::CreateExternalTable;
@@ -42,11 +42,7 @@ mod tests {
4242

4343
// By calling the code below, the table provided will be created within
4444
// the module's code.
45-
let ffi_table_provider = table_provider_module.create_table().ok_or(
46-
DataFusionError::NotImplemented(
47-
"External table provider failed to implement create_table".to_string(),
48-
),
49-
)?(synchronous, codec);
45+
let ffi_table_provider = (table_provider_module.create_table)(synchronous, codec);
5046

5147
// In order to access the table provider within this executable, we need to
5248
// turn it into a `TableProvider`.
@@ -80,11 +76,8 @@ mod tests {
8076
let table_provider_module = get_module()?;
8177
let (ctx, codec) = super::utils::ctx_and_codec();
8278

83-
let ffi_table_provider_factory = table_provider_module
84-
.create_table_factory()
85-
.ok_or(DataFusionError::NotImplemented(
86-
"External table provider factory failed to implement create".to_string(),
87-
))?(codec);
79+
let ffi_table_provider_factory =
80+
(table_provider_module.create_table_factory)(codec);
8881

8982
let foreign_table_provider_factory: Arc<dyn TableProviderFactory> =
9083
(&ffi_table_provider_factory).into();

datafusion/ffi/tests/ffi_udwf.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod tests {
2222
use std::sync::Arc;
2323

2424
use arrow::array::{ArrayRef, create_array};
25-
use datafusion::error::{DataFusionError, Result};
25+
use datafusion::error::Result;
2626
use datafusion::logical_expr::expr::Sort;
2727
use datafusion::logical_expr::{ExprFunctionExt, WindowUDF, WindowUDFImpl, col};
2828
use datafusion::prelude::SessionContext;
@@ -33,13 +33,7 @@ mod tests {
3333
async fn test_rank_udwf() -> Result<()> {
3434
let module = get_module()?;
3535

36-
let ffi_rank_func =
37-
module
38-
.create_rank_udwf()
39-
.ok_or(DataFusionError::NotImplemented(
40-
"External table provider failed to implement create_scalar_udf"
41-
.to_string(),
42-
))?();
36+
let ffi_rank_func = (module.create_rank_udwf)();
4337
let foreign_rank_func: Arc<dyn WindowUDFImpl> = (&ffi_rank_func).into();
4438

4539
let udwf = WindowUDF::new_from_shared_impl(foreign_rank_func);

0 commit comments

Comments
 (0)