Skip to content

Commit d6194b8

Browse files
committed
cargo_fmt_fix_test_accessor_method
1 parent d0ab1fb commit d6194b8

16 files changed

Lines changed: 50 additions & 171 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_catalog.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,14 @@ mod tests {
2424
use std::sync::Arc;
2525

2626
use datafusion::catalog::{CatalogProvider, CatalogProviderList};
27-
use datafusion_common::DataFusionError;
2827
use datafusion_ffi::tests::utils::get_module;
2928

3029
#[tokio::test]
3130
async fn test_catalog() -> datafusion_common::Result<()> {
3231
let module = get_module()?;
3332
let (ctx, codec) = super::utils::ctx_and_codec();
3433

35-
let ffi_catalog =
36-
module
37-
.create_catalog()
38-
.ok_or(DataFusionError::NotImplemented(
39-
"External catalog provider failed to implement create_catalog"
40-
.to_string(),
41-
))?(codec);
34+
let ffi_catalog = (module.create_catalog)(codec);
4235
let foreign_catalog: Arc<dyn CatalogProvider + Send> = (&ffi_catalog).into();
4336

4437
let _ = ctx.register_catalog("fruit", foreign_catalog);
@@ -59,13 +52,7 @@ mod tests {
5952
let module = get_module()?;
6053
let (ctx, codec) = super::utils::ctx_and_codec();
6154

62-
let ffi_catalog_list =
63-
module
64-
.create_catalog_list()
65-
.ok_or(DataFusionError::NotImplemented(
66-
"External catalog provider failed to implement create_catalog_list"
67-
.to_string(),
68-
))?(codec);
55+
let ffi_catalog_list = (module.create_catalog_list)(codec);
6956
let foreign_catalog_list: Arc<dyn CatalogProviderList + Send> =
7057
(&ffi_catalog_list).into();
7158

datafusion/ffi/tests/ffi_config.rs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/// when the feature integration-tests is built
2020
#[cfg(feature = "integration-tests")]
2121
mod tests {
22-
use datafusion::error::{DataFusionError, Result};
22+
use datafusion::error::Result;
2323
use datafusion_common::ScalarValue;
2424
use datafusion_common::config::{ConfigOptions, TableOptions};
2525
use datafusion_execution::config::SessionConfig;
@@ -31,13 +31,7 @@ mod tests {
3131
fn test_ffi_config_options_extension() -> Result<()> {
3232
let module = get_module()?;
3333

34-
let extension_options =
35-
module
36-
.create_extension_options()
37-
.ok_or(DataFusionError::NotImplemented(
38-
"External test library failed to implement create_extension_options"
39-
.to_string(),
40-
))?();
34+
let extension_options = (module.create_extension_options)();
4135

4236
let mut config = ConfigOptions::new();
4337
config.extensions.insert(extension_options);
@@ -61,13 +55,7 @@ mod tests {
6155
fn test_ffi_table_options_extension() -> Result<()> {
6256
let module = get_module()?;
6357

64-
let extension_options =
65-
module
66-
.create_extension_options()
67-
.ok_or(DataFusionError::NotImplemented(
68-
"External test library failed to implement create_extension_options"
69-
.to_string(),
70-
))?();
58+
let extension_options = (module.create_extension_options)();
7159

7260
let mut table_options = TableOptions::new();
7361
table_options.extensions.insert(extension_options);
@@ -92,13 +80,7 @@ mod tests {
9280
fn test_ffi_session_config_options_extension() -> Result<()> {
9381
let module = get_module()?;
9482

95-
let extension_options =
96-
module
97-
.create_extension_options()
98-
.ok_or(DataFusionError::NotImplemented(
99-
"External test library failed to implement create_extension_options"
100-
.to_string(),
101-
))?();
83+
let extension_options = (module.create_extension_options)();
10284

10385
let mut config = SessionConfig::new().with_option_extension(extension_options);
10486

0 commit comments

Comments
 (0)