Skip to content

Commit

Permalink
Renumber ebg_nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarex committed May 25, 2017
1 parent 13bd2a6 commit 5c61a92
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
12 changes: 12 additions & 0 deletions include/extractor/node_data_container.hpp
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -81,6 +84,15 @@ template <storage::Ownership Ownership> class EdgeBasedNodeDataContainerImpl
serialization::write<Ownership>(storage::io::FileWriter &writer,
const EdgeBasedNodeDataContainerImpl &ebn_data_container);

template <typename = std::enable_if<Ownership == storage::Ownership::Container>>
void Renumber(const std::vector<std::uint32_t> &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<GeometryID> geometry_ids;
Vector<NameID> name_ids;
Expand Down
2 changes: 2 additions & 0 deletions include/partition/partition_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down
23 changes: 17 additions & 6 deletions include/partition/renumber.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -10,31 +11,41 @@ namespace osrm
{
namespace partition
{
std::vector<std::uint32_t> makePermutation(const DynamicEdgeBasedGraph &graph, const std::vector<Partition> &partitions);
std::vector<std::uint32_t> makePermutation(const DynamicEdgeBasedGraph &graph,
const std::vector<Partition> &partitions);

inline void renumber(DynamicEdgeBasedGraph& graph, const std::vector<std::uint32_t> &permutation)
inline void renumber(DynamicEdgeBasedGraph &graph, const std::vector<std::uint32_t> &permutation)
{
// Graph has own specilization
graph.Renumber(permutation);
}

inline void renumber(std::vector<Partition> &partitions, const std::vector<std::uint32_t> &permutation)
inline void renumber(extractor::EdgeBasedNodeDataContainer &node_data_container,
const std::vector<std::uint32_t> &permutation)
{
node_data_container.Renumber(permutation);
}

inline void renumber(std::vector<Partition> &partitions,
const std::vector<std::uint32_t> &permutation)
{
for (auto &partition : partitions)
{
util::inplacePermutation(partition.begin(), partition.end(), permutation);
}
}

inline void renumber(util::vector_view<extractor::EdgeBasedNodeSegment> &segments, const std::vector<std::uint32_t> &permutation)
inline void renumber(util::vector_view<extractor::EdgeBasedNodeSegment> &segments,
const std::vector<std::uint32_t> &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];
}
}

}
}

Expand Down
6 changes: 6 additions & 0 deletions src/partition/partitioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ int Partitioner::Run(const PartitionConfig &config)
auto segments = util::mmapFile<extractor::EdgeBasedNodeSegment>(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";

Expand Down

0 comments on commit 5c61a92

Please sign in to comment.