From dff8c488424b21d539bf8051c706bbc8850bcc2a Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Tue, 7 Mar 2017 15:43:41 +0100 Subject: [PATCH] added reading cell storage in customizer --- include/partition/cell_storage.hpp | 5 +++++ include/partition/io.hpp | 12 ++++++++++++ src/customize/customizer.cpp | 5 +++-- src/partition/partitioner.cpp | 6 ++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/partition/cell_storage.hpp b/include/partition/cell_storage.hpp index 412c9f20e..302ca5652 100644 --- a/include/partition/cell_storage.hpp +++ b/include/partition/cell_storage.hpp @@ -33,6 +33,9 @@ using CellStorageView = detail::CellStorageImpl; namespace io { template +inline void read(const boost::filesystem::path &path, + detail::CellStorageImpl &storage); +template inline void write(const boost::filesystem::path &path, const detail::CellStorageImpl &storage); } @@ -346,6 +349,8 @@ template class CellStorageImpl cells[cell_index], weights.data(), source_boundary.data(), destination_boundary.data()}; } + friend void io::read(const boost::filesystem::path &path, + detail::CellStorageImpl &storage); friend void io::write(const boost::filesystem::path &path, const detail::CellStorageImpl &storage); diff --git a/include/partition/io.hpp b/include/partition/io.hpp index 1c6ddc484..bdfe5867b 100644 --- a/include/partition/io.hpp +++ b/include/partition/io.hpp @@ -33,6 +33,18 @@ template <> inline void write(const boost::filesystem::path &path, const MultiLe writer.SerializeVector(mlp.cell_to_children); } +template <> inline void read(const boost::filesystem::path &path, CellStorage &storage) +{ + const auto fingerprint = storage::io::FileReader::VerifyFingerprint; + storage::io::FileReader reader{path, fingerprint}; + + reader.DeserializeVector(storage.weights); + reader.DeserializeVector(storage.source_boundary); + reader.DeserializeVector(storage.destination_boundary); + reader.DeserializeVector(storage.cells); + reader.DeserializeVector(storage.level_to_cell_offset); +} + template <> inline void write(const boost::filesystem::path &path, const CellStorage &storage) { const auto fingerprint = storage::io::FileWriter::GenerateFingerprint; diff --git a/src/customize/customizer.cpp b/src/customize/customizer.cpp index 32a550f50..3e01dc8be 100644 --- a/src/customize/customizer.cpp +++ b/src/customize/customizer.cpp @@ -74,10 +74,11 @@ int Customizer::Run(const CustomizationConfig &config) << edge_based_graph->GetNumberOfEdges() << " edges, " << edge_based_graph->GetNumberOfNodes() << " nodes"; - osrm::partition::MultiLevelPartition mlp; + partition::MultiLevelPartition mlp; partition::io::read(config.mld_partition_path, mlp); - partition::CellStorage storage(mlp, *edge_based_graph); + partition::CellStorage storage; + partition::io::read(config.mld_storage_path, storage); TIMER_STOP(loading_data); util::Log() << "Loading partition data took " << TIMER_SEC(loading_data) << " seconds"; diff --git a/src/partition/partitioner.cpp b/src/partition/partitioner.cpp index 23db81b09..57fc5f03a 100644 --- a/src/partition/partitioner.cpp +++ b/src/partition/partitioner.cpp @@ -181,8 +181,14 @@ int Partitioner::Run(const PartitionConfig &config) TIMER_STOP(packed_mlp); util::Log() << "MultiLevelPartition constructed in " << TIMER_SEC(packed_mlp) << " seconds"; + TIMER_START(cell_storage); + CellStorage storage(mlp, *edge_based_graph); + TIMER_STOP(cell_storage); + util::Log() << "CellStorage constructed in " << TIMER_SEC(cell_storage) << " seconds"; + TIMER_START(writing_mld_data); io::write(config.mld_partition_path, mlp); + io::write(config.mld_storage_path, storage); TIMER_STOP(writing_mld_data); util::Log() << "MLD data writing took " << TIMER_SEC(writing_mld_data) << " seconds";