diff --git a/include/extractor/node_data_container.hpp b/include/extractor/node_data_container.hpp index d89fe4835d3..ea506fc17fc 100644 --- a/include/extractor/node_data_container.hpp +++ b/include/extractor/node_data_container.hpp @@ -1,9 +1,12 @@ #ifndef OSRM_EXTRACTOR_NODE_DATA_CONTAINER_HPP #define OSRM_EXTRACTOR_NODE_DATA_CONTAINER_HPP +#include "extractor/travel_mode.hpp" + #include "storage/io_fwd.hpp" #include "storage/shared_memory_ownership.hpp" +#include "util/permutation.hpp" #include "util/typedefs.hpp" #include "util/vector_view.hpp" @@ -81,6 +84,15 @@ template class EdgeBasedNodeDataContainerImpl serialization::write(storage::io::FileWriter &writer, const EdgeBasedNodeDataContainerImpl &ebn_data_container); + template > + void Renumber(const std::vector &permutation) + { + util::inplacePermutation(geometry_ids.begin(), geometry_ids.end(), permutation); + util::inplacePermutation(name_ids.begin(), name_ids.end(), permutation); + util::inplacePermutation(component_ids.begin(), component_ids.end(), permutation); + util::inplacePermutation(travel_modes.begin(), travel_modes.end(), permutation); + } + private: Vector geometry_ids; Vector name_ids; diff --git a/include/partition/partition_config.hpp b/include/partition/partition_config.hpp index 7d2805c2b39..a5f4950b371 100644 --- a/include/partition/partition_config.hpp +++ b/include/partition/partition_config.hpp @@ -41,6 +41,7 @@ struct PartitionConfig file_index_path = basepath + ".osrm.fileIndex"; partition_path = basepath + ".osrm.partition"; storage_path = basepath + ".osrm.cells"; + node_data_path = basepath + ".osrm.ebg_nodes"; } // might be changed to the node based graph at some point @@ -51,6 +52,7 @@ struct PartitionConfig boost::filesystem::path partition_path; boost::filesystem::path file_index_path; boost::filesystem::path storage_path; + boost::filesystem::path node_data_path; unsigned requested_num_threads; diff --git a/include/partition/renumber.hpp b/include/partition/renumber.hpp index 20e3ff455c4..ad09a324152 100644 --- a/include/partition/renumber.hpp +++ b/include/partition/renumber.hpp @@ -2,6 +2,7 @@ #define OSRM_PARTITION_RENUMBER_HPP #include "extractor/edge_based_node_segment.hpp" +#include "extractor/node_data_container.hpp" #include "partition/bisection_to_partition.hpp" #include "partition/edge_based_graph.hpp" @@ -10,15 +11,23 @@ namespace osrm { namespace partition { -std::vector makePermutation(const DynamicEdgeBasedGraph &graph, const std::vector &partitions); +std::vector makePermutation(const DynamicEdgeBasedGraph &graph, + const std::vector &partitions); -inline void renumber(DynamicEdgeBasedGraph& graph, const std::vector &permutation) +inline void renumber(DynamicEdgeBasedGraph &graph, const std::vector &permutation) { // Graph has own specilization graph.Renumber(permutation); } -inline void renumber(std::vector &partitions, const std::vector &permutation) +inline void renumber(extractor::EdgeBasedNodeDataContainer &node_data_container, + const std::vector &permutation) +{ + node_data_container.Renumber(permutation); +} + +inline void renumber(std::vector &partitions, + const std::vector &permutation) { for (auto &partition : partitions) { @@ -26,15 +35,17 @@ inline void renumber(std::vector &partitions, const std::vector &segments, const std::vector &permutation) +inline void renumber(util::vector_view &segments, + const std::vector &permutation) { for (auto &segment : segments) { + BOOST_ASSERT(segment.forward_segment_id.enabled); segment.forward_segment_id.id = permutation[segment.forward_segment_id.id]; - segment.reverse_segment_id.id = permutation[segment.reverse_segment_id.id]; + if (segment.reverse_segment_id.enabled) + segment.reverse_segment_id.id = permutation[segment.reverse_segment_id.id]; } } - } } diff --git a/src/partition/partitioner.cpp b/src/partition/partitioner.cpp index 5b901c8ad7b..d4806b7fe25 100644 --- a/src/partition/partitioner.cpp +++ b/src/partition/partitioner.cpp @@ -184,6 +184,12 @@ int Partitioner::Run(const PartitionConfig &config) auto segments = util::mmapFile(config.file_index_path, segment_region); renumber(segments, permutation); } + { + extractor::EdgeBasedNodeDataContainer node_data; + extractor::files::readNodeData(config.node_data_path, node_data); + renumber(node_data, permutation); + extractor::files::writeNodeData(config.node_data_path, node_data); + } TIMER_STOP(renumber); util::Log() << "Renumbered graph in " << TIMER_SEC(renumber) << " seconds";