Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions datafusion/execution/src/cache/cache_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ impl CacheManager {
pub fn try_new(config: &CacheManagerConfig) -> Result<Arc<Self>> {
let mut manager = CacheManager::default();
if let Some(cc) = &config.table_files_statistics_cache {
manager.file_statistic_cache = Some(cc.clone())
manager.file_statistic_cache = Some(Arc::clone(cc))
}
if let Some(lc) = &config.list_files_cache {
manager.list_files_cache = Some(lc.clone())
manager.list_files_cache = Some(Arc::clone(lc))
}
Ok(Arc::new(manager))
}
Expand Down
6 changes: 3 additions & 3 deletions datafusion/execution/src/cache/cache_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl CacheAccessor<Path, Arc<Statistics>> for DefaultFileStatisticsCache {
fn get(&self, k: &Path) -> Option<Arc<Statistics>> {
self.statistics
.get(k)
.map(|s| Some(s.value().1.clone()))
.map(|s| Some(Arc::clone(&s.value().1)))
.unwrap_or(None)
}

Expand All @@ -55,7 +55,7 @@ impl CacheAccessor<Path, Arc<Statistics>> for DefaultFileStatisticsCache {
// file has changed
None
} else {
Some(statistics.clone())
Some(Arc::clone(statistics))
}
})
.unwrap_or(None)
Expand Down Expand Up @@ -108,7 +108,7 @@ impl CacheAccessor<Path, Arc<Vec<ObjectMeta>>> for DefaultListFilesCache {
type Extra = ObjectMeta;

fn get(&self, k: &Path) -> Option<Arc<Vec<ObjectMeta>>> {
self.statistics.get(k).map(|x| x.value().clone())
self.statistics.get(k).map(|x| Arc::clone(x.value()))
}

fn get_with_extra(
Expand Down
2 changes: 1 addition & 1 deletion datafusion/execution/src/disk_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl DiskManager {

let dir_index = thread_rng().gen_range(0..local_dirs.len());
Ok(RefCountedTempFile {
parent_temp_dir: local_dirs[dir_index].clone(),
parent_temp_dir: Arc::clone(&local_dirs[dir_index]),
tempfile: Builder::new()
.tempfile_in(local_dirs[dir_index].as_ref())
.map_err(DataFusionError::IoError)?,
Expand Down
2 changes: 2 additions & 0 deletions datafusion/execution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Make cheap clones clear: https://github.com/apache/datafusion/issues/11143
#![deny(clippy::clone_on_ref_ptr)]

//! DataFusion execution configuration and runtime structures

Expand Down
4 changes: 2 additions & 2 deletions datafusion/execution/src/memory_pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,15 @@ impl MemoryReservation {
self.size = self.size.checked_sub(capacity).unwrap();
Self {
size: capacity,
registration: self.registration.clone(),
registration: Arc::clone(&self.registration),
}
}

/// Returns a new empty [`MemoryReservation`] with the same [`MemoryConsumer`]
pub fn new_empty(&self) -> Self {
Self {
size: 0,
registration: self.registration.clone(),
registration: Arc::clone(&self.registration),
}
}

Expand Down
2 changes: 1 addition & 1 deletion datafusion/execution/src/object_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl ObjectStoreRegistry for DefaultObjectStoreRegistry {
let s = get_url_key(url);
self.object_stores
.get(&s)
.map(|o| o.value().clone())
.map(|o| Arc::clone(o.value()))
.ok_or_else(|| {
DataFusionError::Internal(format!(
"No suitable object store found for {url}. See `RuntimeEnv::register_object_store`"
Expand Down
11 changes: 7 additions & 4 deletions datafusion/execution/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl TaskContext {

/// Return the [RuntimeEnv] associated with this [TaskContext]
pub fn runtime_env(&self) -> Arc<RuntimeEnv> {
self.runtime.clone()
Arc::clone(&self.runtime)
}

/// Update the [`SessionConfig`]
Expand Down Expand Up @@ -172,19 +172,22 @@ impl FunctionRegistry for TaskContext {
udaf: Arc<AggregateUDF>,
) -> Result<Option<Arc<AggregateUDF>>> {
udaf.aliases().iter().for_each(|alias| {
self.aggregate_functions.insert(alias.clone(), udaf.clone());
self.aggregate_functions
.insert(alias.clone(), Arc::clone(&udaf));
});
Ok(self.aggregate_functions.insert(udaf.name().into(), udaf))
}
fn register_udwf(&mut self, udwf: Arc<WindowUDF>) -> Result<Option<Arc<WindowUDF>>> {
udwf.aliases().iter().for_each(|alias| {
self.window_functions.insert(alias.clone(), udwf.clone());
self.window_functions
.insert(alias.clone(), Arc::clone(&udwf));
});
Ok(self.window_functions.insert(udwf.name().into(), udwf))
}
fn register_udf(&mut self, udf: Arc<ScalarUDF>) -> Result<Option<Arc<ScalarUDF>>> {
udf.aliases().iter().for_each(|alias| {
self.scalar_functions.insert(alias.clone(), udf.clone());
self.scalar_functions
.insert(alias.clone(), Arc::clone(&udf));
});
Ok(self.scalar_functions.insert(udf.name().into(), udf))
}
Expand Down