Skip to content

Commit bc47986

Browse files
authored
fix: patch chunk offsets for alp encode (#5080)
Patches get filtered after the `T::encode` call in case they are null. Signed-off-by: Alexander Droste <[email protected]>
1 parent 2f09c15 commit bc47986

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

encodings/alp/src/alp/compress.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ where
6363
{
6464
let values_slice = values.as_slice::<T>();
6565

66-
let (exponents, encoded, exceptional_positions, exceptional_values, chunk_offsets) =
66+
let (exponents, encoded, exceptional_positions, exceptional_values, mut chunk_offsets) =
6767
T::encode(values_slice, exponents);
6868

6969
let encoded_array = PrimitiveArray::new(encoded, values.validity().clone()).into_array();
@@ -82,7 +82,16 @@ where
8282
let (pos, vals): (BufferMut<u64>, BufferMut<T>) = exceptional_positions
8383
.into_iter()
8484
.zip_eq(exceptional_values)
85-
.filter(|(index, _)| is_valid.value(*index as usize))
85+
.filter(|(index, _)| {
86+
let is_valid = is_valid.value(*index as usize);
87+
if !is_valid {
88+
let patch_chunk = *index as usize / 1024;
89+
for chunk_idx in (patch_chunk + 1)..chunk_offsets.len() {
90+
chunk_offsets[chunk_idx] -= 1;
91+
}
92+
}
93+
is_valid
94+
})
8695
.unzip();
8796
(pos.freeze(), vals.freeze())
8897
}

encodings/alp/src/alp/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub trait ALPFloat: private::Sealed + Float + Display + NativePType {
127127
Buffer<Self::ALPInt>,
128128
Buffer<u64>,
129129
Buffer<Self>,
130-
Buffer<u64>,
130+
BufferMut<u64>,
131131
) {
132132
let exp = exponents.unwrap_or_else(|| Self::find_best_exponents(values));
133133

@@ -158,7 +158,7 @@ pub trait ALPFloat: private::Sealed + Float + Display + NativePType {
158158
encoded_output.freeze(),
159159
patch_indices.freeze(),
160160
patch_values.freeze(),
161-
chunk_offsets.freeze(),
161+
chunk_offsets,
162162
)
163163
}
164164

0 commit comments

Comments
 (0)