MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / detect_f64_codec

Function detect_f64_codec

nodedb-codec/src/detect.rs:92–109  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

90/// For partitions ≥ CASCADE_THRESHOLD values with >95% ALP encodability,
91/// selects `AlpFastLanesLz4`. Otherwise falls back to `Gorilla`.
92pub 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)]
112mod tests {

Callers 1

encode_columnFunction · 0.85

Calls 2

alp_encodabilityFunction · 0.85
lenMethod · 0.45

Tested by

no test coverage detected