From 6c5fae7d5d11ec432e6de40668fb12e06b28c057 Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Tue, 26 Mar 2024 19:43:57 +0000 Subject: [PATCH] REE decoding doesn't need to take_while (#151) --- vortex-ree/src/compress.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/vortex-ree/src/compress.rs b/vortex-ree/src/compress.rs index 4cd72429ef..d1d5270257 100644 --- a/vortex-ree/src/compress.rs +++ b/vortex-ree/src/compress.rs @@ -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}; @@ -132,22 +132,18 @@ pub fn ree_decode( }) } -pub fn ree_decode_primitive< - E: NativePType + AsPrimitive + FromPrimitive + Ord, - T: NativePType, ->( +pub fn ree_decode_primitive + Ord, T: NativePType>( run_ends: &[E], values: &[T], offset: usize, length: usize, ) -> Vec { - let offset_e = ::from_usize(offset).unwrap(); - let length_e = ::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) {