diff --git a/include/extractor/files.hpp b/include/extractor/files.hpp index da4d9d96e..dd5793905 100644 --- a/include/extractor/files.hpp +++ b/include/extractor/files.hpp @@ -439,6 +439,24 @@ void writeNames(const boost::filesystem::path &path, const NameTableT &table) serialization::write(writer, "/common/names", table); } + +template +void readEdgeBasedNodeWeights(const boost::filesystem::path &path, NodeWeigtsVectorT &weights) +{ + const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; + storage::tar::FileReader reader{path, fingerprint}; + + storage::serialization::read(reader, "/extractor/edge_based_node_weights", weights); +} + +template +void writeEdgeBasedNodeWeights(const boost::filesystem::path &path, const NodeWeigtsVectorT &weights) +{ + const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; + storage::tar::FileWriter writer{path, fingerprint}; + + storage::serialization::write(writer, "/extractor/edge_based_node_weights", weights); +} } } } diff --git a/src/contractor/contractor.cpp b/src/contractor/contractor.cpp index 3aa874d39..45a0ce036 100644 --- a/src/contractor/contractor.cpp +++ b/src/contractor/contractor.cpp @@ -63,11 +63,7 @@ int Contractor::Run() util::Log() << "Reading node weights."; std::vector node_weights; - { - storage::io::FileReader reader(config.GetPath(".osrm.enw"), - storage::io::FileReader::VerifyFingerprint); - storage::serialization::read(reader, node_weights); - } + extractor::files::readEdgeBasedNodeWeights(config.GetPath(".osrm.enw"), node_weights); util::Log() << "Done reading node weights."; util::Log() << "Loading edge-expanded graph representation"; diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp index 07b80a8ca..54a75704f 100644 --- a/src/extractor/extractor.cpp +++ b/src/extractor/extractor.cpp @@ -325,11 +325,7 @@ int Extractor::run(ScriptingEnvironment &scripting_environment) util::Log() << "Saving edge-based node weights to file."; TIMER_START(timer_write_node_weights); - { - storage::io::FileWriter writer(config.GetPath(".osrm.enw"), - storage::io::FileWriter::GenerateFingerprint); - storage::serialization::write(writer, edge_based_node_weights); - } + extractor::files::writeEdgeBasedNodeWeights(config.GetPath(".osrm.enw"), edge_based_node_weights); TIMER_STOP(timer_write_node_weights); util::Log() << "Done writing. (" << TIMER_SEC(timer_write_node_weights) << ")";