| 40 | } |
| 41 | |
| 42 | ::std::unique_ptr<Graph> GraphBuilder::build() const noexcept { |
| 43 | ::std::unique_ptr<Graph> graph {new Graph}; |
| 44 | graph->set_executor(*_executor); |
| 45 | graph->set_page_allocator(*_page_allocator); |
| 46 | graph->initialize_data(_data_index_for_name); |
| 47 | graph->initialize_vertexes(_vertexes.size()); |
| 48 | auto& vertexes = graph->vertexes(); |
| 49 | |
| 50 | for (size_t i = 0; i < _vertexes.size(); ++i) { |
| 51 | auto& builder = _vertexes[i]; |
| 52 | auto& vertex = vertexes[i]; |
| 53 | if (0 != builder->build(*graph, vertex)) { |
| 54 | BABYLON_LOG(WARNING) << "build " << *builder << " failed"; |
| 55 | return ::std::unique_ptr<Graph>(); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | for (const auto& one_data : graph->data()) { |
| 60 | if (ABSL_PREDICT_FALSE(0 != one_data.error_code())) { |
| 61 | BABYLON_LOG(WARNING) << one_data << " build failed"; |
| 62 | return ::std::unique_ptr<Graph>(); |
| 63 | } |
| 64 | if (ABSL_PREDICT_FALSE(!one_data.check_safe_mutable())) { |
| 65 | BABYLON_LOG(WARNING) << one_data << " mutable but non exclusive"; |
| 66 | return ::std::unique_ptr<Graph>(); |
| 67 | } |
| 68 | } |
| 69 | return graph; |
| 70 | } |
| 71 | |
| 72 | size_t GraphBuilder::get_or_allocate_data_index(StringView name) noexcept { |
| 73 | size_t data_index = _data_index_for_name.size(); |
nothing calls this directly
no test coverage detected