Skip to content

Commit 91a62f3

Browse files
authored
chore: inline alp decompress_from_buffer fn (#5587)
Signed-off-by: Alexander Droste <[email protected]>
1 parent 240403b commit 91a62f3

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

encodings/alp/src/alp/decompress.rs

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use vortex_dtype::DType;
1515
use vortex_dtype::NativePType;
1616
use vortex_dtype::match_each_unsigned_integer_ptype;
1717
use vortex_error::VortexResult;
18-
use vortex_mask::Mask;
1918
use vortex_vector::Vector;
2019
use vortex_vector::VectorMutOps;
2120
use vortex_vector::VectorOps;
@@ -59,31 +58,11 @@ pub fn decompress_into_vector<T: ALPFloat>(
5958
patches_vectors: Option<(Vector, Vector, Option<Vector>)>,
6059
patches_offset: usize,
6160
) -> VortexResult<Vector> {
62-
let encoded_primitive = encoded_vector.into_primitive();
63-
let validity = encoded_primitive.validity().clone();
64-
let encoded_mutable = encoded_primitive.into_mut();
65-
66-
let alp_buffer = T::ALPInt::downcast(encoded_mutable).into_parts().0;
67-
68-
decompress_from_buffer::<T>(
69-
alp_buffer,
70-
exponents,
71-
patches_vectors,
72-
patches_offset,
73-
validity,
74-
)
75-
}
76-
77-
fn decompress_from_buffer<T: ALPFloat>(
78-
mut alp_buffer: BufferMut<T::ALPInt>,
79-
exponents: Exponents,
80-
patches_vectors: Option<(Vector, Vector, Option<Vector>)>,
81-
patches_offset: usize,
82-
validity: Mask,
83-
) -> VortexResult<Vector> {
61+
let encoded_primitive = encoded_vector.into_primitive().into_mut();
62+
let (mut alp_buffer, mask) = T::ALPInt::downcast(encoded_primitive).into_parts();
8463
<T>::decode_slice_inplace(alp_buffer.as_mut_slice(), exponents);
8564

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

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

108-
let result = PVectorMut::<T>::new(decoded_buffer, validity.into_mut());
109-
Ok(result.freeze().into())
87+
Ok(PVectorMut::<T>::new(decoded_buffer, mask).freeze().into())
11088
}
11189

11290
/// Decompresses an ALP-encoded array in 1024-element chunks.

0 commit comments

Comments
 (0)