Skip to content

Commit 9e223c0

Browse files
committed
u
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent c490bb9 commit 9e223c0

2 files changed

Lines changed: 11 additions & 34 deletions

File tree

encodings/fastlanes/src/delta/array/delta_compress.rs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,38 +25,26 @@ pub fn delta_compress(
2525
) -> VortexResult<(PrimitiveArray, PrimitiveArray)> {
2626
let validity = array.validity()?;
2727
let original_ptype = array.ptype();
28-
let unsigned_ptype = original_ptype.to_unsigned();
29-
// Signed integers are processed through their unsigned counterpart: `wrapping_sub`
30-
// is bit-identical for signed and unsigned operands, so the encoded bytes are the
31-
// same regardless of how the buffer's elements are interpreted.
32-
let work = if original_ptype == unsigned_ptype {
33-
array.clone()
34-
} else {
35-
array.reinterpret_cast(unsigned_ptype)
36-
};
28+
let array = array.reinterpret_cast(original_ptype.to_unsigned());
3729

38-
let (bases, deltas) = match_each_unsigned_integer_ptype!(work.ptype(), |T| {
30+
let (bases, deltas) = match_each_unsigned_integer_ptype!(array.ptype(), |T| {
3931
// Fill-forward null values so that transposed deltas at null positions remain
4032
// small. Without this, bitpacking may skip patches for null positions, and the
4133
// corrupted delta values propagate through the cumulative sum during decompression.
42-
let filled = fill_forward_nulls(work.to_buffer::<T>(), &validity, ctx)?;
34+
let filled = fill_forward_nulls(array.to_buffer::<T>(), &validity, ctx)?;
4335
let (bases, deltas) = compress_primitive::<T, { T::LANES }>(&filled);
4436
// TODO(robert): This can be avoided if we add TransposedBoolArray that performs index translation when necessary.
4537
let validity = transpose_validity(&validity, ctx)?;
4638
(
47-
PrimitiveArray::new(bases, work.dtype().nullability().into()),
39+
PrimitiveArray::new(bases, array.dtype().nullability().into()),
4840
PrimitiveArray::new(deltas, validity),
4941
)
5042
});
5143

52-
Ok(if original_ptype == unsigned_ptype {
53-
(bases, deltas)
54-
} else {
55-
(
56-
bases.reinterpret_cast(original_ptype),
57-
deltas.reinterpret_cast(original_ptype),
58-
)
59-
})
44+
Ok((
45+
bases.reinterpret_cast(original_ptype),
46+
deltas.reinterpret_cast(original_ptype),
47+
))
6048
}
6149

6250
fn compress_primitive<T, const LANES: usize>(array: &[T]) -> (Buffer<T>, Buffer<T>)

encodings/fastlanes/src/delta/array/delta_decompress.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,10 @@ pub fn delta_decompress(
3535
let validity = validity.slice(start..end)?;
3636

3737
let original_ptype = deltas.ptype();
38-
let unsigned_ptype = original_ptype.to_unsigned();
3938
// Signed inputs are processed through their unsigned counterpart; `wrapping_add` on the
4039
// raw bytes inverts the `wrapping_sub` done at compress time regardless of signedness.
41-
let (bases, deltas) = if original_ptype == unsigned_ptype {
42-
(bases, deltas)
43-
} else {
44-
(
45-
bases.reinterpret_cast(unsigned_ptype),
46-
deltas.reinterpret_cast(unsigned_ptype),
47-
)
48-
};
40+
let bases = bases.reinterpret_cast(original_ptype.to_unsigned());
41+
let deltas = deltas.reinterpret_cast(original_ptype.to_unsigned());
4942

5043
let decoded = match_each_unsigned_integer_ptype!(deltas.ptype(), |T| {
5144
const LANES: usize = T::LANES;
@@ -56,11 +49,7 @@ pub fn delta_decompress(
5649
PrimitiveArray::new(buffer, validity)
5750
});
5851

59-
Ok(if original_ptype == unsigned_ptype {
60-
decoded
61-
} else {
62-
decoded.reinterpret_cast(original_ptype)
63-
})
52+
Ok(decoded.reinterpret_cast(original_ptype))
6453
}
6554

6655
/// Performs the low-level delta decompression on primitive values.

0 commit comments

Comments
 (0)