Moved MultiLevelPartition and CellStorage to partition namespace

This commit is contained in:
Patrick Niklaus
2017-03-04 18:54:06 +00:00
committed by Patrick Niklaus
parent 694bf9d8b1
commit 00d01946cd
9 changed files with 105 additions and 101 deletions
@@ -3,9 +3,11 @@
#include "contractor/query_edge.hpp"
#include "engine/algorithm.hpp"
#include "util/cell_storage.hpp"
#include "partition/multi_level_partition.hpp"
#include "partition/cell_storage.hpp"
#include "util/integer_range.hpp"
#include "util/multi_level_partition.hpp"
namespace osrm
{
@@ -64,9 +66,9 @@ template <> class AlgorithmDataFacade<algorithm::CoreCH>
template <> class AlgorithmDataFacade<algorithm::MLD>
{
public:
virtual const util::MultiLevelPartitionView &GetMultiLevelPartition() const = 0;
virtual const partition::MultiLevelPartitionView &GetMultiLevelPartition() const = 0;
virtual const util::CellStorageView &GetCellStorage() const = 0;
virtual const partition::CellStorageView &GetCellStorage() const = 0;
};
}
}
@@ -5,23 +5,26 @@
#include "engine/datafacade/contiguous_block_allocator.hpp"
#include "engine/datafacade/datafacade_base.hpp"
#include "engine/algorithm.hpp"
#include "engine/geospatial_query.hpp"
#include "extractor/compressed_edge_container.hpp"
#include "extractor/guidance/turn_instruction.hpp"
#include "extractor/guidance/turn_lane_types.hpp"
#include "extractor/profile_properties.hpp"
#include "storage/shared_datatype.hpp"
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
#include "util/guidance/turn_lanes.hpp"
#include "engine/algorithm.hpp"
#include "engine/geospatial_query.hpp"
#include "util/cell_storage.hpp"
#include "partition/cell_storage.hpp"
#include "partition/multi_level_partition.hpp"
#include "storage/shared_datatype.hpp"
#include "util/exception.hpp"
#include "util/exception_utils.hpp"
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
#include "util/guidance/turn_bearing.hpp"
#include "util/guidance/turn_lanes.hpp"
#include "util/log.hpp"
#include "util/multi_level_partition.hpp"
#include "util/name_table.hpp"
#include "util/packed_vector.hpp"
#include "util/range_table.hpp"
@@ -1088,8 +1091,8 @@ class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD>
: public datafacade::AlgorithmDataFacade<algorithm::MLD>
{
// MLD data
util::MultiLevelPartitionView mld_partition;
util::CellStorageView mld_cell_storage;
partition::MultiLevelPartitionView mld_partition;
partition::CellStorageView mld_cell_storage;
void InitializeInternalPointers(storage::DataLayout &data_layout, char *memory_block)
{
@@ -1103,24 +1106,26 @@ class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD>
BOOST_ASSERT(data_layout.GetBlockSize(storage::DataLayout::MLD_LEVEL_DATA) > 0);
BOOST_ASSERT(data_layout.GetBlockSize(storage::DataLayout::MLD_CELL_TO_CHILDREN) > 0);
auto level_data = *data_layout.GetBlockPtr<util::MultiLevelPartitionView::LevelData>(
memory_block, storage::DataLayout::MLD_PARTITION);
auto level_data =
*data_layout.GetBlockPtr<partition::MultiLevelPartitionView::LevelData>(
memory_block, storage::DataLayout::MLD_PARTITION);
auto mld_partition_ptr = data_layout.GetBlockPtr<util::PartitionID>(
auto mld_partition_ptr = data_layout.GetBlockPtr<partition::PartitionID>(
memory_block, storage::DataLayout::MLD_PARTITION);
auto partition_entries_count =
data_layout.GetBlockEntries(storage::DataLayout::MLD_PARTITION);
util::ShM<util::PartitionID, true>::vector partition(mld_partition_ptr,
partition_entries_count);
util::ShM<partition::PartitionID, true>::vector partition(mld_partition_ptr,
partition_entries_count);
auto mld_chilren_ptr = data_layout.GetBlockPtr<util::CellID>(
auto mld_chilren_ptr = data_layout.GetBlockPtr<partition::CellID>(
memory_block, storage::DataLayout::MLD_CELL_TO_CHILDREN);
auto children_entries_count =
data_layout.GetBlockEntries(storage::DataLayout::MLD_CELL_TO_CHILDREN);
util::ShM<util::CellID, true>::vector cell_to_children(mld_chilren_ptr,
children_entries_count);
util::ShM<partition::CellID, true>::vector cell_to_children(mld_chilren_ptr,
children_entries_count);
mld_partition = util::MultiLevelPartitionView{level_data, partition, cell_to_children};
mld_partition =
partition::MultiLevelPartitionView{level_data, partition, cell_to_children};
}
if (data_layout.GetBlockSize(storage::DataLayout::MLD_CELL_WEIGHTS) > 0)
@@ -1138,7 +1143,7 @@ class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD>
memory_block, storage::DataLayout::MLD_CELL_SOURCE_BOUNDARY);
auto mld_destination_boundary_ptr = data_layout.GetBlockPtr<NodeID>(
memory_block, storage::DataLayout::MLD_CELL_DESTINATION_BOUNDARY);
auto mld_cells_ptr = data_layout.GetBlockPtr<util::CellStorageView::CellData>(
auto mld_cells_ptr = data_layout.GetBlockPtr<partition::CellStorageView::CellData>(
memory_block, storage::DataLayout::MLD_CELLS);
auto mld_cell_level_offsets_ptr = data_layout.GetBlockPtr<std::uint64_t>(
memory_block, storage::DataLayout::MLD_CELL_LEVEL_OFFSETS);
@@ -1158,16 +1163,16 @@ class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD>
source_boundary_entries_count);
util::ShM<NodeID, true>::vector destination_boundary(
mld_destination_boundary_ptr, destination_boundary_entries_count);
util::ShM<util::CellStorageView::CellData, true>::vector cells(mld_cells_ptr,
cells_entries_counts);
util::ShM<partition::CellStorageView::CellData, true>::vector cells(
mld_cells_ptr, cells_entries_counts);
util::ShM<std::uint64_t, true>::vector level_offsets(mld_cell_level_offsets_ptr,
cell_level_offsets_entries_count);
mld_cell_storage = util::CellStorageView{std::move(weights),
std::move(source_boundary),
std::move(destination_boundary),
std::move(cells),
std::move(level_offsets)};
mld_cell_storage = partition::CellStorageView{std::move(weights),
std::move(source_boundary),
std::move(destination_boundary),
std::move(cells),
std::move(level_offsets)};
}
}
@@ -1182,9 +1187,12 @@ class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD>
InitializeInternalPointers(allocator->GetLayout(), allocator->GetMemory());
}
const util::MultiLevelPartitionView &GetMultiLevelPartition() const { return mld_partition; }
const partition::MultiLevelPartitionView &GetMultiLevelPartition() const
{
return mld_partition;
}
const util::CellStorageView &GetCellStorage() const { return mld_cell_storage; }
const partition::CellStorageView &GetCellStorage() const { return mld_cell_storage; }
};
template <>
@@ -1,10 +1,11 @@
#ifndef OSRM_UTIL_CELL_STORAGE_HPP
#define OSRM_UTIL_CELL_STORAGE_HPP
#include "partition/multi_level_partition.hpp"
#include "util/assert.hpp"
#include "util/for_each_range.hpp"
#include "util/log.hpp"
#include "util/multi_level_partition.hpp"
#include "util/shared_memory_vector_wrapper.hpp"
#include "util/typedefs.hpp"
@@ -20,23 +21,22 @@
namespace osrm
{
namespace util
namespace partition
{
namespace detail
{
namespace detail {
template <bool UseShareMemory> class CellStorageImpl;
}
using CellStorage = detail::CellStorageImpl<false>;
using CellStorageView = detail::CellStorageImpl<true>;
}
namespace partition {
namespace io {
namespace io
{
template <bool UseShareMemory>
inline void write(const boost::filesystem::path &path, const util::detail::CellStorageImpl<UseShareMemory> &storage);
}
inline void write(const boost::filesystem::path &path,
const detail::CellStorageImpl<UseShareMemory> &storage);
}
namespace util
{
namespace detail
{
template <bool UseShareMemory> class CellStorageImpl
@@ -301,10 +301,10 @@ template <bool UseShareMemory> class CellStorageImpl
template <typename = std::enable_if<UseShareMemory>>
CellStorageImpl(Vector<EdgeWeight> weights_,
Vector<NodeID> source_boundary_,
Vector<NodeID> destination_boundary_,
Vector<CellData> cells_,
Vector<std::uint64_t> level_to_cell_offset_)
Vector<NodeID> source_boundary_,
Vector<NodeID> destination_boundary_,
Vector<CellData> cells_,
Vector<std::uint64_t> level_to_cell_offset_)
: weights(std::move(weights_)), source_boundary(std::move(source_boundary_)),
destination_boundary(std::move(destination_boundary_)), cells(std::move(cells_)),
level_to_cell_offset(std::move(level_to_cell_offset_))
@@ -322,8 +322,7 @@ template <bool UseShareMemory> class CellStorageImpl
cells[cell_index], weights.data(), source_boundary.data(), destination_boundary.data()};
}
template <typename = std::enable_if<!UseShareMemory>>
Cell GetCell(LevelID level, CellID id)
template <typename = std::enable_if<!UseShareMemory>> Cell GetCell(LevelID level, CellID id)
{
const auto level_index = LevelIDToIndex(level);
BOOST_ASSERT(level_index < level_to_cell_offset.size());
@@ -334,7 +333,8 @@ template <bool UseShareMemory> class CellStorageImpl
cells[cell_index], weights.data(), source_boundary.data(), destination_boundary.data()};
}
friend void partition::io::write<UseShareMemory>(const boost::filesystem::path &path, const util::detail::CellStorageImpl<UseShareMemory> &storage);
friend void io::write<UseShareMemory>(const boost::filesystem::path &path,
const detail::CellStorageImpl<UseShareMemory> &storage);
private:
Vector<EdgeWeight> weights;
+5 -4
View File
@@ -1,9 +1,10 @@
#ifndef OSRM_PARTITION_IO_HPP
#define OSRM_PARTITION_IO_HPP
#include "partition/multi_level_partition.hpp"
#include "partition/cell_storage.hpp"
#include "storage/io.hpp"
#include "util/multi_level_partition.hpp"
#include "util/cell_storage.hpp"
namespace osrm
{
@@ -13,7 +14,7 @@ namespace io
{
template <>
inline void write(const boost::filesystem::path &path, const util::MultiLevelPartition &mlp)
inline void write(const boost::filesystem::path &path, const partition::MultiLevelPartition &mlp)
{
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
storage::io::FileWriter writer{path, fingerprint};
@@ -24,7 +25,7 @@ inline void write(const boost::filesystem::path &path, const util::MultiLevelPar
}
template <>
inline void write(const boost::filesystem::path &path, const util::CellStorage &storage)
inline void write(const boost::filesystem::path &path, const partition::CellStorage &storage)
{
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
storage::io::FileWriter writer{path, fingerprint};
@@ -20,8 +20,7 @@
namespace osrm
{
namespace util
namespace partition
{
namespace detail
{
@@ -29,20 +28,14 @@ template <bool UseShareMemory> class MultiLevelPartitionImpl;
}
using MultiLevelPartition = detail::MultiLevelPartitionImpl<false>;
using MultiLevelPartitionView = detail::MultiLevelPartitionImpl<true>;
}
namespace partition
{
namespace io
{
template <bool UseShareMemory>
void write(const boost::filesystem::path &file,
const util::detail::MultiLevelPartitionImpl<UseShareMemory> &mlp);
}
const detail::MultiLevelPartitionImpl<UseShareMemory> &mlp);
}
namespace util
{
namespace detail
{
// get the msb of an integer
@@ -168,8 +161,8 @@ template <bool UseShareMemory> class MultiLevelPartitionImpl final
return cell_to_children[offset + cell + 1];
}
friend void partition::io::write<UseShareMemory>(const boost::filesystem::path &file,
const MultiLevelPartitionImpl &mlp);
friend void io::write<UseShareMemory>(const boost::filesystem::path &file,
const MultiLevelPartitionImpl &mlp);
private:
auto MakeLevelData(const std::vector<std::uint32_t> &lidx_to_num_cells)