Skip to content

Commit

Permalink
asdfa
Browse files Browse the repository at this point in the history
  • Loading branch information
lwwmanning committed Mar 22, 2024
1 parent 49144ff commit e827282
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions vortex-fastlanes/src/delta/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ where
if remainder_size > 0 {
let chunk = &array[array.len() - remainder_size..];
for next in chunk {
output.push(next.wrapping_sub(&base_scalar));
let diff = next.wrapping_sub(&base_scalar);
output.push(diff);
base_scalar = *next;
}
}
Expand Down Expand Up @@ -152,14 +153,16 @@ where
}
base_scalar = output[output.len() - 1];
}
assert_eq!(output.len() % 1024, 0);

// To avoid padding, the remainder is encoded with scalar logic.
let remainder_size = array.len() % 1024;
if remainder_size > 0 {
let chunk = &array[array.len() - remainder_size..];
for next in chunk {
output.push(next.wrapping_add(&base_scalar));
base_scalar = *next;
let chunk = &array[num_chunks * 1024..];
for next_diff in chunk {
let next = next_diff.wrapping_add(&base_scalar);
output.push(next);
base_scalar = next;
}
}

Expand Down Expand Up @@ -189,13 +192,13 @@ mod test {

assert_eq!(compressed.encoding().id(), DeltaEncoding.id());
let delta = compressed.as_any().downcast_ref::<DeltaArray>().unwrap();
println!("Delta {:?}", delta);

let decompressed = decompress(delta).unwrap();
assert_eq!(
decompressed.typed_data::<i32>(),
Vec::from_iter(0..10_000).as_slice()
);
let decompressed_slice = decompressed.typed_data::<i32>();
assert_eq!(decompressed_slice.len(), 10_000);
for (actual, expected) in decompressed_slice.iter().zip(0..10_000) {
assert_eq!(actual, &expected);
}
}

#[test]
Expand Down

0 comments on commit e827282

Please sign in to comment.