From 786a3d891995b89515066354ce52f0d7664f5cde Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Sun, 2 Apr 2017 23:13:24 +0000 Subject: [PATCH] Read multi level graph to view --- include/partition/serialization.hpp | 2 +- src/storage/storage.cpp | 65 ++++++++++++++++------------- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/include/partition/serialization.hpp b/include/partition/serialization.hpp index 7d8ff5406..acf419b5d 100644 --- a/include/partition/serialization.hpp +++ b/include/partition/serialization.hpp @@ -21,7 +21,7 @@ inline void read(storage::io::FileReader &reader, MultiLevelGraph diff --git a/src/storage/storage.cpp b/src/storage/storage.cpp index 61888f823..f474510d0 100644 --- a/src/storage/storage.cpp +++ b/src/storage/storage.cpp @@ -7,8 +7,8 @@ #include "storage/shared_memory_ownership.hpp" #include "storage/shared_monitor.hpp" -#include "contractor/query_graph.hpp" #include "contractor/files.hpp" +#include "contractor/query_graph.hpp" #include "customizer/edge_based_graph.hpp" @@ -64,7 +64,8 @@ namespace storage { using RTreeLeaf = engine::datafacade::BaseDataFacade::RTreeLeaf; -using RTreeNode = util:: StaticRTree, storage::Ownership::View>::TreeNode; +using RTreeNode = util:: + StaticRTree, storage::Ownership::View>::TreeNode; using QueryGraph = util::StaticGraph; using EdgeBasedGraph = util::StaticGraph; @@ -223,8 +224,7 @@ void Storage::PopulateLayout(DataLayout &layout) auto num_offsets = reader.ReadVectorSize(); auto num_masks = reader.ReadVectorSize(); - layout.SetBlockSize(DataLayout::LANE_DESCRIPTION_OFFSETS, - num_offsets); + layout.SetBlockSize(DataLayout::LANE_DESCRIPTION_OFFSETS, num_offsets); layout.SetBlockSize( DataLayout::LANE_DESCRIPTION_MASKS, num_masks); } @@ -259,15 +259,17 @@ void Storage::PopulateLayout(DataLayout &layout) layout.SetBlockSize(DataLayout::HSGR_CHECKSUM, 1); layout.SetBlockSize(DataLayout::CH_GRAPH_NODE_LIST, - num_nodes); + num_nodes); layout.SetBlockSize(DataLayout::CH_GRAPH_EDGE_LIST, - num_edges); + num_edges); } else { layout.SetBlockSize(DataLayout::HSGR_CHECKSUM, 0); - layout.SetBlockSize(DataLayout::CH_GRAPH_NODE_LIST, 0); - layout.SetBlockSize(DataLayout::CH_GRAPH_EDGE_LIST, 0); + layout.SetBlockSize(DataLayout::CH_GRAPH_NODE_LIST, + 0); + layout.SetBlockSize(DataLayout::CH_GRAPH_EDGE_LIST, + 0); } // load rsearch tree size @@ -507,10 +509,10 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr) else { layout.GetBlockPtr(memory_ptr, DataLayout::HSGR_CHECKSUM); - layout.GetBlockPtr(memory_ptr, - DataLayout::CH_GRAPH_NODE_LIST); - layout.GetBlockPtr(memory_ptr, - DataLayout::CH_GRAPH_EDGE_LIST); + layout.GetBlockPtr( + memory_ptr, DataLayout::CH_GRAPH_NODE_LIST); + layout.GetBlockPtr( + memory_ptr, DataLayout::CH_GRAPH_EDGE_LIST); } // store the filename of the on-disk portion of the RTree @@ -568,7 +570,8 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr) util::vector_view masks( masks_ptr, layout.num_entries[storage::DataLayout::LANE_DESCRIPTION_MASKS]); - extractor::files::readTurnLaneDescriptions(config.turn_lane_description_path, offsets, masks); + extractor::files::readTurnLaneDescriptions( + config.turn_lane_description_path, offsets, masks); } // Load original edge data @@ -949,24 +952,28 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr) if (boost::filesystem::exists(config.mld_graph_path)) { - io::FileReader reader(config.mld_graph_path, io::FileReader::VerifyFingerprint); - auto nodes_ptr = - layout.GetBlockPtr( - memory_ptr, DataLayout::MLD_GRAPH_NODE_LIST); - auto edges_ptr = - layout.GetBlockPtr( - memory_ptr, DataLayout::MLD_GRAPH_EDGE_LIST); - auto node_to_offset_ptr = - layout.GetBlockPtr( - memory_ptr, DataLayout::MLD_GRAPH_NODE_TO_OFFSET); + auto graph_nodes_ptr = + layout.GetBlockPtr( + memory_ptr, storage::DataLayout::MLD_GRAPH_NODE_LIST); + auto graph_edges_ptr = + layout.GetBlockPtr( + memory_ptr, storage::DataLayout::MLD_GRAPH_EDGE_LIST); + auto graph_node_to_offset_ptr = + layout.GetBlockPtr( + memory_ptr, storage::DataLayout::MLD_GRAPH_NODE_TO_OFFSET); - auto num_nodes = reader.ReadElementCount64(); - reader.ReadInto(nodes_ptr, num_nodes); - auto num_edges = reader.ReadElementCount64(); - reader.ReadInto(edges_ptr, num_edges); - auto num_node_to_offset = reader.ReadElementCount64(); - reader.ReadInto(node_to_offset_ptr, num_node_to_offset); + util::vector_view node_list( + graph_nodes_ptr, layout.num_entries[storage::DataLayout::MLD_GRAPH_NODE_LIST]); + util::vector_view edge_list( + graph_edges_ptr, layout.num_entries[storage::DataLayout::MLD_GRAPH_EDGE_LIST]); + util::vector_view node_to_offset( + graph_node_to_offset_ptr, + layout.num_entries[storage::DataLayout::MLD_GRAPH_NODE_TO_OFFSET]); + + customizer::MultiLevelEdgeBasedGraphView graph_view( + std::move(node_list), std::move(edge_list), std::move(node_to_offset)); + partition::files::readGraph(config.mld_graph_path, graph_view); } } }