| 1412 | } |
| 1413 | |
| 1414 | void |
| 1415 | HGraph::Deserialize(StreamReader& reader) { |
| 1416 | // try to deserialize footer (only in new version) |
| 1417 | auto footer = Footer::Parse(reader); |
| 1418 | |
| 1419 | if (footer == nullptr) { // old format, DON'T EDIT, remove in the future |
| 1420 | logger::debug("parse with v0.14 version format"); |
| 1421 | |
| 1422 | this->deserialize_basic_info_v0_14(reader); |
| 1423 | |
| 1424 | this->basic_flatten_codes_->Deserialize(reader); |
| 1425 | this->bottom_graph_->Deserialize(reader); |
| 1426 | if (this->use_reorder_) { |
| 1427 | this->high_precise_codes_->Deserialize(reader); |
| 1428 | } |
| 1429 | |
| 1430 | for (auto& route_graph : this->route_graphs_) { |
| 1431 | route_graph->Deserialize(reader); |
| 1432 | } |
| 1433 | auto new_size = max_capacity_.load(); |
| 1434 | this->neighbors_mutex_->Resize(new_size); |
| 1435 | |
| 1436 | pool_ = std::make_shared<VisitedListPool>(1, allocator_, new_size, allocator_); |
| 1437 | |
| 1438 | if (this->extra_info_size_ > 0 && this->extra_infos_ != nullptr) { |
| 1439 | this->extra_infos_->Deserialize(reader); |
| 1440 | } |
| 1441 | this->total_count_ = this->basic_flatten_codes_->TotalCount(); |
| 1442 | |
| 1443 | if (this->use_attribute_filter_ and this->attr_filter_index_ != nullptr) { |
| 1444 | this->attr_filter_index_->Deserialize(reader); |
| 1445 | } |
| 1446 | } else { // create like `else if ( ver in [v0.15, v0.17] )` here if need in the future |
| 1447 | logger::debug("parse with new version format"); |
| 1448 | |
| 1449 | BufferStreamReader buffer_reader( |
| 1450 | &reader, std::numeric_limits<uint64_t>::max(), this->allocator_); |
| 1451 | |
| 1452 | auto metadata = footer->GetMetadata(); |
| 1453 | // metadata should NOT be nullptr if footer is not nullptr |
| 1454 | this->deserialize_basic_info(metadata->Get(BASIC_INFO)); |
| 1455 | this->deserialize_label_info(buffer_reader); |
| 1456 | |
| 1457 | this->basic_flatten_codes_->Deserialize(buffer_reader); |
| 1458 | this->bottom_graph_->Deserialize(buffer_reader); |
| 1459 | if (this->use_reorder_) { |
| 1460 | this->high_precise_codes_->Deserialize(buffer_reader); |
| 1461 | } |
| 1462 | |
| 1463 | for (auto& route_graph : this->route_graphs_) { |
| 1464 | route_graph->Deserialize(buffer_reader); |
| 1465 | } |
| 1466 | auto new_size = max_capacity_.load(); |
| 1467 | this->neighbors_mutex_->Resize(new_size); |
| 1468 | |
| 1469 | pool_ = std::make_shared<VisitedListPool>(1, allocator_, new_size, allocator_); |
| 1470 | |
| 1471 | if (this->extra_info_size_ > 0 && this->extra_infos_ != nullptr) { |
no test coverage detected