Detect the optimal codec for a column based on its type and data. When `codec` is not `Auto`, returns it unchanged. When `Auto`, analyzes the column type hint to select the best codec. For data-aware selection (ALP encodability, monotonicity detection), use `detect_f64_codec()` or `detect_i64_codec()` with actual values.
(codec: ColumnCodec, type_hint: ColumnTypeHint)
| 28 | /// data-aware selection (ALP encodability, monotonicity detection), |
| 29 | /// use `detect_f64_codec()` or `detect_i64_codec()` with actual values. |
| 30 | pub fn detect_codec(codec: ColumnCodec, type_hint: ColumnTypeHint) -> ColumnCodec { |
| 31 | if codec != ColumnCodec::Auto { |
| 32 | return codec; |
| 33 | } |
| 34 | |
| 35 | // Default selections (data-unaware). The segment writer calls |
| 36 | // data-aware variants (detect_f64_codec, detect_i64_codec) when |
| 37 | // it has actual values. |
| 38 | match type_hint { |
| 39 | ColumnTypeHint::Timestamp => ColumnCodec::DeltaFastLanesLz4, |
| 40 | ColumnTypeHint::Float64 => ColumnCodec::AlpFastLanesLz4, |
| 41 | ColumnTypeHint::Int64 => ColumnCodec::DeltaFastLanesLz4, |
| 42 | ColumnTypeHint::Symbol => ColumnCodec::FastLanesLz4, |
| 43 | ColumnTypeHint::String => ColumnCodec::FsstLz4, |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | /// Detect the optimal codec for an i64 column by analyzing the data. |
| 48 | /// |
no outgoing calls
no test coverage detected