Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 4 additions & 26 deletions encodings/alp/src/alp/decompress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use vortex_dtype::DType;
use vortex_dtype::NativePType;
use vortex_dtype::match_each_unsigned_integer_ptype;
use vortex_error::VortexResult;
use vortex_mask::Mask;
use vortex_vector::Vector;
use vortex_vector::VectorMutOps;
use vortex_vector::VectorOps;
Expand Down Expand Up @@ -59,31 +58,11 @@ pub fn decompress_into_vector<T: ALPFloat>(
patches_vectors: Option<(Vector, Vector, Option<Vector>)>,
patches_offset: usize,
) -> VortexResult<Vector> {
let encoded_primitive = encoded_vector.into_primitive();
let validity = encoded_primitive.validity().clone();
let encoded_mutable = encoded_primitive.into_mut();

let alp_buffer = T::ALPInt::downcast(encoded_mutable).into_parts().0;

decompress_from_buffer::<T>(
alp_buffer,
exponents,
patches_vectors,
patches_offset,
validity,
)
}

fn decompress_from_buffer<T: ALPFloat>(
mut alp_buffer: BufferMut<T::ALPInt>,
exponents: Exponents,
patches_vectors: Option<(Vector, Vector, Option<Vector>)>,
patches_offset: usize,
validity: Mask,
) -> VortexResult<Vector> {
let encoded_primitive = encoded_vector.into_primitive().into_mut();
let (mut alp_buffer, mask) = T::ALPInt::downcast(encoded_primitive).into_parts();
<T>::decode_slice_inplace(alp_buffer.as_mut_slice(), exponents);

// Convert to float buffer.
// SAFETY: `Buffer<T::ALPInt> and `BufferMut<T>` have the same layout.
let mut decoded_buffer: BufferMut<T> = unsafe { transmute(alp_buffer) };

// Apply patches if they exist.
Expand All @@ -105,8 +84,7 @@ fn decompress_from_buffer<T: ALPFloat>(
});
}

let result = PVectorMut::<T>::new(decoded_buffer, validity.into_mut());
Ok(result.freeze().into())
Ok(PVectorMut::<T>::new(decoded_buffer, mask).freeze().into())
}

/// Decompresses an ALP-encoded array in 1024-element chunks.
Expand Down
Loading