Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-isaacs committed Jan 31, 2025
1 parent 68fb90d commit 0a41c26
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 1 addition & 2 deletions vortex-array/src/compute/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ pub fn take(array: impl AsRef<Array>, indices: impl AsRef<Array>) -> VortexResul
// If the indices are all within bounds, we can skip bounds checking.
let checked_indices = indices
.statistics()
.get_as::<usize>(Stat::Max)
.map(|stat| stat.bound::<Max>())
.get_as_bound::<Max, usize>()
.is_some_and(|max| max < array.len());

let derived_stats = derive_take_stats(array);
Expand Down
8 changes: 2 additions & 6 deletions vortex-array/src/patches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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::<u64>(Stat::Max)
.map(|s| s.bound::<Max>())
{
if let Some(max) = indices.statistics().get_as_bound::<Max, u64>() {
assert!(
max < (array_len as u64),
"Patch indices {:?} are longer than the array length {}",
Expand Down
8 changes: 8 additions & 0 deletions vortex-array/src/stats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,14 @@ impl dyn Statistics + '_ {
})
}

pub fn get_as_bound<S, U>(&self) -> Option<S::Bound>
where
S: StatType<U>,
U: for<'a> TryFrom<&'a ScalarValue, Error = VortexError>,
{
self.get_as::<U>(S::STAT).map(|v| v.bound::<S>())
}

/// 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.
///
Expand Down

0 comments on commit 0a41c26

Please sign in to comment.