diff --git a/fastfield_codecs/src/lib.rs b/fastfield_codecs/src/lib.rs index d57fd78fc..af621a702 100644 --- a/fastfield_codecs/src/lib.rs +++ b/fastfield_codecs/src/lib.rs @@ -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 diff --git a/fastfield_codecs/src/linearinterpol.rs b/fastfield_codecs/src/linearinterpol.rs index c86a64090..af27f054f 100644 --- a/fastfield_codecs/src/linearinterpol.rs +++ b/fastfield_codecs/src/linearinterpol.rs @@ -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);