From ec3cda32fad54850a71a9d8c32113fd1d6711dc6 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Tue, 7 Mar 2017 13:57:55 +0100 Subject: [PATCH] moved basic type definitions to osrm namespace --- include/customizer/cell_customizer.hpp | 9 +++----- .../contiguous_internalmem_datafacade.hpp | 12 +++++----- include/partition/cell_storage.hpp | 17 +++++++------- include/partition/io.hpp | 3 +-- include/partition/multi_level_partition.hpp | 6 ----- include/util/typedefs.hpp | 9 +++++++- src/customize/customizer.cpp | 18 +++++++-------- src/partition/partitioner.cpp | 2 +- src/storage/storage.cpp | 22 +++++++++---------- 9 files changed, 46 insertions(+), 52 deletions(-) diff --git a/include/customizer/cell_customizer.hpp b/include/customizer/cell_customizer.hpp index 67c69fe12..cda079601 100644 --- a/include/customizer/cell_customizer.hpp +++ b/include/customizer/cell_customizer.hpp @@ -20,10 +20,7 @@ class CellCustomizer CellCustomizer(const partition::MultiLevelPartition &partition) : partition(partition) {} template - void Customize(const GraphT &graph, - partition::CellStorage &cells, - partition::LevelID level, - partition::CellID id) + void Customize(const GraphT &graph, partition::CellStorage &cells, LevelID level, CellID id) { auto cell = cells.GetCell(level, id); auto destinations = cell.GetDestinationNodes(); @@ -87,8 +84,8 @@ class CellCustomizer void RelaxNode(const GraphT &graph, const partition::CellStorage &cells, Heap &heap, - partition::LevelID level, - partition::CellID id, + LevelID level, + CellID id, NodeID node, EdgeWeight weight) const { diff --git a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp index db71ce464..16d9464dc 100644 --- a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp +++ b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp @@ -1110,19 +1110,19 @@ class ContiguousInternalMemoryAlgorithmDataFacade *data_layout.GetBlockPtr( memory_block, storage::DataLayout::MLD_LEVEL_DATA); - auto mld_partition_ptr = data_layout.GetBlockPtr( + auto mld_partition_ptr = data_layout.GetBlockPtr( memory_block, storage::DataLayout::MLD_PARTITION); auto partition_entries_count = data_layout.GetBlockEntries(storage::DataLayout::MLD_PARTITION); - util::ShM::vector partition(mld_partition_ptr, - partition_entries_count); + util::ShM::vector partition(mld_partition_ptr, + partition_entries_count); - auto mld_chilren_ptr = data_layout.GetBlockPtr( + auto mld_chilren_ptr = data_layout.GetBlockPtr( memory_block, storage::DataLayout::MLD_CELL_TO_CHILDREN); auto children_entries_count = data_layout.GetBlockEntries(storage::DataLayout::MLD_CELL_TO_CHILDREN); - util::ShM::vector cell_to_children(mld_chilren_ptr, - children_entries_count); + util::ShM::vector cell_to_children(mld_chilren_ptr, + children_entries_count); mld_partition = partition::MultiLevelPartitionView{level_data, partition, cell_to_children}; diff --git a/include/partition/cell_storage.hpp b/include/partition/cell_storage.hpp index 5937a3552..412c9f20e 100644 --- a/include/partition/cell_storage.hpp +++ b/include/partition/cell_storage.hpp @@ -177,7 +177,7 @@ template class CellStorageImpl } }; - std::size_t LevelIDToIndex(partition::LevelID level) const { return level - 1; } + std::size_t LevelIDToIndex(LevelID level) const { return level - 1; } public: using Cell = CellImpl; @@ -190,7 +190,7 @@ template class CellStorageImpl { // pre-allocate storge for CellData so we can have random access to it by cell id unsigned number_of_cells = 0; - for (partition::LevelID level = 1u; level < partition.GetNumberOfLevels(); ++level) + for (LevelID level = 1u; level < partition.GetNumberOfLevels(); ++level) { level_to_cell_offset.push_back(number_of_cells); number_of_cells += partition.GetNumberOfCells(level); @@ -198,12 +198,12 @@ template class CellStorageImpl level_to_cell_offset.push_back(number_of_cells); cells.resize(number_of_cells); - std::vector> level_source_boundary; - std::vector> level_destination_boundary; + std::vector> level_source_boundary; + std::vector> level_destination_boundary; std::size_t number_of_unconneced = 0; - for (partition::LevelID level = 1u; level < partition.GetNumberOfLevels(); ++level) + for (LevelID level = 1u; level < partition.GetNumberOfLevels(); ++level) { auto level_offset = level_to_cell_offset[LevelIDToIndex(level)]; @@ -212,7 +212,7 @@ template class CellStorageImpl for (auto node = 0u; node < base_graph.GetNumberOfNodes(); ++node) { - const partition::CellID cell_id = partition.GetCell(level, node); + const CellID cell_id = partition.GetCell(level, node); bool is_source_node = false; bool is_destination_node = false; bool is_boundary_node = false; @@ -324,7 +324,7 @@ template class CellStorageImpl { } - ConstCell GetCell(partition::LevelID level, partition::CellID id) const + ConstCell GetCell(LevelID level, CellID id) const { const auto level_index = LevelIDToIndex(level); BOOST_ASSERT(level_index < level_to_cell_offset.size()); @@ -335,8 +335,7 @@ template class CellStorageImpl cells[cell_index], weights.data(), source_boundary.data(), destination_boundary.data()}; } - template > - Cell GetCell(partition::LevelID level, partition::CellID id) + template > Cell GetCell(LevelID level, CellID id) { const auto level_index = LevelIDToIndex(level); BOOST_ASSERT(level_index < level_to_cell_offset.size()); diff --git a/include/partition/io.hpp b/include/partition/io.hpp index 520371b93..1c6ddc484 100644 --- a/include/partition/io.hpp +++ b/include/partition/io.hpp @@ -1,8 +1,8 @@ #ifndef OSRM_PARTITION_IO_HPP #define OSRM_PARTITION_IO_HPP -#include "partition/multi_level_partition.hpp" #include "partition/cell_storage.hpp" +#include "partition/multi_level_partition.hpp" #include "storage/io.hpp" @@ -44,7 +44,6 @@ template <> inline void write(const boost::filesystem::path &path, const CellSto writer.SerializeVector(storage.cells); writer.SerializeVector(storage.level_to_cell_offset); } - } } } diff --git a/include/partition/multi_level_partition.hpp b/include/partition/multi_level_partition.hpp index 188fbbef9..47bb32b4c 100644 --- a/include/partition/multi_level_partition.hpp +++ b/include/partition/multi_level_partition.hpp @@ -40,12 +40,6 @@ void write(const boost::filesystem::path &file, const detail::MultiLevelPartitionImpl &mlp); } -using LevelID = std::uint8_t; -using CellID = std::uint32_t; -using PartitionID = std::uint64_t; - -static constexpr CellID INVALID_CELL_ID = std::numeric_limits::max(); - namespace detail { diff --git a/include/util/typedefs.hpp b/include/util/typedefs.hpp index d27716040..815ca170d 100644 --- a/include/util/typedefs.hpp +++ b/include/util/typedefs.hpp @@ -61,7 +61,6 @@ using EdgeWeight = std::int32_t; using TurnPenalty = std::int16_t; // turn penalty in 100ms units static const std::size_t INVALID_INDEX = std::numeric_limits::max(); -using BisectionID = std::uint32_t; using LaneID = std::uint8_t; static const LaneID INVALID_LANEID = std::numeric_limits::max(); @@ -99,6 +98,14 @@ static const EdgeWeight MAXIMAL_EDGE_DURATION_INT_30 = (1 << 29) - 1; using DatasourceID = std::uint8_t; +using BisectionID = std::uint32_t; +using LevelID = std::uint8_t; +using CellID = std::uint32_t; +using PartitionID = std::uint64_t; + +static constexpr auto INVALID_LEVEL_ID = std::numeric_limits::max(); +static constexpr auto INVALID_CELL_ID = std::numeric_limits::max(); + struct SegmentID { SegmentID(const NodeID id_, const bool enabled_) : id{id_}, enabled{enabled_} diff --git a/src/customize/customizer.cpp b/src/customize/customizer.cpp index aec507578..32a550f50 100644 --- a/src/customize/customizer.cpp +++ b/src/customize/customizer.cpp @@ -23,7 +23,7 @@ void CellStorageStatistics(const Graph &graph, for (std::size_t level = 1; level < partition.GetNumberOfLevels(); ++level) { - std::unordered_map cell_nodes; + std::unordered_map cell_nodes; for (auto node : util::irange(0u, graph.GetNumberOfNodes())) { ++cell_nodes[partition.GetCell(level, node)]; @@ -55,14 +55,14 @@ void CellStorageStatistics(const Graph &graph, } util::Log() << "Level " << level << " #cells " << cell_nodes.size() << " #nodes " << total - << ", source nodes: average " << source - << " (" << (100. * source / total) << "%)" - << " invalid " << invalid_sources - << " (" << (100. * invalid_sources / total) << "%)" - << ", destination nodes: average " << destination - << " (" << (100. * destination / total) << "%)" - << " invalid " << invalid_destinations - << " (" << (100. * invalid_destinations / total) << "%)"; + << ", source nodes: average " << source << " (" << (100. * source / total) + << "%)" + << " invalid " << invalid_sources << " (" << (100. * invalid_sources / total) + << "%)" + << ", destination nodes: average " << destination << " (" + << (100. * destination / total) << "%)" + << " invalid " << invalid_destinations << " (" + << (100. * invalid_destinations / total) << "%)"; } } diff --git a/src/partition/partitioner.cpp b/src/partition/partitioner.cpp index 671d3a068..23db81b09 100644 --- a/src/partition/partitioner.cpp +++ b/src/partition/partitioner.cpp @@ -1,6 +1,7 @@ #include "partition/partitioner.hpp" #include "partition/bisection_graph.hpp" #include "partition/bisection_to_partition.hpp" +#include "partition/cell_storage.hpp" #include "partition/compressed_node_based_graph_reader.hpp" #include "partition/edge_based_graph_reader.hpp" #include "partition/io.hpp" @@ -17,7 +18,6 @@ #include #include -#include #include #include diff --git a/src/storage/storage.cpp b/src/storage/storage.cpp index 436e8b5b0..0b0980967 100644 --- a/src/storage/storage.cpp +++ b/src/storage/storage.cpp @@ -427,19 +427,17 @@ void Storage::PopulateLayout(DataLayout &layout) reader.Skip(1); layout.SetBlockSize( DataLayout::MLD_LEVEL_DATA, 1); - const auto partition_entries_count = reader.ReadVectorSize(); - layout.SetBlockSize(DataLayout::MLD_PARTITION, - partition_entries_count); - const auto children_entries_count = reader.ReadVectorSize(); - layout.SetBlockSize(DataLayout::MLD_CELL_TO_CHILDREN, - children_entries_count); + const auto partition_entries_count = reader.ReadVectorSize(); + layout.SetBlockSize(DataLayout::MLD_PARTITION, partition_entries_count); + const auto children_entries_count = reader.ReadVectorSize(); + layout.SetBlockSize(DataLayout::MLD_CELL_TO_CHILDREN, children_entries_count); } else { layout.SetBlockSize( DataLayout::MLD_LEVEL_DATA, 0); - layout.SetBlockSize(DataLayout::MLD_PARTITION, 0); - layout.SetBlockSize(DataLayout::MLD_CELL_TO_CHILDREN, 0); + layout.SetBlockSize(DataLayout::MLD_PARTITION, 0); + layout.SetBlockSize(DataLayout::MLD_CELL_TO_CHILDREN, 0); } if (boost::filesystem::exists(config.mld_storage_path)) @@ -964,10 +962,10 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr) auto mld_level_data_ptr = layout.GetBlockPtr( memory_ptr, DataLayout::MLD_LEVEL_DATA); - auto mld_partition_ptr = layout.GetBlockPtr( - memory_ptr, DataLayout::MLD_PARTITION); - auto mld_chilren_ptr = layout.GetBlockPtr( - memory_ptr, DataLayout::MLD_CELL_TO_CHILDREN); + auto mld_partition_ptr = + layout.GetBlockPtr(memory_ptr, DataLayout::MLD_PARTITION); + auto mld_chilren_ptr = + layout.GetBlockPtr(memory_ptr, DataLayout::MLD_CELL_TO_CHILDREN); io::FileReader reader(config.mld_partition_path, io::FileReader::VerifyFingerprint);