Detect the optimal codec for an f64 column by analyzing the data. For partitions ≥ CASCADE_THRESHOLD values with >95% ALP encodability, selects `AlpFastLanesLz4`. Otherwise falls back to `Gorilla`.
(values: &[f64])
| 90 | /// For partitions ≥ CASCADE_THRESHOLD values with >95% ALP encodability, |
| 91 | /// selects `AlpFastLanesLz4`. Otherwise falls back to `Gorilla`. |
| 92 | pub fn detect_f64_codec(values: &[f64]) -> ColumnCodec { |
| 93 | if values.len() < 2 { |
| 94 | return ColumnCodec::Gorilla; |
| 95 | } |
| 96 | |
| 97 | let use_cascade = values.len() >= CASCADE_THRESHOLD; |
| 98 | |
| 99 | if use_cascade { |
| 100 | // Check ALP encodability on a sample. |
| 101 | let encodability = crate::alp::alp_encodability(values); |
| 102 | if encodability > 0.95 { |
| 103 | return ColumnCodec::AlpFastLanesLz4; |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | // Fallback: Gorilla is the best general-purpose f64 codec. |
| 108 | ColumnCodec::Gorilla |
| 109 | } |
| 110 | |
| 111 | #[cfg(test)] |
| 112 | mod tests { |
no test coverage detected