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

Function detect_codec

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

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)

Source from the content-addressed store, hash-verified

28/// data-aware selection (ALP encodability, monotonicity detection),
29/// use `detect_f64_codec()` or `detect_i64_codec()` with actual values.
30pub 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///

Callers 2

select_codecFunction · 0.85
encode_columnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected