Skip to content

Commit 2fa1b82

Browse files
authored
Merge pull request #6 from alamb/alamb/just_use_arc
Use Arc all the way down
2 parents 55d3b73 + 92af2d7 commit 2fa1b82

File tree

5 files changed

+16
-27
lines changed

5 files changed

+16
-27
lines changed

datafusion/core/src/execution/session_state.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -734,18 +734,13 @@ impl SessionState {
734734
}
735735

736736
/// return the configuration options
737-
pub fn config_options(&self) -> &ConfigOptions {
737+
pub fn config_options(&self) -> &Arc<ConfigOptions> {
738738
self.config.options()
739739
}
740740

741-
/// return the configuration options
742-
pub fn config_options_arc(&self) -> Arc<ConfigOptions> {
743-
self.config.options_arc()
744-
}
745-
746741
/// Mark the start of the execution
747742
pub fn start_execution(&mut self) {
748-
let config = self.config.options_arc();
743+
let config = Arc::clone(self.config.options());
749744
self.execution_props.start_execution(config);
750745
}
751746

@@ -1899,7 +1894,7 @@ impl OptimizerConfig for SessionState {
18991894
}
19001895

19011896
fn options(&self) -> Arc<ConfigOptions> {
1902-
self.config_options_arc()
1897+
Arc::clone(self.config.options())
19031898
}
19041899

19051900
fn function_registry(&self) -> Option<&dyn FunctionRegistry> {

datafusion/core/tests/parquet/file_statistics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use datafusion_execution::runtime_env::RuntimeEnvBuilder;
3838
use datafusion_expr::{col, lit, Expr};
3939

4040
use datafusion::datasource::physical_plan::FileScanConfig;
41+
use datafusion_common::config::ConfigOptions;
4142
use datafusion_physical_optimizer::filter_pushdown::FilterPushdown;
4243
use datafusion_physical_optimizer::PhysicalOptimizerRule;
4344
use datafusion_physical_plan::filter::FilterExec;
@@ -55,7 +56,7 @@ async fn check_stats_precision_with_filter_pushdown() {
5556
let table = get_listing_table(&table_path, None, &opt).await;
5657

5758
let (_, _, state) = get_cache_runtime_state();
58-
let mut options = state.config().options().clone();
59+
let mut options: ConfigOptions = state.config().options().as_ref().clone();
5960
options.execution.parquet.pushdown_filters = true;
6061

6162
// Scan without filter, stats are exact

datafusion/execution/src/config.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,10 @@ impl SessionConfig {
136136
/// let config = SessionConfig::new();
137137
/// assert!(config.options().execution.batch_size > 0);
138138
/// ```
139-
pub fn options(&self) -> &ConfigOptions {
139+
pub fn options(&self) -> &Arc<ConfigOptions> {
140140
&self.options
141141
}
142142

143-
/// Returns the config options as an Arc
144-
pub fn options_arc(&self) -> Arc<ConfigOptions> {
145-
Arc::clone(&self.options)
146-
}
147-
148143
/// Return a mutable handle to the configuration options.
149144
///
150145
/// Can be used to set configuration options.

datafusion/ffi/src/session_config.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use std::{
19-
collections::HashMap,
20-
ffi::{c_char, c_void, CString},
21-
};
22-
2318
use abi_stable::{
2419
std_types::{RHashMap, RString},
2520
StableAbi,
2621
};
2722
use datafusion::{config::ConfigOptions, error::Result};
2823
use datafusion::{error::DataFusionError, prelude::SessionConfig};
24+
use std::sync::Arc;
25+
use std::{
26+
collections::HashMap,
27+
ffi::{c_char, c_void, CString},
28+
};
2929

3030
/// A stable struct for sharing [`SessionConfig`] across FFI boundaries.
3131
/// Instead of attempting to expose the entire SessionConfig interface, we
@@ -85,11 +85,9 @@ unsafe extern "C" fn release_fn_wrapper(config: &mut FFI_SessionConfig) {
8585

8686
unsafe extern "C" fn clone_fn_wrapper(config: &FFI_SessionConfig) -> FFI_SessionConfig {
8787
let old_private_data = config.private_data as *mut SessionConfigPrivateData;
88-
let old_config = &(*old_private_data).config;
88+
let old_config = Arc::clone(&(*old_private_data).config);
8989

90-
let private_data = Box::new(SessionConfigPrivateData {
91-
config: old_config.clone(),
92-
});
90+
let private_data = Box::new(SessionConfigPrivateData { config: old_config });
9391

9492
FFI_SessionConfig {
9593
config_options: config_options_fn_wrapper,
@@ -100,7 +98,7 @@ unsafe extern "C" fn clone_fn_wrapper(config: &FFI_SessionConfig) -> FFI_Session
10098
}
10199

102100
struct SessionConfigPrivateData {
103-
pub config: ConfigOptions,
101+
pub config: Arc<ConfigOptions>,
104102
}
105103

106104
impl From<&SessionConfig> for FFI_SessionConfig {
@@ -120,7 +118,7 @@ impl From<&SessionConfig> for FFI_SessionConfig {
120118
}
121119

122120
let private_data = Box::new(SessionConfigPrivateData {
123-
config: session.options().clone(),
121+
config: Arc::clone(session.options()),
124122
});
125123

126124
Self {

datafusion/physical-plan/src/async_func.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl ExecutionPlan for AsyncFuncExec {
176176
// now, for each record batch, evaluate the async expressions and add the columns to the result
177177
let async_exprs_captured = Arc::new(self.async_exprs.clone());
178178
let schema_captured = self.schema();
179-
let config_options_ref = Arc::new(context.session_config().options().clone());
179+
let config_options_ref = Arc::clone(context.session_config().options());
180180

181181
let stream_with_async_functions = input_stream.then(move |batch| {
182182
// need to clone *again* to capture the async_exprs and schema in the

0 commit comments

Comments
 (0)