Skip to content

Commit d76a564

Browse files
committed
chore: inline alp decompress_from_buffer fn
Signed-off-by: Alexander Droste <[email protected]>
1 parent ef33c36 commit d76a564

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

encodings/alp/src/alp/decompress.rs

Lines changed: 6 additions & 24 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,13 @@ 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();
61+
let encoded_primitive = encoded_vector.into_primitive().into_mut();
6362
let validity = encoded_primitive.validity().clone();
64-
let encoded_mutable = encoded_primitive.into_mut();
6563

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> {
64+
let mut alp_buffer = T::ALPInt::downcast(encoded_primitive).into_parts().0;
8465
<T>::decode_slice_inplace(alp_buffer.as_mut_slice(), exponents);
8566

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

8970
// Apply patches if they exist.
@@ -105,8 +86,9 @@ fn decompress_from_buffer<T: ALPFloat>(
10586
});
10687
}
10788

108-
let result = PVectorMut::<T>::new(decoded_buffer, validity.into_mut());
109-
Ok(result.freeze().into())
89+
Ok(PVectorMut::<T>::new(decoded_buffer, validity)
90+
.freeze()
91+
.into())
11092
}
11193

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

0 commit comments

Comments
 (0)