Skip to content

Commit

Permalink
ALP decompress in place (#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
robert3005 authored Aug 29, 2024
1 parent 76d522e commit 1598493
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions encodings/alp/src/compress.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use itertools::Itertools;
use vortex::array::{PrimitiveArray, Sparse, SparseArray};
use vortex::validity::Validity;
use vortex::{Array, ArrayDType, ArrayDef, IntoArray, IntoArrayVariant};
Expand Down Expand Up @@ -61,11 +60,12 @@ pub fn alp_encode(parray: &PrimitiveArray) -> VortexResult<ALPArray> {

pub fn decompress(array: ALPArray) -> VortexResult<PrimitiveArray> {
let encoded = array.encoded().into_primitive()?;
let validity = encoded.validity();

let decoded = match_each_alp_float_ptype!(array.dtype().try_into().unwrap(), |$T| {
PrimitiveArray::from_vec(
decompress_primitive::<$T>(encoded.maybe_null_slice(), array.exponents()),
encoded.validity(),
decompress_primitive::<$T>(encoded.into_maybe_null_slice(), array.exponents()),
validity,
)
});

Expand Down Expand Up @@ -95,13 +95,13 @@ fn patch_decoded(array: PrimitiveArray, patches: &Array) -> VortexResult<Primiti
}

fn decompress_primitive<T: NativePType + ALPFloat>(
values: &[T::ALPInt],
values: Vec<T::ALPInt>,
exponents: Exponents,
) -> Vec<T> {
values
.iter()
.map(|&v| T::decode_single(v, exponents))
.collect_vec()
.into_iter()
.map(|v| T::decode_single(v, exponents))
.collect()
}

#[cfg(test)]
Expand Down

0 comments on commit 1598493

Please sign in to comment.