-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
98 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::cmp::min; | ||
|
||
use num_traits::{AsPrimitive, FromPrimitive}; | ||
use vortex_dtype::NativePType; | ||
use vortex_error::vortex_panic; | ||
|
||
#[inline] | ||
pub fn trimmed_ends_iter<E: NativePType + FromPrimitive + AsPrimitive<usize> + Ord>( | ||
run_ends: &[E], | ||
offset: usize, | ||
length: usize, | ||
) -> impl Iterator<Item = usize> + use<'_, E> { | ||
let offset_e = E::from_usize(offset).unwrap_or_else(|| { | ||
vortex_panic!( | ||
"offset {} cannot be converted to {}", | ||
offset, | ||
std::any::type_name::<E>() | ||
) | ||
}); | ||
let length_e = E::from_usize(length).unwrap_or_else(|| { | ||
vortex_panic!( | ||
"length {} cannot be converted to {}", | ||
length, | ||
std::any::type_name::<E>() | ||
) | ||
}); | ||
run_ends | ||
.iter() | ||
.copied() | ||
.map(move |v| v - offset_e) | ||
.map(move |v| min(v, length_e)) | ||
.map(|v| v.as_()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ pub use array::*; | |
mod array; | ||
pub mod compress; | ||
mod compute; | ||
mod iter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters