Merge pull request #2971 from quickwit-oss/trinity.pointard/fix-slop-overflow

fix overflow on large jumps in linear sequence
This commit is contained in:
trinity-1686a
2026-06-23 10:18:29 +02:00
committed by GitHub
2 changed files with 23 additions and 1 deletions

View File

@@ -241,6 +241,28 @@ mod tests {
use super::*;
use crate::column_values::u64_based::tests::create_and_validate;
// A block boundary where a high run ends and a low run begins: y0 ≈ 2^32, y511 ≈ 0.
// This large jump used to cause an overflow which made us render all value on 64b
// when 32 was enough.
fn large_descending_jump_vals() -> Vec<u64> {
let high_start: u64 = 4_294_967_039; // ≈ 2^32 - 257
(0u64..256)
.map(|i| high_start + i)
.chain(0u64..256)
.collect()
}
#[test]
fn test_blockwise_linear_large_descending_jump_uses_at_most_32bit() {
let vals = large_descending_jump_vals();
let (_, actual_rate) =
create_and_validate::<BlockwiseLinearCodec>(&vals, "large descending jump").unwrap();
assert!(
actual_rate <= 0.6,
"compression rate {actual_rate:.3} is too high (bug: 64-bit residuals)"
);
}
#[test]
fn test_with_codec_data_sets_simple() {
create_and_validate::<BlockwiseLinearCodec>(

View File

@@ -37,7 +37,7 @@ fn compute_slope(y0: u64, y1: u64, num_vals: NonZeroU32) -> u64 {
} else {
y0.wrapping_sub(y1)
};
if abs_dy >= 1 << 32 {
if abs_dy >= 1 << 31 {
// This is outside of realm we handle.
// Let's just bail.
return 0u64;