From bced9a5a6d84177b7c4987cf9645db5d74c76414 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Mon, 19 Mar 2018 12:49:49 +0000 Subject: [PATCH] Port .datasource_names to tar format --- include/extractor/files.hpp | 28 ++++++++++++++-------------- include/extractor/serialization.hpp | 9 +++++---- src/storage/storage.cpp | 9 +++------ 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/include/extractor/files.hpp b/include/extractor/files.hpp index 273b9c73b..32bab8e73 100644 --- a/include/extractor/files.hpp +++ b/include/extractor/files.hpp @@ -107,7 +107,7 @@ void readEdgeBasedGraph(const boost::filesystem::path &path, connectivity_checksum = reader.ReadOne("/common/connectivity_checksum"); } -// reads .osrm.nodes +// reads .osrm.nbg_nodes template inline void readNodes(const boost::filesystem::path &path, CoordinatesT &coordinates, @@ -123,7 +123,7 @@ inline void readNodes(const boost::filesystem::path &path, util::serialization::read(reader, "/common/osm_node_ids", osm_node_ids); } -// writes .osrm.nodes +// writes .osrm.nbg_nodes template inline void writeNodes(const boost::filesystem::path &path, const CoordinatesT &coordinates, @@ -142,38 +142,38 @@ inline void writeNodes(const boost::filesystem::path &path, // reads .osrm.cnbg_to_ebg inline void readNBGMapping(const boost::filesystem::path &path, std::vector &mapping) { - const auto fingerprint = storage::io::FileReader::VerifyFingerprint; - storage::io::FileReader reader{path, fingerprint}; + const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; + storage::tar::FileReader reader{path, fingerprint}; - storage::serialization::read(reader, mapping); + storage::serialization::read(reader, "/common/cnbg_to_ebg", mapping); } // writes .osrm.cnbg_to_ebg inline void writeNBGMapping(const boost::filesystem::path &path, const std::vector &mapping) { - const auto fingerprint = storage::io::FileWriter::GenerateFingerprint; - storage::io::FileWriter writer{path, fingerprint}; + const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; + storage::tar::FileWriter writer{path, fingerprint}; - storage::serialization::write(writer, mapping); + storage::serialization::write(writer, "/common/cnbg_to_ebg", mapping); } // reads .osrm.datasource_names inline void readDatasources(const boost::filesystem::path &path, Datasources &sources) { - const auto fingerprint = storage::io::FileReader::VerifyFingerprint; - storage::io::FileReader reader{path, fingerprint}; + const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; + storage::tar::FileReader reader{path, fingerprint}; - serialization::read(reader, sources); + serialization::read(reader, "/common/data_sources_names", sources); } // writes .osrm.datasource_names inline void writeDatasources(const boost::filesystem::path &path, Datasources &sources) { - const auto fingerprint = storage::io::FileWriter::GenerateFingerprint; - storage::io::FileWriter writer{path, fingerprint}; + const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; + storage::tar::FileWriter writer{path, fingerprint}; - serialization::write(writer, sources); + serialization::write(writer, "/common/data_sources_names", sources); } // reads .osrm.geometry diff --git a/include/extractor/serialization.hpp b/include/extractor/serialization.hpp index 4aff2a0db..2edb453cc 100644 --- a/include/extractor/serialization.hpp +++ b/include/extractor/serialization.hpp @@ -64,14 +64,15 @@ inline void write(storage::tar::FileWriter &writer, } // read/write for datasources file -inline void read(storage::io::FileReader &reader, Datasources &sources) +inline void read(storage::tar::FileReader &reader, const std::string& name, Datasources &sources) { - reader.ReadInto(sources); + sources = reader.ReadOne(name); } -inline void write(storage::io::FileWriter &writer, Datasources &sources) +inline void write(storage::tar::FileWriter &writer, const std::string& name, Datasources &sources) { - writer.WriteFrom(sources); + writer.WriteElementCount64(name, 1); + writer.WriteOne(name, sources); } // read/write for segment data file diff --git a/src/storage/storage.cpp b/src/storage/storage.cpp index 3e16ab351..78970c4be 100644 --- a/src/storage/storage.cpp +++ b/src/storage/storage.cpp @@ -372,11 +372,6 @@ void Storage::PopulateLayout(DataLayout &layout) make_block(number_of_compressed_geometries)); } - // Load datasource name sizes. - { - layout.SetBlock(DataLayout::DATASOURCES_NAMES, make_block(1)); - } - { // Loading turn lane data io::FileReader lane_data_file(config.GetPath(".osrm.tld"), @@ -447,6 +442,7 @@ void Storage::PopulateLayout(DataLayout &layout) {"/common/properties", DataLayout::PROPERTIES}, {"/common/coordinates", DataLayout::COORDINATE_LIST}, {"/common/osm_node_ids/packed", DataLayout::OSM_NODE_ID_LIST}, + {"/common/data_sources_names", DataLayout::DATASOURCES_NAMES}, }; std::vector blocks; @@ -460,7 +456,8 @@ void Storage::PopulateLayout(DataLayout &layout) {OPTIONAL, config.GetPath(".osrm.hsgr")}, {REQUIRED, config.GetPath(".osrm.icd")}, {REQUIRED, config.GetPath(".osrm.properties")}, - {REQUIRED, config.GetPath(".osrm.nbg_nodes")} + {REQUIRED, config.GetPath(".osrm.nbg_nodes")}, + {REQUIRED, config.GetPath(".osrm.datasource_names")} }; for (const auto &file : tar_files)