Remove osrm namespace indication where possible, wrap out shared_memory_ownership

This commit is contained in:
Pepijn Schoen 2017-04-04 09:52:00 +02:00 committed by Patrick Niklaus
parent 091a495632
commit 789311abd6
19 changed files with 114 additions and 108 deletions

View File

@ -7,7 +7,7 @@
#include "util/static_graph.hpp" #include "util/static_graph.hpp"
#include "util/typedefs.hpp" #include "util/typedefs.hpp"
#include "storage/shared_memory.hpp" #include "storage/shared_memory_ownership.hpp"
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
@ -19,17 +19,16 @@ namespace customizer
using EdgeBasedGraphEdgeData = partition::EdgeBasedGraphEdgeData; using EdgeBasedGraphEdgeData = partition::EdgeBasedGraphEdgeData;
struct MultiLevelEdgeBasedGraph struct MultiLevelEdgeBasedGraph
: public partition::MultiLevelGraph<EdgeBasedGraphEdgeData, osrm::storage::Ownership::Container> : public partition::MultiLevelGraph<EdgeBasedGraphEdgeData, storage::Ownership::Container>
{ {
using Base = using Base = partition::MultiLevelGraph<EdgeBasedGraphEdgeData, storage::Ownership::Container>;
partition::MultiLevelGraph<EdgeBasedGraphEdgeData, osrm::storage::Ownership::Container>;
using Base::Base; using Base::Base;
}; };
struct MultiLevelEdgeBasedGraphView struct MultiLevelEdgeBasedGraphView
: public partition::MultiLevelGraph<EdgeBasedGraphEdgeData, osrm::storage::Ownership::View> : public partition::MultiLevelGraph<EdgeBasedGraphEdgeData, storage::Ownership::View>
{ {
using Base = partition::MultiLevelGraph<EdgeBasedGraphEdgeData, osrm::storage::Ownership::View>; using Base = partition::MultiLevelGraph<EdgeBasedGraphEdgeData, storage::Ownership::View>;
using Base::Base; using Base::Base;
}; };

View File

@ -20,7 +20,7 @@
#include "partition/multi_level_partition.hpp" #include "partition/multi_level_partition.hpp"
#include "storage/shared_datatype.hpp" #include "storage/shared_datatype.hpp"
#include "storage/shared_memory.hpp" #include "storage/shared_memory_ownership.hpp"
#include "util/exception.hpp" #include "util/exception.hpp"
#include "util/exception_utils.hpp" #include "util/exception_utils.hpp"
@ -62,7 +62,7 @@ class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::CH>
: public datafacade::AlgorithmDataFacade<algorithm::CH> : public datafacade::AlgorithmDataFacade<algorithm::CH>
{ {
private: private:
using QueryGraph = util::StaticGraph<EdgeData, osrm::storage::Ownership::View>; using QueryGraph = util::StaticGraph<EdgeData, storage::Ownership::View>;
using GraphNode = QueryGraph::NodeArrayEntry; using GraphNode = QueryGraph::NodeArrayEntry;
using GraphEdge = QueryGraph::EdgeArrayEntry; using GraphEdge = QueryGraph::EdgeArrayEntry;
@ -200,11 +200,10 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
{ {
private: private:
using super = BaseDataFacade; using super = BaseDataFacade;
using IndexBlock = util::RangeTable<16, osrm::storage::Ownership::View>::BlockT; using IndexBlock = util::RangeTable<16, storage::Ownership::View>::BlockT;
using RTreeLeaf = super::RTreeLeaf; using RTreeLeaf = super::RTreeLeaf;
using SharedRTree = util::StaticRTree<RTreeLeaf, using SharedRTree =
util::vector_view<util::Coordinate>, util::StaticRTree<RTreeLeaf, util::vector_view<util::Coordinate>, storage::Ownership::View>;
osrm::storage::Ownership::View>;
using SharedGeospatialQuery = GeospatialQuery<SharedRTree, BaseDataFacade>; using SharedGeospatialQuery = GeospatialQuery<SharedRTree, BaseDataFacade>;
using RTreeNode = SharedRTree::TreeNode; using RTreeNode = SharedRTree::TreeNode;
@ -214,7 +213,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
unsigned m_check_sum; unsigned m_check_sum;
util::vector_view<util::Coordinate> m_coordinate_list; util::vector_view<util::Coordinate> m_coordinate_list;
util::PackedVector<OSMNodeID, osrm::storage::Ownership::View> m_osmnodeid_list; util::PackedVector<OSMNodeID, storage::Ownership::View> m_osmnodeid_list;
util::vector_view<GeometryID> m_via_geometry_list; util::vector_view<GeometryID> m_via_geometry_list;
util::vector_view<NameID> m_name_ID_list; util::vector_view<NameID> m_name_ID_list;
util::vector_view<LaneDataID> m_lane_data_id; util::vector_view<LaneDataID> m_lane_data_id;
@ -251,7 +250,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
util::vector_view<util::guidance::EntryClass> m_entry_class_table; util::vector_view<util::guidance::EntryClass> m_entry_class_table;
// the look-up table for distinct bearing classes. A bearing class lists the available bearings // the look-up table for distinct bearing classes. A bearing class lists the available bearings
// at an intersection // at an intersection
std::shared_ptr<util::RangeTable<16, osrm::storage::Ownership::View>> m_bearing_ranges_table; std::shared_ptr<util::RangeTable<16, storage::Ownership::View>> m_bearing_ranges_table;
util::vector_view<DiscreteBearing> m_bearing_values_table; util::vector_view<DiscreteBearing> m_bearing_values_table;
// allocator that keeps the allocation data // allocator that keeps the allocation data
@ -503,11 +502,8 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
util::vector_view<IndexBlock> bearing_blocks( util::vector_view<IndexBlock> bearing_blocks(
blocks_ptr, data_layout.num_entries[storage::DataLayout::BEARING_BLOCKS]); blocks_ptr, data_layout.num_entries[storage::DataLayout::BEARING_BLOCKS]);
m_bearing_ranges_table = m_bearing_ranges_table = std::make_unique<util::RangeTable<16, storage::Ownership::View>>(
std::make_unique<util::RangeTable<16, osrm::storage::Ownership::View>>( bearing_offsets, bearing_blocks, static_cast<unsigned>(m_bearing_values_table.size()));
bearing_offsets,
bearing_blocks,
static_cast<unsigned>(m_bearing_values_table.size()));
auto entry_class_ptr = data_layout.GetBlockPtr<util::guidance::EntryClass>( auto entry_class_ptr = data_layout.GetBlockPtr<util::guidance::EntryClass>(
memory_block, storage::DataLayout::ENTRY_CLASS); memory_block, storage::DataLayout::ENTRY_CLASS);

View File

@ -4,7 +4,7 @@
#include "util/shared_memory_vector_wrapper.hpp" #include "util/shared_memory_vector_wrapper.hpp"
#include "util/typedefs.hpp" #include "util/typedefs.hpp"
#include "storage/shared_memory.hpp" #include "storage/shared_memory_ownership.hpp"
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include <boost/range/adaptor/reversed.hpp> #include <boost/range/adaptor/reversed.hpp>
@ -24,22 +24,22 @@ class CompressedEdgeContainer;
namespace detail namespace detail
{ {
template <osrm::storage::Ownership Ownership> class SegmentDataContainerImpl; template <storage::Ownership Ownership> class SegmentDataContainerImpl;
} }
namespace io namespace io
{ {
template <osrm::storage::Ownership Ownership> template <storage::Ownership Ownership>
inline void read(const boost::filesystem::path &path, inline void read(const boost::filesystem::path &path,
detail::SegmentDataContainerImpl<Ownership> &segment_data); detail::SegmentDataContainerImpl<Ownership> &segment_data);
template <osrm::storage::Ownership Ownership> template <storage::Ownership Ownership>
inline void write(const boost::filesystem::path &path, inline void write(const boost::filesystem::path &path,
const detail::SegmentDataContainerImpl<Ownership> &segment_data); const detail::SegmentDataContainerImpl<Ownership> &segment_data);
} }
namespace detail namespace detail
{ {
template <osrm::storage::Ownership Ownership> class SegmentDataContainerImpl template <storage::Ownership Ownership> class SegmentDataContainerImpl
{ {
template <typename T> using Vector = typename util::ShM<T, Ownership>::vector; template <typename T> using Vector = typename util::ShM<T, Ownership>::vector;
@ -207,8 +207,8 @@ template <osrm::storage::Ownership Ownership> class SegmentDataContainerImpl
}; };
} }
using SegmentDataView = detail::SegmentDataContainerImpl<osrm::storage::Ownership::View>; using SegmentDataView = detail::SegmentDataContainerImpl<storage::Ownership::View>;
using SegmentDataContainer = detail::SegmentDataContainerImpl<osrm::storage::Ownership::Container>; using SegmentDataContainer = detail::SegmentDataContainerImpl<storage::Ownership::Container>;
} }
} }

View File

@ -10,7 +10,7 @@
#include "util/typedefs.hpp" #include "util/typedefs.hpp"
#include "storage/io.hpp" #include "storage/io.hpp"
#include "storage/shared_memory.hpp" #include "storage/shared_memory_ownership.hpp"
#include <boost/iterator/iterator_facade.hpp> #include <boost/iterator/iterator_facade.hpp>
#include <boost/range/iterator_range.hpp> #include <boost/range/iterator_range.hpp>
@ -27,23 +27,23 @@ namespace partition
{ {
namespace detail namespace detail
{ {
template <osrm::storage::Ownership Ownership> class CellStorageImpl; template <storage::Ownership Ownership> class CellStorageImpl;
} }
using CellStorage = detail::CellStorageImpl<osrm::storage::Ownership::Container>; using CellStorage = detail::CellStorageImpl<storage::Ownership::Container>;
using CellStorageView = detail::CellStorageImpl<osrm::storage::Ownership::View>; using CellStorageView = detail::CellStorageImpl<storage::Ownership::View>;
namespace io namespace io
{ {
template <osrm::storage::Ownership Ownership> template <storage::Ownership Ownership>
inline void read(const boost::filesystem::path &path, detail::CellStorageImpl<Ownership> &storage); inline void read(const boost::filesystem::path &path, detail::CellStorageImpl<Ownership> &storage);
template <osrm::storage::Ownership Ownership> template <storage::Ownership Ownership>
inline void write(const boost::filesystem::path &path, inline void write(const boost::filesystem::path &path,
const detail::CellStorageImpl<Ownership> &storage); const detail::CellStorageImpl<Ownership> &storage);
} }
namespace detail namespace detail
{ {
template <osrm::storage::Ownership Ownership> class CellStorageImpl template <storage::Ownership Ownership> class CellStorageImpl
{ {
public: public:
using WeightOffset = std::uint32_t; using WeightOffset = std::uint32_t;
@ -186,7 +186,7 @@ template <osrm::storage::Ownership Ownership> class CellStorageImpl
CellStorageImpl() {} CellStorageImpl() {}
template <typename GraphT, template <typename GraphT,
typename = std::enable_if<Ownership == osrm::storage::Ownership::Container>> typename = std::enable_if<Ownership == storage::Ownership::Container>>
CellStorageImpl(const partition::MultiLevelPartition &partition, const GraphT &base_graph) CellStorageImpl(const partition::MultiLevelPartition &partition, const GraphT &base_graph)
{ {
// pre-allocate storge for CellData so we can have random access to it by cell id // pre-allocate storge for CellData so we can have random access to it by cell id
@ -315,7 +315,7 @@ template <osrm::storage::Ownership Ownership> class CellStorageImpl
weights.resize(weight_offset + 1, INVALID_EDGE_WEIGHT); weights.resize(weight_offset + 1, INVALID_EDGE_WEIGHT);
} }
template <typename = std::enable_if<Ownership == osrm::storage::Ownership::View>> template <typename = std::enable_if<Ownership == storage::Ownership::View>>
CellStorageImpl(Vector<EdgeWeight> weights_, CellStorageImpl(Vector<EdgeWeight> weights_,
Vector<NodeID> source_boundary_, Vector<NodeID> source_boundary_,
Vector<NodeID> destination_boundary_, Vector<NodeID> destination_boundary_,
@ -340,7 +340,7 @@ template <osrm::storage::Ownership Ownership> class CellStorageImpl
destination_boundary.empty() ? nullptr : destination_boundary.data()}; destination_boundary.empty() ? nullptr : destination_boundary.data()};
} }
template <typename = std::enable_if<Ownership == osrm::storage::Ownership::Container>> template <typename = std::enable_if<Ownership == storage::Ownership::Container>>
Cell GetCell(LevelID level, CellID id) Cell GetCell(LevelID level, CellID id)
{ {
const auto level_index = LevelIDToIndex(level); const auto level_index = LevelIDToIndex(level);

View File

@ -7,7 +7,7 @@
#include "partition/multi_level_partition.hpp" #include "partition/multi_level_partition.hpp"
#include "storage/io.hpp" #include "storage/io.hpp"
#include "storage/shared_memory.hpp" #include "storage/shared_memory_ownership.hpp"
namespace osrm namespace osrm
{ {
@ -16,7 +16,7 @@ namespace partition
namespace io namespace io
{ {
template <typename EdgeDataT, osrm::storage::Ownership Ownership> template <typename EdgeDataT, storage::Ownership Ownership>
inline void read(const boost::filesystem::path &path, MultiLevelGraph<EdgeDataT, Ownership> &graph) inline void read(const boost::filesystem::path &path, MultiLevelGraph<EdgeDataT, Ownership> &graph)
{ {
const auto fingerprint = storage::io::FileReader::VerifyFingerprint; const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
@ -27,7 +27,7 @@ inline void read(const boost::filesystem::path &path, MultiLevelGraph<EdgeDataT,
reader.DeserializeVector(graph.edge_to_level); reader.DeserializeVector(graph.edge_to_level);
} }
template <typename EdgeDataT, osrm::storage::Ownership Ownership> template <typename EdgeDataT, storage::Ownership Ownership>
inline void write(const boost::filesystem::path &path, inline void write(const boost::filesystem::path &path,
const MultiLevelGraph<EdgeDataT, Ownership> &graph) const MultiLevelGraph<EdgeDataT, Ownership> &graph)
{ {

View File

@ -3,7 +3,7 @@
#include "partition/multi_level_partition.hpp" #include "partition/multi_level_partition.hpp"
#include "storage/shared_memory.hpp" #include "storage/shared_memory_ownership.hpp"
#include "util/static_graph.hpp" #include "util/static_graph.hpp"
@ -16,18 +16,18 @@ namespace osrm
{ {
namespace partition namespace partition
{ {
template <typename EdgeDataT, osrm::storage::Ownership Ownership> class MultiLevelGraph; template <typename EdgeDataT, storage::Ownership Ownership> class MultiLevelGraph;
namespace io namespace io
{ {
template <typename EdgeDataT, osrm::storage::Ownership Ownership> template <typename EdgeDataT, storage::Ownership Ownership>
void read(const boost::filesystem::path &path, MultiLevelGraph<EdgeDataT, Ownership> &graph); void read(const boost::filesystem::path &path, MultiLevelGraph<EdgeDataT, Ownership> &graph);
template <typename EdgeDataT, osrm::storage::Ownership Ownership> template <typename EdgeDataT, storage::Ownership Ownership>
void write(const boost::filesystem::path &path, const MultiLevelGraph<EdgeDataT, Ownership> &graph); void write(const boost::filesystem::path &path, const MultiLevelGraph<EdgeDataT, Ownership> &graph);
} }
template <typename EdgeDataT, osrm::storage::Ownership Ownership> template <typename EdgeDataT, storage::Ownership Ownership>
class MultiLevelGraph : public util::StaticGraph<EdgeDataT, Ownership> class MultiLevelGraph : public util::StaticGraph<EdgeDataT, Ownership>
{ {
private: private:

View File

@ -8,7 +8,7 @@
#include "util/typedefs.hpp" #include "util/typedefs.hpp"
#include "storage/io.hpp" #include "storage/io.hpp"
#include "storage/shared_memory.hpp" #include "storage/shared_memory_ownership.hpp"
#include <algorithm> #include <algorithm>
#include <array> #include <array>
@ -26,16 +26,16 @@ namespace partition
{ {
namespace detail namespace detail
{ {
template <osrm::storage::Ownership Ownership> class MultiLevelPartitionImpl; template <storage::Ownership Ownership> class MultiLevelPartitionImpl;
} }
using MultiLevelPartition = detail::MultiLevelPartitionImpl<osrm::storage::Ownership::Container>; using MultiLevelPartition = detail::MultiLevelPartitionImpl<storage::Ownership::Container>;
using MultiLevelPartitionView = detail::MultiLevelPartitionImpl<osrm::storage::Ownership::View>; using MultiLevelPartitionView = detail::MultiLevelPartitionImpl<storage::Ownership::View>;
namespace io namespace io
{ {
template <osrm::storage::Ownership Ownership> template <storage::Ownership Ownership>
void read(const boost::filesystem::path &file, detail::MultiLevelPartitionImpl<Ownership> &mlp); void read(const boost::filesystem::path &file, detail::MultiLevelPartitionImpl<Ownership> &mlp);
template <osrm::storage::Ownership Ownership> template <storage::Ownership Ownership>
void write(const boost::filesystem::path &file, void write(const boost::filesystem::path &file,
const detail::MultiLevelPartitionImpl<Ownership> &mlp); const detail::MultiLevelPartitionImpl<Ownership> &mlp);
} }
@ -43,7 +43,7 @@ void write(const boost::filesystem::path &file,
namespace detail namespace detail
{ {
template <osrm::storage::Ownership Ownership> class MultiLevelPartitionImpl final template <storage::Ownership Ownership> class MultiLevelPartitionImpl final
{ {
// we will support at most 16 levels // we will support at most 16 levels
static const constexpr std::uint8_t MAX_NUM_LEVEL = 16; static const constexpr std::uint8_t MAX_NUM_LEVEL = 16;
@ -68,7 +68,7 @@ template <osrm::storage::Ownership Ownership> class MultiLevelPartitionImpl fina
// cell_sizes is index by level (starting at 0, the base graph). // cell_sizes is index by level (starting at 0, the base graph).
// However level 0 always needs to have cell size 1, since it is the // However level 0 always needs to have cell size 1, since it is the
// basegraph. // basegraph.
template <typename = typename std::enable_if<Ownership == osrm::storage::Ownership::Container>> template <typename = typename std::enable_if<Ownership == storage::Ownership::Container>>
MultiLevelPartitionImpl(const std::vector<std::vector<CellID>> &partitions, MultiLevelPartitionImpl(const std::vector<std::vector<CellID>> &partitions,
const std::vector<std::uint32_t> &lidx_to_num_cells) const std::vector<std::uint32_t> &lidx_to_num_cells)
: level_data(MakeLevelData(lidx_to_num_cells)) : level_data(MakeLevelData(lidx_to_num_cells))
@ -76,7 +76,7 @@ template <osrm::storage::Ownership Ownership> class MultiLevelPartitionImpl fina
InitializePartitionIDs(partitions); InitializePartitionIDs(partitions);
} }
template <typename = typename std::enable_if<Ownership == osrm::storage::Ownership::View>> template <typename = typename std::enable_if<Ownership == storage::Ownership::View>>
MultiLevelPartitionImpl(LevelData level_data, MultiLevelPartitionImpl(LevelData level_data,
Vector<PartitionID> partition_, Vector<PartitionID> partition_,
Vector<CellID> cell_to_children_) Vector<CellID> cell_to_children_)

View File

@ -25,17 +25,13 @@
#include <exception> #include <exception>
#include <thread> #include <thread>
#include "storage/shared_memory_ownership.hpp"
namespace osrm namespace osrm
{ {
namespace storage namespace storage
{ {
enum class Ownership
{
Container,
View
};
struct OSRMLockFile struct OSRMLockFile
{ {
boost::filesystem::path operator()() boost::filesystem::path operator()()

View File

@ -0,0 +1,17 @@
#ifndef SHARED_MEMORY_OWNERSHIP_HPP
#define SHARED_MEMORY_OWNERSHIP_HPP
namespace osrm
{
namespace storage
{
enum class Ownership
{
Container,
View
};
}
}
#endif // SHARED_MEMORY_OWNERSHIP_HPP

View File

@ -4,7 +4,7 @@
#include "util/shared_memory_vector_wrapper.hpp" #include "util/shared_memory_vector_wrapper.hpp"
#include "util/typedefs.hpp" #include "util/typedefs.hpp"
#include "storage/shared_memory.hpp" #include "storage/shared_memory_ownership.hpp"
#include <cmath> #include <cmath>
#include <vector> #include <vector>
@ -22,7 +22,7 @@ namespace util
* NOTE: this type is templated for future use, but will require a slight refactor to * NOTE: this type is templated for future use, but will require a slight refactor to
* configure BITSIZE and ELEMSIZE * configure BITSIZE and ELEMSIZE
*/ */
template <typename T, osrm::storage::Ownership Ownership = osrm::storage::Ownership::Container> template <typename T, storage::Ownership Ownership = storage::Ownership::Container>
class PackedVector class PackedVector
{ {
static const constexpr std::size_t BITSIZE = 33; static const constexpr std::size_t BITSIZE = 33;
@ -123,20 +123,20 @@ class PackedVector
std::size_t size() const { return num_elements; } std::size_t size() const { return num_elements; }
template <bool enabled = (Ownership == osrm::storage::Ownership::View)> template <bool enabled = (Ownership == storage::Ownership::View)>
void reserve(typename std::enable_if<!enabled, std::size_t>::type capacity) void reserve(typename std::enable_if<!enabled, std::size_t>::type capacity)
{ {
vec.reserve(elements_to_blocks(capacity)); vec.reserve(elements_to_blocks(capacity));
} }
template <bool enabled = (Ownership == osrm::storage::Ownership::View)> template <bool enabled = (Ownership == storage::Ownership::View)>
void reset(typename std::enable_if<enabled, std::uint64_t>::type *ptr, void reset(typename std::enable_if<enabled, std::uint64_t>::type *ptr,
typename std::enable_if<enabled, std::size_t>::type size) typename std::enable_if<enabled, std::size_t>::type size)
{ {
vec.reset(ptr, size); vec.reset(ptr, size);
} }
template <bool enabled = (Ownership == osrm::storage::Ownership::View)> template <bool enabled = (Ownership == storage::Ownership::View)>
void set_number_of_entries(typename std::enable_if<enabled, std::size_t>::type count) void set_number_of_entries(typename std::enable_if<enabled, std::size_t>::type count)
{ {
num_elements = count; num_elements = count;
@ -154,38 +154,38 @@ class PackedVector
signed cursor = -1; signed cursor = -1;
template <bool enabled = (Ownership == osrm::storage::Ownership::View)> template <bool enabled = (Ownership == storage::Ownership::View)>
void replace_last_elem(typename std::enable_if<enabled, std::uint64_t>::type last_elem) void replace_last_elem(typename std::enable_if<enabled, std::uint64_t>::type last_elem)
{ {
vec[cursor] = last_elem; vec[cursor] = last_elem;
} }
template <bool enabled = (Ownership == osrm::storage::Ownership::View)> template <bool enabled = (Ownership == storage::Ownership::View)>
void replace_last_elem(typename std::enable_if<!enabled, std::uint64_t>::type last_elem) void replace_last_elem(typename std::enable_if<!enabled, std::uint64_t>::type last_elem)
{ {
vec.back() = last_elem; vec.back() = last_elem;
} }
template <bool enabled = (Ownership == osrm::storage::Ownership::View)> template <bool enabled = (Ownership == storage::Ownership::View)>
void add_last_elem(typename std::enable_if<enabled, std::uint64_t>::type last_elem) void add_last_elem(typename std::enable_if<enabled, std::uint64_t>::type last_elem)
{ {
vec[cursor + 1] = last_elem; vec[cursor + 1] = last_elem;
cursor++; cursor++;
} }
template <bool enabled = (Ownership == osrm::storage::Ownership::View)> template <bool enabled = (Ownership == storage::Ownership::View)>
void add_last_elem(typename std::enable_if<!enabled, std::uint64_t>::type last_elem) void add_last_elem(typename std::enable_if<!enabled, std::uint64_t>::type last_elem)
{ {
vec.push_back(last_elem); vec.push_back(last_elem);
} }
template <bool enabled = (Ownership == osrm::storage::Ownership::View)> template <bool enabled = (Ownership == storage::Ownership::View)>
std::uint64_t vec_back(typename std::enable_if<enabled>::type * = nullptr) std::uint64_t vec_back(typename std::enable_if<enabled>::type * = nullptr)
{ {
return vec[cursor]; return vec[cursor];
} }
template <bool enabled = (Ownership == osrm::storage::Ownership::View)> template <bool enabled = (Ownership == storage::Ownership::View)>
std::uint64_t vec_back(typename std::enable_if<!enabled>::type * = nullptr) std::uint64_t vec_back(typename std::enable_if<!enabled>::type * = nullptr)
{ {
return vec.back(); return vec.back();

View File

@ -2,7 +2,7 @@
#define RANGE_TABLE_HPP #define RANGE_TABLE_HPP
#include "storage/io.hpp" #include "storage/io.hpp"
#include "storage/shared_memory.hpp" #include "storage/shared_memory_ownership.hpp"
#include "util/integer_range.hpp" #include "util/integer_range.hpp"
#include "util/shared_memory_vector_wrapper.hpp" #include "util/shared_memory_vector_wrapper.hpp"
@ -19,14 +19,13 @@ namespace util
* and otherwise the compiler gets confused. * and otherwise the compiler gets confused.
*/ */
template <unsigned BLOCK_SIZE = 16, template <unsigned BLOCK_SIZE = 16, storage::Ownership Ownership = storage::Ownership::Container>
osrm::storage::Ownership Ownership = osrm::storage::Ownership::Container>
class RangeTable; class RangeTable;
template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership> template <unsigned BLOCK_SIZE, storage::Ownership Ownership>
std::ostream &operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, Ownership> &table); std::ostream &operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, Ownership> &table);
template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership> template <unsigned BLOCK_SIZE, storage::Ownership Ownership>
std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, Ownership> &table); std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, Ownership> &table);
/** /**
@ -38,7 +37,7 @@ std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, Ownership> &ta
* But each block consists of an absolute value and BLOCK_SIZE differential values. * But each block consists of an absolute value and BLOCK_SIZE differential values.
* So the effective block size is sizeof(unsigned) + BLOCK_SIZE. * So the effective block size is sizeof(unsigned) + BLOCK_SIZE.
*/ */
template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership> class RangeTable template <unsigned BLOCK_SIZE, storage::Ownership Ownership> class RangeTable
{ {
public: public:
using BlockT = std::array<unsigned char, BLOCK_SIZE>; using BlockT = std::array<unsigned char, BLOCK_SIZE>;
@ -142,7 +141,7 @@ template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership> class RangeTa
sum_lengths = lengths_prefix_sum; sum_lengths = lengths_prefix_sum;
} }
void Write(osrm::storage::io::FileWriter &filewriter) void Write(storage::io::FileWriter &filewriter)
{ {
unsigned number_of_blocks = diff_blocks.size(); unsigned number_of_blocks = diff_blocks.size();
@ -154,7 +153,7 @@ template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership> class RangeTa
filewriter.WriteFrom(diff_blocks.data(), number_of_blocks); filewriter.WriteFrom(diff_blocks.data(), number_of_blocks);
} }
void Read(osrm::storage::io::FileReader &filereader) void Read(storage::io::FileReader &filereader)
{ {
unsigned number_of_blocks = filereader.ReadElementCount32(); unsigned number_of_blocks = filereader.ReadElementCount32();
// read total length // read total length
@ -215,7 +214,7 @@ template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership> class RangeTa
unsigned sum_lengths; unsigned sum_lengths;
}; };
template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership> template <unsigned BLOCK_SIZE, storage::Ownership Ownership>
unsigned RangeTable<BLOCK_SIZE, Ownership>::PrefixSumAtIndex(int index, const BlockT &block) const unsigned RangeTable<BLOCK_SIZE, Ownership>::PrefixSumAtIndex(int index, const BlockT &block) const
{ {
// this loop looks inefficent, but a modern compiler // this loop looks inefficent, but a modern compiler
@ -229,7 +228,7 @@ unsigned RangeTable<BLOCK_SIZE, Ownership>::PrefixSumAtIndex(int index, const Bl
return sum; return sum;
} }
template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership> template <unsigned BLOCK_SIZE, storage::Ownership Ownership>
std::ostream &operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, Ownership> &table) std::ostream &operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, Ownership> &table)
{ {
// write number of block // write number of block
@ -245,7 +244,7 @@ std::ostream &operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, Ownersh
return out; return out;
} }
template <unsigned BLOCK_SIZE, osrm::storage::Ownership Ownership> template <unsigned BLOCK_SIZE, storage::Ownership Ownership>
std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, Ownership> &table) std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, Ownership> &table)
{ {
// read number of block // read number of block

View File

@ -3,7 +3,7 @@
#include "util/log.hpp" #include "util/log.hpp"
#include "storage/shared_memory.hpp" #include "storage/shared_memory_ownership.hpp"
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/iterator/iterator_facade.hpp> #include <boost/iterator/iterator_facade.hpp>
@ -172,9 +172,9 @@ template <typename DataT> void swap(vector_view<DataT> &lhs, vector_view<DataT>
std::swap(lhs.m_size, rhs.m_size); std::swap(lhs.m_size, rhs.m_size);
} }
template <typename DataT, osrm::storage::Ownership Ownership> struct ShM template <typename DataT, storage::Ownership Ownership> struct ShM
{ {
using vector = typename std::conditional<Ownership == osrm::storage::Ownership::View, using vector = typename std::conditional<Ownership == storage::Ownership::View,
vector_view<DataT>, vector_view<DataT>,
std::vector<DataT>>::type; std::vector<DataT>>::type;
}; };

View File

@ -7,7 +7,7 @@
#include "util/shared_memory_vector_wrapper.hpp" #include "util/shared_memory_vector_wrapper.hpp"
#include "util/typedefs.hpp" #include "util/typedefs.hpp"
#include "storage/shared_memory.hpp" #include "storage/shared_memory_ownership.hpp"
#include <boost/assert.hpp> #include <boost/assert.hpp>
@ -99,8 +99,7 @@ EntryT edgeToEntry(const OtherEdge &from, std::false_type)
} // namespace static_graph_details } // namespace static_graph_details
template <typename EdgeDataT, template <typename EdgeDataT, storage::Ownership Ownership = storage::Ownership::Container>
osrm::storage::Ownership Ownership = osrm::storage::Ownership::Container>
class StaticGraph class StaticGraph
{ {
public: public:

View File

@ -15,7 +15,7 @@
#include "osrm/coordinate.hpp" #include "osrm/coordinate.hpp"
#include "storage/shared_memory.hpp" #include "storage/shared_memory_ownership.hpp"
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
@ -54,7 +54,7 @@ namespace util
// are computed, this means the internal distance metric doesn not represent meters! // are computed, this means the internal distance metric doesn not represent meters!
template <class EdgeDataT, template <class EdgeDataT,
class CoordinateListT = std::vector<Coordinate>, class CoordinateListT = std::vector<Coordinate>,
osrm::storage::Ownership Ownership = osrm::storage::Ownership::Container, storage::Ownership Ownership = storage::Ownership::Container,
std::uint32_t BRANCHING_FACTOR = 128, std::uint32_t BRANCHING_FACTOR = 128,
std::uint32_t LEAF_PAGE_SIZE = 4096> std::uint32_t LEAF_PAGE_SIZE = 4096>
class StaticRTree class StaticRTree
@ -159,7 +159,7 @@ class StaticRTree
boost::iostreams::mapped_file_source m_leaves_region; boost::iostreams::mapped_file_source m_leaves_region;
// read-only view of leaves // read-only view of leaves
typename ShM<const LeafNode, osrm::storage::Ownership::View>::vector m_leaves; typename ShM<const LeafNode, storage::Ownership::View>::vector m_leaves;
public: public:
StaticRTree(const StaticRTree &) = delete; StaticRTree(const StaticRTree &) = delete;

View File

@ -29,13 +29,13 @@ constexpr int32_t WORLD_MAX_LON = 180 * COORDINATE_PRECISION;
using RTreeLeaf = extractor::EdgeBasedNode; using RTreeLeaf = extractor::EdgeBasedNode;
using BenchStaticRTree = using BenchStaticRTree =
util::StaticRTree<RTreeLeaf, util::StaticRTree<RTreeLeaf,
util::ShM<util::Coordinate, osrm::storage::Ownership::Container>::vector, util::ShM<util::Coordinate, storage::Ownership::Container>::vector,
osrm::storage::Ownership::Container>; storage::Ownership::Container>;
std::vector<util::Coordinate> loadCoordinates(const boost::filesystem::path &nodes_file) std::vector<util::Coordinate> loadCoordinates(const boost::filesystem::path &nodes_file)
{ {
osrm::storage::io::FileReader nodes_path_file_reader( storage::io::FileReader nodes_path_file_reader(nodes_file,
nodes_file, osrm::storage::io::FileReader::HasNoFingerprint); storage::io::FileReader::HasNoFingerprint);
extractor::QueryNode current_node; extractor::QueryNode current_node;
unsigned coordinate_count = nodes_path_file_reader.ReadElementCount32(); unsigned coordinate_count = nodes_path_file_reader.ReadElementCount32();

View File

@ -8,7 +8,7 @@
#include "partition/io.hpp" #include "partition/io.hpp"
#include "partition/multi_level_partition.hpp" #include "partition/multi_level_partition.hpp"
#include "storage/shared_memory.hpp" #include "storage/shared_memory_ownership.hpp"
#include "updater/updater.hpp" #include "updater/updater.hpp"
@ -85,7 +85,7 @@ auto LoadAndUpdateEdgeExpandedGraph(const CustomizationConfig &config,
auto tidied = auto tidied =
partition::prepareEdgesForUsageInGraph<StaticEdgeBasedGraphEdge>(std::move(directed)); partition::prepareEdgesForUsageInGraph<StaticEdgeBasedGraphEdge>(std::move(directed));
auto edge_based_graph = std::make_unique< auto edge_based_graph = std::make_unique<
partition::MultiLevelGraph<EdgeBasedGraphEdgeData, osrm::storage::Ownership::Container>>( partition::MultiLevelGraph<EdgeBasedGraphEdgeData, storage::Ownership::Container>>(
mlp, num_nodes, std::move(tidied)); mlp, num_nodes, std::move(tidied));
util::Log() << "Loaded edge based graph for mapping partition ids: " util::Log() << "Loaded edge based graph for mapping partition ids: "

View File

@ -16,6 +16,7 @@
#include "storage/serialization.hpp" #include "storage/serialization.hpp"
#include "storage/shared_datatype.hpp" #include "storage/shared_datatype.hpp"
#include "storage/shared_memory.hpp" #include "storage/shared_memory.hpp"
#include "storage/shared_memory_ownership.hpp"
#include "storage/shared_monitor.hpp" #include "storage/shared_monitor.hpp"
#include "engine/datafacade/datafacade_base.hpp" #include "engine/datafacade/datafacade_base.hpp"
#include "util/coordinate.hpp" #include "util/coordinate.hpp"
@ -57,7 +58,7 @@ namespace storage
using RTreeLeaf = engine::datafacade::BaseDataFacade::RTreeLeaf; using RTreeLeaf = engine::datafacade::BaseDataFacade::RTreeLeaf;
using RTreeNode = util::StaticRTree<RTreeLeaf, using RTreeNode = util::StaticRTree<RTreeLeaf,
util::vector_view<util::Coordinate>, util::vector_view<util::Coordinate>,
osrm::storage::Ownership::View>::TreeNode; storage::Ownership::View>::TreeNode;
using QueryGraph = util::StaticGraph<contractor::QueryEdge::EdgeData>; using QueryGraph = util::StaticGraph<contractor::QueryEdge::EdgeData>;
using EdgeBasedGraph = util::StaticGraph<extractor::EdgeBasedEdge::EdgeData>; using EdgeBasedGraph = util::StaticGraph<extractor::EdgeBasedEdge::EdgeData>;
@ -365,14 +366,13 @@ void Storage::PopulateLayout(DataLayout &layout)
intersection_file.Skip<std::uint32_t>(1); // sum_lengths intersection_file.Skip<std::uint32_t>(1); // sum_lengths
layout.SetBlockSize<unsigned>(DataLayout::BEARING_OFFSETS, bearing_blocks); layout.SetBlockSize<unsigned>(DataLayout::BEARING_OFFSETS, bearing_blocks);
layout.SetBlockSize<typename util::RangeTable<16, osrm::storage::Ownership::View>::BlockT>( layout.SetBlockSize<typename util::RangeTable<16, storage::Ownership::View>::BlockT>(
DataLayout::BEARING_BLOCKS, bearing_blocks); DataLayout::BEARING_BLOCKS, bearing_blocks);
// No need to read the data // No need to read the data
intersection_file.Skip<unsigned>(bearing_blocks); intersection_file.Skip<unsigned>(bearing_blocks);
intersection_file intersection_file.Skip<typename util::RangeTable<16, storage::Ownership::View>::BlockT>(
.Skip<typename util::RangeTable<16, osrm::storage::Ownership::View>::BlockT>( bearing_blocks);
bearing_blocks);
const auto num_bearings = intersection_file.ReadElementCount64(); const auto num_bearings = intersection_file.ReadElementCount64();
@ -697,7 +697,7 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
layout.GetBlockPtr<util::Coordinate, true>(memory_ptr, DataLayout::COORDINATE_LIST); layout.GetBlockPtr<util::Coordinate, true>(memory_ptr, DataLayout::COORDINATE_LIST);
const auto osmnodeid_ptr = const auto osmnodeid_ptr =
layout.GetBlockPtr<std::uint64_t, true>(memory_ptr, DataLayout::OSM_NODE_ID_LIST); layout.GetBlockPtr<std::uint64_t, true>(memory_ptr, DataLayout::OSM_NODE_ID_LIST);
util::PackedVector<OSMNodeID, osrm::storage::Ownership::View> osmnodeid_list; util::PackedVector<OSMNodeID, storage::Ownership::View> osmnodeid_list;
osmnodeid_list.reset(osmnodeid_ptr, layout.num_entries[DataLayout::OSM_NODE_ID_LIST]); osmnodeid_list.reset(osmnodeid_ptr, layout.num_entries[DataLayout::OSM_NODE_ID_LIST]);
@ -806,7 +806,7 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
intersection_file.Skip<std::uint32_t>(1); // sum_lengths intersection_file.Skip<std::uint32_t>(1); // sum_lengths
std::vector<unsigned> bearing_offsets_data(bearing_blocks); std::vector<unsigned> bearing_offsets_data(bearing_blocks);
std::vector<typename util::RangeTable<16, osrm::storage::Ownership::View>::BlockT> std::vector<typename util::RangeTable<16, storage::Ownership::View>::BlockT>
bearing_blocks_data(bearing_blocks); bearing_blocks_data(bearing_blocks);
intersection_file.ReadInto(bearing_offsets_data.data(), bearing_blocks); intersection_file.ReadInto(bearing_offsets_data.data(), bearing_blocks);
@ -846,9 +846,9 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
if (layout.GetBlockSize(DataLayout::BEARING_BLOCKS) > 0) if (layout.GetBlockSize(DataLayout::BEARING_BLOCKS) > 0)
{ {
const auto bearing_blocks_ptr = layout.GetBlockPtr< const auto bearing_blocks_ptr =
typename util::RangeTable<16, osrm::storage::Ownership::View>::BlockT, layout.GetBlockPtr<typename util::RangeTable<16, storage::Ownership::View>::BlockT,
true>(memory_ptr, DataLayout::BEARING_BLOCKS); true>(memory_ptr, DataLayout::BEARING_BLOCKS);
BOOST_ASSERT( BOOST_ASSERT(
static_cast<std::size_t>(layout.GetBlockSize(DataLayout::BEARING_BLOCKS)) >= static_cast<std::size_t>(layout.GetBlockSize(DataLayout::BEARING_BLOCKS)) >=
std::distance(bearing_blocks_data.begin(), bearing_blocks_data.end()) * std::distance(bearing_blocks_data.begin(), bearing_blocks_data.end()) *

View File

@ -14,7 +14,7 @@
using namespace osrm; using namespace osrm;
void removeLocks() { osrm::storage::SharedMonitor<osrm::storage::SharedDataTimestamp>::remove(); } void removeLocks() { storage::SharedMonitor<storage::SharedDataTimestamp>::remove(); }
void deleteRegion(const storage::SharedDataType region) void deleteRegion(const storage::SharedDataType region)
{ {

View File

@ -81,7 +81,7 @@ void checkWeightsConsistency(
const UpdaterConfig &config, const UpdaterConfig &config,
const std::vector<osrm::extractor::EdgeBasedEdge> &edge_based_edge_list) const std::vector<osrm::extractor::EdgeBasedEdge> &edge_based_edge_list)
{ {
using Reader = osrm::storage::io::FileReader; using Reader = storage::io::FileReader;
using OriginalEdgeData = osrm::extractor::OriginalEdgeData; using OriginalEdgeData = osrm::extractor::OriginalEdgeData;
extractor::SegmentDataContainer segment_data; extractor::SegmentDataContainer segment_data;