|
21 | 21 | use datafusion_common::stats::Precision;
|
22 | 22 | use datafusion_common::{ColumnStatistics, ScalarValue, Statistics};
|
23 | 23 | use std::mem;
|
| 24 | +use std::sync::Arc; |
24 | 25 |
|
25 | 26 | /// Represents statistics data grouped by partition.
|
26 | 27 | ///
|
27 | 28 | /// This structure maintains a collection of statistics, one for each partition
|
28 | 29 | /// of a distributed dataset, allowing access to statistics by partition index.
|
29 | 30 | #[derive(Debug, Clone)]
|
30 | 31 | pub struct PartitionedStatistics {
|
31 |
| - inner: Vec<Statistics>, |
| 32 | + inner: Vec<Arc<Statistics>>, |
32 | 33 | }
|
33 | 34 |
|
34 | 35 | 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 { |
37 | 37 | Self { inner: statistics }
|
38 | 38 | }
|
39 | 39 |
|
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. |
55 | 40 | pub fn statistics(&self, partition_idx: usize) -> &Statistics {
|
56 | 41 | &self.inner[partition_idx]
|
57 | 42 | }
|
58 | 43 |
|
59 |
| - /// Returns the statistics for the specified partition, or None if the index is out of bounds. |
60 | 44 | 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()) |
62 | 46 | }
|
63 | 47 |
|
64 |
| - /// Returns an iterator over the statistics. |
65 | 48 | pub fn iter(&self) -> impl Iterator<Item = &Statistics> {
|
66 |
| - self.inner.iter() |
| 49 | + self.inner.iter().map(|arc| arc.as_ref()) |
67 | 50 | }
|
68 | 51 | }
|
69 | 52 |
|
|
0 commit comments