From 0a41c2633c64e3b60b652681bc781427847949b2 Mon Sep 17 00:00:00 2001 From: Joe Isaacs Date: Fri, 31 Jan 2025 17:40:36 +0000 Subject: [PATCH] updates --- vortex-array/src/compute/take.rs | 3 +-- vortex-array/src/patches.rs | 8 ++------ vortex-array/src/stats/mod.rs | 8 ++++++++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/vortex-array/src/compute/take.rs b/vortex-array/src/compute/take.rs index 743645ca72..0472f95ef8 100644 --- a/vortex-array/src/compute/take.rs +++ b/vortex-array/src/compute/take.rs @@ -56,8 +56,7 @@ pub fn take(array: impl AsRef, indices: impl AsRef) -> VortexResul // If the indices are all within bounds, we can skip bounds checking. let checked_indices = indices .statistics() - .get_as::(Stat::Max) - .map(|stat| stat.bound::()) + .get_as_bound::() .is_some_and(|max| max < array.len()); let derived_stats = derive_take_stats(array); diff --git a/vortex-array/src/patches.rs b/vortex-array/src/patches.rs index b68b32cc31..505999ac47 100644 --- a/vortex-array/src/patches.rs +++ b/vortex-array/src/patches.rs @@ -17,7 +17,7 @@ use crate::compute::{ filter, scalar_at, search_sorted, search_sorted_usize, search_sorted_usize_many, slice, sub_scalar, take, SearchResult, SearchSortedSide, }; -use crate::stats::{Max, Stat}; +use crate::stats::Max; use crate::variants::PrimitiveArrayTrait; use crate::{Array, IntoArray, IntoArrayVariant}; @@ -88,11 +88,7 @@ impl Patches { "Patch indices must be shorter than the array length" ); assert!(!indices.is_empty(), "Patch indices must not be empty"); - if let Some(max) = indices - .statistics() - .get_as::(Stat::Max) - .map(|s| s.bound::()) - { + if let Some(max) = indices.statistics().get_as_bound::() { assert!( max < (array_len as u64), "Patch indices {:?} are longer than the array length {}", diff --git a/vortex-array/src/stats/mod.rs b/vortex-array/src/stats/mod.rs index dc3319377f..85cdc5f402 100644 --- a/vortex-array/src/stats/mod.rs +++ b/vortex-array/src/stats/mod.rs @@ -244,6 +244,14 @@ impl dyn Statistics + '_ { }) } + pub fn get_as_bound(&self) -> Option + where + S: StatType, + U: for<'a> TryFrom<&'a ScalarValue, Error = VortexError>, + { + self.get_as::(S::STAT).map(|v| v.bound::()) + } + /// Get or calculate the provided stat, converting the `ScalarValue` into a typed value. /// If the stored `ScalarValue` is of different type then the primitive typed value this function will perform a cast. ///