From 6e470ed10ff7bc8b7bc24146f3abc79f8fd1f13a Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Mon, 9 Dec 2024 12:39:55 +0000 Subject: [PATCH 1/3] Skip FoR decompression if min and scalar are 0 --- encodings/fastlanes/src/for/compress.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/encodings/fastlanes/src/for/compress.rs b/encodings/fastlanes/src/for/compress.rs index 46b6e19f39..07f8980000 100644 --- a/encodings/fastlanes/src/for/compress.rs +++ b/encodings/fastlanes/src/for/compress.rs @@ -116,10 +116,14 @@ pub fn decompress(array: FoRArray) -> VortexResult { .as_primitive() .typed_value::<$T>() .ok_or_else(|| vortex_err!("expected reference to be non-null"))?; - PrimitiveArray::from_vec( - decompress_primitive(encoded.into_maybe_null_slice::<$T>(), min, shift), - validity, - ) + if min == 0 && shift == 0 { + encoded + } else { + PrimitiveArray::from_vec( + decompress_primitive(encoded.into_maybe_null_slice::<$T>(), min, shift), + validity, + ) + } } })) } From 6071aff01b1795193807d480722393feb8ba43e9 Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Mon, 9 Dec 2024 13:22:40 +0000 Subject: [PATCH 2/3] more --- encodings/fastlanes/src/for/compress.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/encodings/fastlanes/src/for/compress.rs b/encodings/fastlanes/src/for/compress.rs index 07f8980000..c61b2ca2cd 100644 --- a/encodings/fastlanes/src/for/compress.rs +++ b/encodings/fastlanes/src/for/compress.rs @@ -134,11 +134,15 @@ fn decompress_primitive( shift: usize, ) -> Vec { if shift > 0 { - values - .into_iter() - .map(|v| v << shift) - .map(|v| v.wrapping_add(&min)) - .collect_vec() + if min == T::zero() { + values.into_iter().map(|v| v << shift).collect_vec() + } else { + values + .into_iter() + .map(|v| v << shift) + .map(|v| v.wrapping_add(&min)) + .collect_vec() + } } else { values .into_iter() From fbdb53cb3840172eaf80d8e5dcdd78db08f02a79 Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Mon, 9 Dec 2024 13:25:31 +0000 Subject: [PATCH 3/3] move --- encodings/fastlanes/src/for/compress.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/encodings/fastlanes/src/for/compress.rs b/encodings/fastlanes/src/for/compress.rs index c61b2ca2cd..e717ade2c6 100644 --- a/encodings/fastlanes/src/for/compress.rs +++ b/encodings/fastlanes/src/for/compress.rs @@ -135,18 +135,18 @@ fn decompress_primitive( ) -> Vec { if shift > 0 { if min == T::zero() { - values.into_iter().map(|v| v << shift).collect_vec() + values.into_iter().map(move |v| v << shift).collect_vec() } else { values .into_iter() - .map(|v| v << shift) - .map(|v| v.wrapping_add(&min)) + .map(move |v| v << shift) + .map(move |v| v.wrapping_add(&min)) .collect_vec() } } else { values .into_iter() - .map(|v| v.wrapping_add(&min)) + .map(move |v| v.wrapping_add(&min)) .collect_vec() } }