| 87 | } |
| 88 | |
| 89 | [[nodiscard]] std::vector<ColumnDescriptor> columnsForTopic(const DataEngine& engine, const TopicStorage& storage) { |
| 90 | if (!storage.columnDescriptors().empty()) { |
| 91 | return storage.columnDescriptors(); |
| 92 | } |
| 93 | |
| 94 | const auto& chunks = storage.sealedChunks(); |
| 95 | if (!chunks.empty()) { |
| 96 | std::vector<ColumnDescriptor> columns; |
| 97 | columns.reserve(chunks.front().columns.size()); |
| 98 | for (const auto& column : chunks.front().columns) { |
| 99 | if (column.descriptor) { |
| 100 | columns.push_back(*column.descriptor); |
| 101 | } |
| 102 | } |
| 103 | return columns; |
| 104 | } |
| 105 | |
| 106 | const TypeTreeNode* type_tree = engine.typeRegistry().lookup(storage.descriptor().schema_id); |
| 107 | if (type_tree == nullptr) { |
| 108 | return {}; |
| 109 | } |
| 110 | |
| 111 | std::vector<ColumnDescriptor> columns; |
| 112 | FieldId next_id = 0; |
| 113 | if (type_tree->kind == TypeKind::kStruct) { |
| 114 | for (const auto& child : type_tree->children) { |
| 115 | flattenColumns(*child, "", next_id, columns); |
| 116 | } |
| 117 | } else { |
| 118 | flattenColumns(*type_tree, "", next_id, columns); |
| 119 | } |
| 120 | return columns; |
| 121 | } |
| 122 | |
| 123 | } // namespace |
| 124 |
no test coverage detected