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

Function ts_schema_to_shared

nodedb/src/engine/timeseries/columnar_bridge.rs:29–45  ·  view source on GitHub ↗

Convert a timeseries ColumnarSchema to a shared ColumnarSchema. `Symbol` columns are mapped to `Int64` in the shared schema (the u32 symbol IDs are stored as i64). The symbol dictionary is persisted separately.

(ts_schema: &super::columnar_memtable::ColumnarSchema)

Source from the content-addressed store, hash-verified

27/// symbol IDs are stored as i64). The symbol dictionary is persisted
28/// separately.
29pub fn ts_schema_to_shared(ts_schema: &super::columnar_memtable::ColumnarSchema) -> ColumnarSchema {
30 let columns: Vec<ColumnDef> = ts_schema
31 .columns
32 .iter()
33 .map(|(name, ts_type)| {
34 let shared_type = ts_column_type_to_shared(*ts_type);
35 // All timeseries columns are non-nullable (metrics always present).
36 ColumnDef::required(name.clone(), shared_type)
37 })
38 .collect();
39
40 // Schema validation can't fail here since we're converting known-good types.
41 ColumnarSchema {
42 columns,
43 version: 1,
44 }
45}
46
47/// Map a timeseries ColumnType to a shared ColumnType.
48fn ts_column_type_to_shared(ts_type: TsColumnType) -> SharedColumnType {

Callers 2

schema_conversionFunction · 0.85

Calls 5

ts_column_type_to_sharedFunction · 0.85
requiredFunction · 0.85
collectMethod · 0.80
iterMethod · 0.45
cloneMethod · 0.45

Tested by 1

schema_conversionFunction · 0.68