Skip to content

Commit 2653c63

Browse files
authored
Minor: add Arc for statistics in FileGroup (#15564)
1 parent f7b77a1 commit 2653c63

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

datafusion/datasource/src/file_groups.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use std::collections::BinaryHeap;
2525
use std::iter::repeat_with;
2626
use std::mem;
2727
use std::ops::{Index, IndexMut};
28+
use std::sync::Arc;
2829

2930
/// Repartition input files into `target_partitions` partitions, if total file size exceed
3031
/// `repartition_file_min_size`
@@ -368,7 +369,7 @@ pub struct FileGroup {
368369
/// The files in this group
369370
files: Vec<PartitionedFile>,
370371
/// Optional statistics for the data across all files in the group
371-
statistics: Option<Statistics>,
372+
statistics: Option<Arc<Statistics>>,
372373
}
373374

374375
impl FileGroup {
@@ -386,7 +387,7 @@ impl FileGroup {
386387
}
387388

388389
/// Set the statistics for this group
389-
pub fn with_statistics(mut self, statistics: Statistics) -> Self {
390+
pub fn with_statistics(mut self, statistics: Arc<Statistics>) -> Self {
390391
self.statistics = Some(statistics);
391392
self
392393
}
@@ -420,7 +421,7 @@ impl FileGroup {
420421

421422
/// Get the statistics for this group
422423
pub fn statistics(&self) -> Option<&Statistics> {
423-
self.statistics.as_ref()
424+
self.statistics.as_deref()
424425
}
425426

426427
/// Partition the list of files into `n` groups

datafusion/datasource/src/statistics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ pub fn compute_file_group_statistics(
494494
file.statistics.as_ref().map(|stats| stats.as_ref())
495495
});
496496

497-
Ok(file_group.with_statistics(statistics))
497+
Ok(file_group.with_statistics(Arc::new(statistics)))
498498
}
499499

500500
/// Computes statistics for all files across multiple file groups.

0 commit comments

Comments
 (0)