MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / flattenArrayElementImpl

Function flattenArrayElementImpl

pj_datastore/src/writer.cpp:108–122  ·  view source on GitHub ↗

Expand one array element (at path `element_path`, e.g., "poses[0]") into ColumnDescriptors. Handles: struct element (recurse into children), primitive/enum element (single column).

Source from the content-addressed store, hash-verified

106// Expand one array element (at path `element_path`, e.g., "poses[0]") into ColumnDescriptors.
107// Handles: struct element (recurse into children), primitive/enum element (single column).
108void flattenArrayElementImpl(
109 const TypeTreeNode& element_type, std::string_view element_path, FieldId& next_field_id,
110 std::vector<ColumnDescriptor>& out) {
111 if (element_type.kind == TypeKind::kStruct) {
112 for (const auto& child : element_type.children) {
113 flattenColumnsImpl(*child, element_path, next_field_id, out);
114 }
115 } else {
116 ColumnDescriptor desc;
117 desc.field_id = next_field_id++;
118 desc.field_path = std::string(element_path);
119 desc.logical_type = element_type.primitive_type.value_or(PrimitiveType::kFloat64);
120 out.push_back(std::move(desc));
121 }
122}
123
124/// Recursively flatten a type tree into ColumnDescriptors, collecting both
125/// field paths and PrimitiveTypes for each leaf node.

Callers 2

flattenColumnsImplFunction · 0.85
expandArrayMethod · 0.85

Calls 1

flattenColumnsImplFunction · 0.70

Tested by

no test coverage detected