MCPcopy Create free account
hub / github.com/comaps/comaps / LoadHierachy

Function LoadHierachy

generator/hierarchy_entry.cpp:121–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121tree_node::types::Ptrs<HierarchyEntry> LoadHierachy(std::string const & filename)
122{
123 ankerl::unordered_dense::map<CompositeId, tree_node::types::Ptr<HierarchyEntry>> nodes;
124 for (auto const & row : coding::CSVRunner(coding::CSVReader(filename, false /* hasHeader */, kCsvDelimiter)))
125 {
126 auto entry = HierarchyEntryFromCsvRow(row);
127 auto const id = entry.m_id;
128 nodes.emplace(id, tree_node::MakeTreeNode(std::move(entry)));
129 }
130 for (auto const & pair : nodes)
131 {
132 auto const & node = pair.second;
133 auto const parentIdOpt = node->GetData().m_parentId;
134 if (parentIdOpt)
135 {
136 auto const it = nodes.find(*parentIdOpt);
137 CHECK(it != std::cend(nodes), (*it));
138 tree_node::Link(node, it->second);
139 }
140 }
141 std::vector<tree_node::types::Ptr<HierarchyEntry>> trees;
142 base::Transform(nodes, std::back_inserter(trees), base::RetrieveSecond());
143 base::EraseIf(trees, [](auto const & node) { return node->HasParent(); });
144 return trees;
145}
146} // namespace hierarchy
147} // namespace generator

Callers 3

ComplexLoaderMethod · 0.85
UNIT_CLASS_TESTFunction · 0.85
UNIT_CLASS_TESTFunction · 0.85

Calls 13

CSVRunnerClass · 0.85
CSVReaderClass · 0.85
HierarchyEntryFromCsvRowFunction · 0.85
MakeTreeNodeFunction · 0.85
cendFunction · 0.85
TransformFunction · 0.85
RetrieveSecondClass · 0.85
EraseIfFunction · 0.85
LinkFunction · 0.50
emplaceMethod · 0.45
GetDataMethod · 0.45
findMethod · 0.45

Tested by 2

UNIT_CLASS_TESTFunction · 0.68
UNIT_CLASS_TESTFunction · 0.68