add f32::MAX to disable a compressor

This commit is contained in:
Pascal Seitz
2021-06-08 11:50:18 +02:00
parent aa3c4d4029
commit 0ba05df545
2 changed files with 4 additions and 3 deletions

View File

@@ -30,7 +30,8 @@ pub trait FastFieldDataAccess: Clone {
/// The FastFieldSerializerEstimate trait is required on all variants
/// of fast field compressions, to decide which one to choose.
pub trait FastFieldSerializerEstimate {
/// returns an estimate of the compression ratio.
/// returns an estimate of the compression ratio. if the compressor is unable to handle the
/// data it needs to return f32::MAX.
/// The baseline is uncompressed 64bit data.
///
/// It could make sense to also return a value representing

View File

@@ -163,8 +163,8 @@ impl FastFieldSerializerEstimate for LinearInterpolFastFieldSerializer {
/// where the local maxima are for the deviation of the calculated value and
/// the offset is also unknown.
fn estimate(fastfield_accessor: &impl FastFieldDataAccess, stats: FastFieldStats) -> f32 {
if stats.max_value > i64::MAX as u64 / 2 {
return 999.0; // effectively disable compressor for this case
if stats.max_value > i64::MAX as u64 / 2 || stats.num_vals < 3 {
return f32::MAX; //disable compressor for this case
}
let first_val = fastfield_accessor.get(0);
let last_val = fastfield_accessor.get(stats.num_vals as u32 - 1);