Skip to content

Commit

Permalink
REE decoding doesn't need to take_while (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
robert3005 authored Mar 26, 2024
1 parent 880f908 commit 6c5fae7
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions vortex-ree/src/compress.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::cmp::min;

use itertools::Itertools;
use num_traits::{AsPrimitive, FromPrimitive};
use num_traits::AsPrimitive;

use vortex::array::downcast::DowncastArrayBuiltin;
use vortex::array::primitive::{PrimitiveArray, PrimitiveEncoding};
Expand Down Expand Up @@ -132,22 +132,18 @@ pub fn ree_decode(
})
}

pub fn ree_decode_primitive<
E: NativePType + AsPrimitive<usize> + FromPrimitive + Ord,
T: NativePType,
>(
pub fn ree_decode_primitive<E: NativePType + AsPrimitive<usize> + Ord, T: NativePType>(
run_ends: &[E],
values: &[T],
offset: usize,
length: usize,
) -> Vec<T> {
let offset_e = <E as FromPrimitive>::from_usize(offset).unwrap();
let length_e = <E as FromPrimitive>::from_usize(length).unwrap();
let offset_e = E::from_usize(offset).unwrap();
let length_e = E::from_usize(length).unwrap();
let trimmed_ends = run_ends
.iter()
.map(|v| *v - offset_e)
.map(|v| min(v, length_e))
.take_while(|v| *v <= length_e);
.map(|v| min(v, length_e));

let mut decoded = Vec::with_capacity(length);
for (end, &value) in trimmed_ends.zip_eq(values) {
Expand Down

0 comments on commit 6c5fae7

Please sign in to comment.