mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-04 16:22:55 +00:00
add f32::MAX to disable a compressor
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user