diff --git a/deps/fastlanez b/deps/fastlanez index e1bc9e3ebf..b4dfae3cc0 160000 --- a/deps/fastlanez +++ b/deps/fastlanez @@ -1 +1 @@ -Subproject commit e1bc9e3ebfeedaaad19a21db895ed3c458b6ef21 +Subproject commit b4dfae3cc006eec80139a02eabd996fcb79c6512 diff --git a/vortex-alp/src/stats.rs b/vortex-alp/src/stats.rs index f19d5a6e81..e9088da931 100644 --- a/vortex-alp/src/stats.rs +++ b/vortex-alp/src/stats.rs @@ -1,11 +1,12 @@ use std::collections::HashMap; +use vortex::error::VortexResult; use crate::ALPArray; use vortex::stats::{Stat, StatsCompute, StatsSet}; impl StatsCompute for ALPArray { - fn compute(&self, _stat: &Stat) -> StatsSet { + fn compute(&self, _stat: &Stat) -> VortexResult { // TODO(ngates): implement based on the encoded array - StatsSet::from(HashMap::new()) + Ok(StatsSet::from(HashMap::new())) } } diff --git a/vortex-dict/src/stats.rs b/vortex-dict/src/stats.rs index e8b647b070..020e046da8 100644 --- a/vortex-dict/src/stats.rs +++ b/vortex-dict/src/stats.rs @@ -1,9 +1,10 @@ +use vortex::error::VortexResult; use vortex::stats::{Stat, StatsCompute, StatsSet}; use crate::dict::DictArray; impl StatsCompute for DictArray { - fn compute(&self, _stat: &Stat) -> StatsSet { + fn compute(&self, _stat: &Stat) -> VortexResult { let mut stats = StatsSet::new(); if let Some(rc) = self.codes().stats().get_or_compute(&Stat::RunCount) { @@ -46,6 +47,6 @@ impl StatsCompute for DictArray { } } - stats + Ok(stats) } } diff --git a/vortex-fastlanes/src/bitpacking/mod.rs b/vortex-fastlanes/src/bitpacking/mod.rs index 4f49307ec6..785479a1af 100644 --- a/vortex-fastlanes/src/bitpacking/mod.rs +++ b/vortex-fastlanes/src/bitpacking/mod.rs @@ -1,5 +1,4 @@ use std::any::Any; -use std::collections::HashMap; use std::sync::{Arc, RwLock}; use vortex::array::{ @@ -161,9 +160,8 @@ impl ArrayDisplay for BitPackedArray { } impl StatsCompute for BitPackedArray { - fn compute(&self, _stat: &Stat) -> StatsSet { - // TODO(ngates): implement based on the encoded array - StatsSet::from(HashMap::new()) + fn compute(&self, _stat: &Stat) -> VortexResult { + Ok(StatsSet::default()) } } diff --git a/vortex-fastlanes/src/for/mod.rs b/vortex-fastlanes/src/for/mod.rs index c0a3ec6e20..71c537e274 100644 --- a/vortex-fastlanes/src/for/mod.rs +++ b/vortex-fastlanes/src/for/mod.rs @@ -1,5 +1,4 @@ use std::any::Any; -use std::collections::HashMap; use std::sync::{Arc, RwLock}; use vortex::array::{Array, ArrayRef, ArrowIterator, Encoding, EncodingId, EncodingRef}; @@ -123,9 +122,8 @@ impl ArrayDisplay for FoRArray { } impl StatsCompute for FoRArray { - fn compute(&self, _stat: &Stat) -> StatsSet { - // TODO(ngates): implement based on the encoded array - StatsSet::from(HashMap::new()) + fn compute(&self, _stat: &Stat) -> VortexResult { + Ok(StatsSet::default()) } } diff --git a/vortex-ffor/src/stats.rs b/vortex-ffor/src/stats.rs index c0372e99aa..7aae542de9 100644 --- a/vortex-ffor/src/stats.rs +++ b/vortex-ffor/src/stats.rs @@ -1,11 +1,10 @@ -use std::collections::HashMap; +use vortex::error::VortexResult; use crate::FFORArray; use vortex::stats::{Stat, StatsCompute, StatsSet}; impl StatsCompute for FFORArray { - fn compute(&self, _stat: &Stat) -> StatsSet { - // TODO(ngates): implement based on the encoded array - StatsSet::from(HashMap::new()) + fn compute(&self, _stat: &Stat) -> VortexResult { + Ok(StatsSet::default()) } } diff --git a/vortex-ree/src/stats.rs b/vortex-ree/src/stats.rs index b5bda96c3d..7b16fda239 100644 --- a/vortex-ree/src/stats.rs +++ b/vortex-ree/src/stats.rs @@ -1,8 +1,9 @@ use crate::REEArray; +use vortex::error::VortexResult; use vortex::stats::{Stat, StatsCompute, StatsSet}; impl StatsCompute for REEArray { - fn compute(&self, _stat: &Stat) -> StatsSet { + fn compute(&self, _stat: &Stat) -> VortexResult { todo!() } } diff --git a/vortex-roaring/src/boolean/stats.rs b/vortex-roaring/src/boolean/stats.rs index 9c7a141a0b..454aaf248f 100644 --- a/vortex-roaring/src/boolean/stats.rs +++ b/vortex-roaring/src/boolean/stats.rs @@ -1,10 +1,11 @@ use vortex::array::Array; +use vortex::error::VortexResult; use vortex::stats::{Stat, StatsCompute, StatsSet}; use crate::boolean::RoaringBoolArray; impl StatsCompute for RoaringBoolArray { - fn compute(&self, stat: &Stat) -> StatsSet { + fn compute(&self, stat: &Stat) -> VortexResult { let cardinality = self.bitmap().cardinality() as usize; if let Some(value) = match stat { Stat::IsConstant => Some((cardinality == self.len() || cardinality == 0).into()), @@ -26,9 +27,9 @@ impl StatsCompute for RoaringBoolArray { Stat::NullCount => Some(0.into()), _ => None, } { - StatsSet::of(stat.clone(), value) + Ok(StatsSet::of(stat.clone(), value)) } else { - StatsSet::default() + Ok(StatsSet::default()) } } } diff --git a/vortex-roaring/src/integer/stats.rs b/vortex-roaring/src/integer/stats.rs index 14579eeb96..d87670cec4 100644 --- a/vortex-roaring/src/integer/stats.rs +++ b/vortex-roaring/src/integer/stats.rs @@ -1,9 +1,10 @@ +use vortex::error::VortexResult; use vortex::stats::{Stat, StatsCompute, StatsSet}; use crate::RoaringIntArray; impl StatsCompute for RoaringIntArray { - fn compute(&self, stat: &Stat) -> StatsSet { + fn compute(&self, stat: &Stat) -> VortexResult { if let Some(value) = match stat { Stat::IsConstant => Some((self.bitmap.cardinality() <= 1).into()), Stat::IsSorted => Some(true.into()), @@ -13,9 +14,9 @@ impl StatsCompute for RoaringIntArray { Stat::NullCount => Some(0.into()), _ => None, } { - StatsSet::of(stat.clone(), value) + Ok(StatsSet::of(stat.clone(), value)) } else { - StatsSet::default() + Ok(StatsSet::default()) } } } diff --git a/vortex-zigzag/src/stats.rs b/vortex-zigzag/src/stats.rs index 1feac0aff1..2f8e010324 100644 --- a/vortex-zigzag/src/stats.rs +++ b/vortex-zigzag/src/stats.rs @@ -1,12 +1,13 @@ use std::collections::HashMap; +use vortex::error::VortexResult; use vortex::stats::{Stat, StatsCompute, StatsSet}; use crate::zigzag::ZigZagArray; impl StatsCompute for ZigZagArray { - fn compute(&self, _stat: &Stat) -> StatsSet { + fn compute(&self, _stat: &Stat) -> VortexResult { // TODO(ngates): implement based on the encoded array - StatsSet::from(HashMap::new()) + Ok(StatsSet::from(HashMap::new())) } } diff --git a/vortex/src/array/bool/stats.rs b/vortex/src/array/bool/stats.rs index ddf83852d4..f875e5933a 100644 --- a/vortex/src/array/bool/stats.rs +++ b/vortex/src/array/bool/stats.rs @@ -2,15 +2,16 @@ use std::collections::HashMap; use crate::array::bool::BoolArray; use crate::array::Array; +use crate::error::VortexResult; use crate::stats::{Stat, StatsCompute, StatsSet}; impl StatsCompute for BoolArray { - fn compute(&self, _stat: &Stat) -> StatsSet { + fn compute(&self, _stat: &Stat) -> VortexResult { if self.len() == 0 { - return StatsSet::from(HashMap::from([ + return Ok(StatsSet::from(HashMap::from([ (Stat::TrueCount, 0.into()), (Stat::RunCount, 0.into()), - ])); + ]))); } let mut prev_bit = self.buffer().value(0); @@ -28,7 +29,7 @@ impl StatsCompute for BoolArray { } run_count += 1; - StatsSet::from(HashMap::from([ + Ok(StatsSet::from(HashMap::from([ (Stat::Min, (true_count == self.len()).into()), (Stat::Max, (true_count > 0).into()), ( @@ -37,6 +38,6 @@ impl StatsCompute for BoolArray { ), (Stat::RunCount, run_count.into()), (Stat::TrueCount, true_count.into()), - ])) + ]))) } } diff --git a/vortex/src/array/chunked/stats.rs b/vortex/src/array/chunked/stats.rs index b58adb2dc7..1eef0f2c70 100644 --- a/vortex/src/array/chunked/stats.rs +++ b/vortex/src/array/chunked/stats.rs @@ -1,9 +1,11 @@ use crate::array::chunked::ChunkedArray; +use crate::error::VortexResult; use crate::stats::{Stat, StatsCompute, StatsSet}; impl StatsCompute for ChunkedArray { - fn compute(&self, stat: &Stat) -> StatsSet { - self.chunks() + fn compute(&self, stat: &Stat) -> VortexResult { + Ok(self + .chunks() .iter() .map(|c| { let s = c.stats(); @@ -14,6 +16,6 @@ impl StatsCompute for ChunkedArray { .fold(StatsSet::new(), |mut acc, x| { acc.merge(&x); acc - }) + })) } } diff --git a/vortex/src/array/constant/stats.rs b/vortex/src/array/constant/stats.rs index e8bdd7df5d..14eeefad12 100644 --- a/vortex/src/array/constant/stats.rs +++ b/vortex/src/array/constant/stats.rs @@ -3,11 +3,12 @@ use std::collections::HashMap; use crate::array::constant::ConstantArray; use crate::array::Array; use crate::dtype::{DType, Nullability}; +use crate::error::VortexResult; use crate::scalar::{BoolScalar, PScalar, Scalar}; use crate::stats::{Stat, StatsCompute, StatsSet}; impl StatsCompute for ConstantArray { - fn compute(&self, _stat: &Stat) -> StatsSet { + fn compute(&self, _stat: &Stat) -> VortexResult { let mut m = HashMap::from([ (Stat::Max, dyn_clone::clone_box(self.scalar())), (Stat::Min, dyn_clone::clone_box(self.scalar())), @@ -31,6 +32,7 @@ impl StatsCompute for ConstantArray { .boxed(), ); } - StatsSet::from(m) + + Ok(StatsSet::from(m)) } } diff --git a/vortex/src/array/primitive/stats.rs b/vortex/src/array/primitive/stats.rs index ef066abcce..9067202077 100644 --- a/vortex/src/array/primitive/stats.rs +++ b/vortex/src/array/primitive/stats.rs @@ -6,13 +6,14 @@ use half::f16; use num_traits::{NumCast, PrimInt}; use crate::array::primitive::PrimitiveArray; +use crate::error::VortexResult; use crate::ptype::match_each_native_ptype; use crate::scalar::ListScalarVec; use crate::scalar::Scalar; use crate::stats::{Stat, StatsCompute, StatsSet}; impl StatsCompute for PrimitiveArray { - fn compute(&self, stat: &Stat) -> StatsSet { + fn compute(&self, stat: &Stat) -> VortexResult { match_each_native_ptype!(self.ptype(), |$P| { WrappedPrimitive::<$P>::new(self).compute(stat) }) @@ -30,7 +31,7 @@ impl<'a, P> WrappedPrimitive<'a, P> { macro_rules! integer_stats { ($T:ty) => { impl StatsCompute for WrappedPrimitive<'_, $T> { - fn compute(&self, _stat: &Stat) -> StatsSet { + fn compute(&self, _stat: &Stat) -> VortexResult { integer_stats::<$T>(self.0) } } @@ -49,7 +50,7 @@ integer_stats!(u64); macro_rules! float_stats { ($T:ty) => { impl StatsCompute for WrappedPrimitive<'_, $T> { - fn compute(&self, _stat: &Stat) -> StatsSet { + fn compute(&self, _stat: &Stat) -> VortexResult { float_stats::<$T>(self.0) } } @@ -60,7 +61,9 @@ float_stats!(f16); float_stats!(f32); float_stats!(f64); -fn integer_stats(array: &PrimitiveArray) -> StatsSet +fn integer_stats( + array: &PrimitiveArray, +) -> VortexResult where Box: From, { @@ -97,7 +100,7 @@ where } run_count += 1; - StatsSet::from(HashMap::from([ + Ok(StatsSet::from(HashMap::from([ (Stat::Min, min.into()), (Stat::Max, max.into()), (Stat::IsConstant, (min == max).into()), @@ -105,10 +108,10 @@ where (Stat::IsSorted, is_sorted.into()), (Stat::IsStrictSorted, (is_sorted && is_strict_sorted).into()), (Stat::RunCount, run_count.into()), - ])) + ]))) } -fn float_stats(array: &PrimitiveArray) -> StatsSet +fn float_stats(array: &PrimitiveArray) -> VortexResult where Box: From, { @@ -136,13 +139,13 @@ where } run_count += 1; - StatsSet::from(HashMap::from([ + Ok(StatsSet::from(HashMap::from([ (Stat::Min, min.into()), (Stat::Max, max.into()), (Stat::IsConstant, (min == max).into()), (Stat::IsSorted, is_sorted.into()), (Stat::RunCount, run_count.into()), - ])) + ]))) } #[cfg(test)] diff --git a/vortex/src/array/sparse/stats.rs b/vortex/src/array/sparse/stats.rs index 3e21325261..b12669ee59 100644 --- a/vortex/src/array/sparse/stats.rs +++ b/vortex/src/array/sparse/stats.rs @@ -1,8 +1,9 @@ use crate::array::sparse::SparseArray; +use crate::error::VortexResult; use crate::stats::{Stat, StatsCompute, StatsSet}; impl StatsCompute for SparseArray { - fn compute(&self, _stat: &Stat) -> StatsSet { + fn compute(&self, _stat: &Stat) -> VortexResult { todo!() } } diff --git a/vortex/src/array/struct_/stats.rs b/vortex/src/array/struct_/stats.rs index 0a1e944afe..6d3e2b7e78 100644 --- a/vortex/src/array/struct_/stats.rs +++ b/vortex/src/array/struct_/stats.rs @@ -1,8 +1,9 @@ use crate::array::struct_::StructArray; +use crate::error::VortexResult; use crate::stats::{Stat, StatsCompute, StatsSet}; impl StatsCompute for StructArray { - fn compute(&self, _stat: &Stat) -> StatsSet { + fn compute(&self, _stat: &Stat) -> VortexResult { todo!() } } diff --git a/vortex/src/array/typed/stats.rs b/vortex/src/array/typed/stats.rs index bff00d42dc..fde409ce5e 100644 --- a/vortex/src/array/typed/stats.rs +++ b/vortex/src/array/typed/stats.rs @@ -1,8 +1,9 @@ use crate::array::typed::TypedArray; +use crate::error::VortexResult; use crate::stats::{Stat, StatsCompute, StatsSet}; impl StatsCompute for TypedArray { - fn compute(&self, _stat: &Stat) -> StatsSet { + fn compute(&self, _stat: &Stat) -> VortexResult { todo!() } } diff --git a/vortex/src/array/varbin/stats.rs b/vortex/src/array/varbin/stats.rs index 12f3743a29..3cc9c70baf 100644 --- a/vortex/src/array/varbin/stats.rs +++ b/vortex/src/array/varbin/stats.rs @@ -16,7 +16,7 @@ impl StatsCompute for T where T: BinaryArray + Array, { - fn compute(&self, _stat: &Stat) -> StatsSet { + fn compute(&self, _stat: &Stat) -> VortexResult { let mut min = vec![0xFF]; let mut max = vec![0x00]; let mut is_constant = true; @@ -41,7 +41,7 @@ where runs += 1; } - StatsSet::from(HashMap::from([ + Ok(StatsSet::from(HashMap::from([ ( Stat::Min, if matches!(self.dtype(), DType::Utf8(_)) { @@ -61,7 +61,7 @@ where (Stat::RunCount, runs.into()), (Stat::IsSorted, is_sorted.into()), (Stat::IsConstant, is_constant.into()), - ])) + ]))) } } diff --git a/vortex/src/stats.rs b/vortex/src/stats.rs index e559f2d41c..390cbd0e3c 100644 --- a/vortex/src/stats.rs +++ b/vortex/src/stats.rs @@ -208,7 +208,7 @@ impl StatsSet { } pub trait StatsCompute { - fn compute(&self, stat: &Stat) -> StatsSet; + fn compute(&self, stat: &Stat) -> VortexResult; } pub struct Stats<'a> { @@ -257,7 +257,7 @@ impl<'a> Stats<'a> { .write() .unwrap() .0 - .extend(self.compute.compute(stat).0); + .extend(self.compute.compute(stat).unwrap().0); self.get(stat) }