Skip to content

Commit acc80c5

Browse files
committed
use Arc
1 parent 7c23abf commit acc80c5

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

datafusion/physical-plan/src/statistics.rs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,32 @@
2121
use datafusion_common::stats::Precision;
2222
use datafusion_common::{ColumnStatistics, ScalarValue, Statistics};
2323
use std::mem;
24+
use std::sync::Arc;
2425

2526
/// Represents statistics data grouped by partition.
2627
///
2728
/// This structure maintains a collection of statistics, one for each partition
2829
/// of a distributed dataset, allowing access to statistics by partition index.
2930
#[derive(Debug, Clone)]
3031
pub struct PartitionedStatistics {
31-
inner: Vec<Statistics>,
32+
inner: Vec<Arc<Statistics>>,
3233
}
3334

3435
impl PartitionedStatistics {
35-
/// Creates a new PartitionedStatistics instance from a vector of Statistics.
36-
pub fn new(statistics: Vec<Statistics>) -> Self {
36+
pub fn new(statistics: Vec<Arc<Statistics>>) -> Self {
3737
Self { inner: statistics }
3838
}
3939

40-
/// Returns the number of partitions.
41-
pub fn len(&self) -> usize {
42-
self.inner.len()
43-
}
44-
45-
/// Returns true if there are no partitions.
46-
pub fn is_empty(&self) -> bool {
47-
self.inner.is_empty()
48-
}
49-
50-
/// Returns the statistics for the specified partition.
51-
///
52-
/// # Panics
53-
///
54-
/// Panics if `partition_idx` is out of bounds.
5540
pub fn statistics(&self, partition_idx: usize) -> &Statistics {
5641
&self.inner[partition_idx]
5742
}
5843

59-
/// Returns the statistics for the specified partition, or None if the index is out of bounds.
6044
pub fn get_statistics(&self, partition_idx: usize) -> Option<&Statistics> {
61-
self.inner.get(partition_idx)
45+
self.inner.get(partition_idx).map(|arc| arc.as_ref())
6246
}
6347

64-
/// Returns an iterator over the statistics.
6548
pub fn iter(&self) -> impl Iterator<Item = &Statistics> {
66-
self.inner.iter()
49+
self.inner.iter().map(|arc| arc.as_ref())
6750
}
6851
}
6952

0 commit comments

Comments
 (0)