use vortex_error::VortexResult;
use crate::array::chunked::ChunkedArray;
use crate::array::ChunkedEncoding;
use crate::stats::{ArrayStatistics, Stat, StatisticsVTable, StatsSet};
impl StatisticsVTable<ChunkedArray> for ChunkedEncoding {
fn compute_statistics(&self, array: &ChunkedArray, stat: Stat) -> VortexResult<StatsSet> {
Ok(array
.chunks()
.map(|c| {
let s = c.statistics();
match stat {
Stat::IsConstant | Stat::IsSorted | Stat::IsStrictSorted => {
s.compute_all(&[stat, Stat::Min, Stat::Max]).ok()
}
_ => s.compute(stat).map(|s| StatsSet::of(stat, s)),
}
.unwrap_or_default()
})
.reduce(|acc, x| acc.merge_ordered(&x))
.unwrap_or_default())
}
}