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

Function flattenColumns

pj_datastore/src/reader.cpp:48–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48void flattenColumns(
49 const TypeTreeNode& node, std::string_view prefix, FieldId& next_id, std::vector<ColumnDescriptor>& out) {
50 const std::string path = prefix.empty() ? node.name : std::string(prefix) + "." + node.name;
51
52 if (node.kind == TypeKind::kStruct) {
53 for (const auto& child : node.children) {
54 flattenColumns(*child, path, next_id, out);
55 }
56 return;
57 }
58
59 if (node.kind == TypeKind::kArray) {
60 if (!node.element_type || !node.fixed_array_size.has_value()) {
61 return;
62 }
63 for (uint32_t i = 0; i < *node.fixed_array_size; ++i) {
64 const std::string element_path = path + "[" + std::to_string(i) + "]";
65 if (node.element_type->kind == TypeKind::kStruct) {
66 for (const auto& child : node.element_type->children) {
67 flattenColumns(*child, element_path, next_id, out);
68 }
69 } else {
70 out.push_back(
71 ColumnDescriptor{
72 .field_id = next_id++,
73 .logical_type = node.element_type->primitive_type.value_or(PrimitiveType::kFloat64),
74 .field_path = element_path,
75 });
76 }
77 }
78 return;
79 }
80
81 out.push_back(
82 ColumnDescriptor{
83 .field_id = next_id++,
84 .logical_type = node.primitive_type.value_or(PrimitiveType::kFloat64),
85 .field_path = path,
86 });
87}
88
89[[nodiscard]] std::vector<ColumnDescriptor> columnsForTopic(const DataEngine& engine, const TopicStorage& storage) {
90 if (!storage.columnDescriptors().empty()) {

Callers 1

columnsForTopicFunction · 0.85

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected