Renaming of MemorySetting > Ownership
This commit is contained in:
committed by
Patrick Niklaus
parent
d6e56c38d5
commit
16665aeb00
@@ -27,24 +27,24 @@ namespace partition
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <osrm::storage::MemorySetting MemorySetting> class CellStorageImpl;
|
||||
template <osrm::storage::Ownership Ownership> class CellStorageImpl;
|
||||
}
|
||||
using CellStorage = detail::CellStorageImpl<osrm::storage::MemorySetting::InternalMemory>;
|
||||
using CellStorageView = detail::CellStorageImpl<osrm::storage::MemorySetting::SharedMemory>;
|
||||
using CellStorage = detail::CellStorageImpl<osrm::storage::Ownership::Container>;
|
||||
using CellStorageView = detail::CellStorageImpl<osrm::storage::Ownership::View>;
|
||||
|
||||
namespace io
|
||||
{
|
||||
template <osrm::storage::MemorySetting MemorySetting>
|
||||
template <osrm::storage::Ownership Ownership>
|
||||
inline void read(const boost::filesystem::path &path,
|
||||
detail::CellStorageImpl<MemorySetting> &storage);
|
||||
template <osrm::storage::MemorySetting MemorySetting>
|
||||
detail::CellStorageImpl<Ownership> &storage);
|
||||
template <osrm::storage::Ownership Ownership>
|
||||
inline void write(const boost::filesystem::path &path,
|
||||
const detail::CellStorageImpl<MemorySetting> &storage);
|
||||
const detail::CellStorageImpl<Ownership> &storage);
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <osrm::storage::MemorySetting MemorySetting> class CellStorageImpl
|
||||
template <osrm::storage::Ownership Ownership> class CellStorageImpl
|
||||
{
|
||||
public:
|
||||
using WeightOffset = std::uint32_t;
|
||||
@@ -66,7 +66,7 @@ template <osrm::storage::MemorySetting MemorySetting> class CellStorageImpl
|
||||
};
|
||||
|
||||
private:
|
||||
template <typename T> using Vector = typename util::ShM<T, MemorySetting>::vector;
|
||||
template <typename T> using Vector = typename util::ShM<T, Ownership>::vector;
|
||||
|
||||
// Implementation of the cell view. We need a template parameter here
|
||||
// because we need to derive a read-only and read-write view from this.
|
||||
@@ -188,7 +188,7 @@ template <osrm::storage::MemorySetting MemorySetting> class CellStorageImpl
|
||||
|
||||
template <
|
||||
typename GraphT,
|
||||
typename = std::enable_if<MemorySetting == osrm::storage::MemorySetting::InternalMemory>>
|
||||
typename = std::enable_if<Ownership == osrm::storage::Ownership::Container>>
|
||||
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
|
||||
@@ -318,7 +318,7 @@ template <osrm::storage::MemorySetting MemorySetting> class CellStorageImpl
|
||||
}
|
||||
|
||||
template <
|
||||
typename = std::enable_if<MemorySetting == osrm::storage::MemorySetting::SharedMemory>>
|
||||
typename = std::enable_if<Ownership == osrm::storage::Ownership::View>>
|
||||
CellStorageImpl(Vector<EdgeWeight> weights_,
|
||||
Vector<NodeID> source_boundary_,
|
||||
Vector<NodeID> destination_boundary_,
|
||||
@@ -344,7 +344,7 @@ template <osrm::storage::MemorySetting MemorySetting> class CellStorageImpl
|
||||
}
|
||||
|
||||
template <
|
||||
typename = std::enable_if<MemorySetting == osrm::storage::MemorySetting::InternalMemory>>
|
||||
typename = std::enable_if<Ownership == osrm::storage::Ownership::Container>>
|
||||
Cell GetCell(LevelID level, CellID id)
|
||||
{
|
||||
const auto level_index = LevelIDToIndex(level);
|
||||
@@ -356,10 +356,10 @@ template <osrm::storage::MemorySetting MemorySetting> class CellStorageImpl
|
||||
cells[cell_index], weights.data(), source_boundary.data(), destination_boundary.data()};
|
||||
}
|
||||
|
||||
friend void io::read<MemorySetting>(const boost::filesystem::path &path,
|
||||
detail::CellStorageImpl<MemorySetting> &storage);
|
||||
friend void io::write<MemorySetting>(const boost::filesystem::path &path,
|
||||
const detail::CellStorageImpl<MemorySetting> &storage);
|
||||
friend void io::read<Ownership>(const boost::filesystem::path &path,
|
||||
detail::CellStorageImpl<Ownership> &storage);
|
||||
friend void io::write<Ownership>(const boost::filesystem::path &path,
|
||||
const detail::CellStorageImpl<Ownership> &storage);
|
||||
|
||||
private:
|
||||
Vector<EdgeWeight> weights;
|
||||
|
||||
@@ -16,9 +16,9 @@ namespace partition
|
||||
namespace io
|
||||
{
|
||||
|
||||
template <typename EdgeDataT, osrm::storage::MemorySetting MemorySetting>
|
||||
template <typename EdgeDataT, osrm::storage::Ownership Ownership>
|
||||
inline void read(const boost::filesystem::path &path,
|
||||
MultiLevelGraph<EdgeDataT, MemorySetting> &graph)
|
||||
MultiLevelGraph<EdgeDataT, Ownership> &graph)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
@@ -28,9 +28,9 @@ inline void read(const boost::filesystem::path &path,
|
||||
reader.DeserializeVector(graph.edge_to_level);
|
||||
}
|
||||
|
||||
template <typename EdgeDataT, osrm::storage::MemorySetting MemorySetting>
|
||||
template <typename EdgeDataT, osrm::storage::Ownership Ownership>
|
||||
inline void write(const boost::filesystem::path &path,
|
||||
const MultiLevelGraph<EdgeDataT, MemorySetting> &graph)
|
||||
const MultiLevelGraph<EdgeDataT, Ownership> &graph)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
@@ -16,24 +16,24 @@ namespace osrm
|
||||
{
|
||||
namespace partition
|
||||
{
|
||||
template <typename EdgeDataT, osrm::storage::MemorySetting MemorySetting> class MultiLevelGraph;
|
||||
template <typename EdgeDataT, osrm::storage::Ownership Ownership> class MultiLevelGraph;
|
||||
|
||||
namespace io
|
||||
{
|
||||
template <typename EdgeDataT, osrm::storage::MemorySetting MemorySetting>
|
||||
void read(const boost::filesystem::path &path, MultiLevelGraph<EdgeDataT, MemorySetting> &graph);
|
||||
template <typename EdgeDataT, osrm::storage::Ownership Ownership>
|
||||
void read(const boost::filesystem::path &path, MultiLevelGraph<EdgeDataT, Ownership> &graph);
|
||||
|
||||
template <typename EdgeDataT, osrm::storage::MemorySetting MemorySetting>
|
||||
template <typename EdgeDataT, osrm::storage::Ownership Ownership>
|
||||
void write(const boost::filesystem::path &path,
|
||||
const MultiLevelGraph<EdgeDataT, MemorySetting> &graph);
|
||||
const MultiLevelGraph<EdgeDataT, Ownership> &graph);
|
||||
}
|
||||
|
||||
template <typename EdgeDataT, osrm::storage::MemorySetting MemorySetting>
|
||||
class MultiLevelGraph : public util::StaticGraph<EdgeDataT, MemorySetting>
|
||||
template <typename EdgeDataT, osrm::storage::Ownership Ownership>
|
||||
class MultiLevelGraph : public util::StaticGraph<EdgeDataT, Ownership>
|
||||
{
|
||||
private:
|
||||
using SuperT = util::StaticGraph<EdgeDataT, MemorySetting>;
|
||||
template <typename T> using Vector = typename util::ShM<T, MemorySetting>::vector;
|
||||
using SuperT = util::StaticGraph<EdgeDataT, Ownership>;
|
||||
template <typename T> using Vector = typename util::ShM<T, Ownership>::vector;
|
||||
|
||||
public:
|
||||
// We limit each node to have 255 edges
|
||||
@@ -192,11 +192,11 @@ class MultiLevelGraph : public util::StaticGraph<EdgeDataT, MemorySetting>
|
||||
}
|
||||
|
||||
friend void
|
||||
io::read<EdgeDataT, MemorySetting>(const boost::filesystem::path &path,
|
||||
MultiLevelGraph<EdgeDataT, MemorySetting> &graph);
|
||||
io::read<EdgeDataT, Ownership>(const boost::filesystem::path &path,
|
||||
MultiLevelGraph<EdgeDataT, Ownership> &graph);
|
||||
friend void
|
||||
io::write<EdgeDataT, MemorySetting>(const boost::filesystem::path &path,
|
||||
const MultiLevelGraph<EdgeDataT, MemorySetting> &graph);
|
||||
io::write<EdgeDataT, Ownership>(const boost::filesystem::path &path,
|
||||
const MultiLevelGraph<EdgeDataT, Ownership> &graph);
|
||||
|
||||
Vector<EdgeOffset> node_to_edge_offset;
|
||||
};
|
||||
|
||||
@@ -26,32 +26,32 @@ namespace partition
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <osrm::storage::MemorySetting MemorySetting> class MultiLevelPartitionImpl;
|
||||
template <osrm::storage::Ownership Ownership> class MultiLevelPartitionImpl;
|
||||
}
|
||||
using MultiLevelPartition =
|
||||
detail::MultiLevelPartitionImpl<osrm::storage::MemorySetting::InternalMemory>;
|
||||
detail::MultiLevelPartitionImpl<osrm::storage::Ownership::Container>;
|
||||
using MultiLevelPartitionView =
|
||||
detail::MultiLevelPartitionImpl<osrm::storage::MemorySetting::SharedMemory>;
|
||||
detail::MultiLevelPartitionImpl<osrm::storage::Ownership::View>;
|
||||
|
||||
namespace io
|
||||
{
|
||||
template <osrm::storage::MemorySetting MemorySetting>
|
||||
void read(const boost::filesystem::path &file, detail::MultiLevelPartitionImpl<MemorySetting> &mlp);
|
||||
template <osrm::storage::MemorySetting MemorySetting>
|
||||
template <osrm::storage::Ownership Ownership>
|
||||
void read(const boost::filesystem::path &file, detail::MultiLevelPartitionImpl<Ownership> &mlp);
|
||||
template <osrm::storage::Ownership Ownership>
|
||||
void write(const boost::filesystem::path &file,
|
||||
const detail::MultiLevelPartitionImpl<MemorySetting> &mlp);
|
||||
const detail::MultiLevelPartitionImpl<Ownership> &mlp);
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <osrm::storage::MemorySetting MemorySetting> class MultiLevelPartitionImpl final
|
||||
template <osrm::storage::Ownership Ownership> class MultiLevelPartitionImpl final
|
||||
{
|
||||
// we will support at most 16 levels
|
||||
static const constexpr std::uint8_t MAX_NUM_LEVEL = 16;
|
||||
static const constexpr std::uint8_t NUM_PARTITION_BITS = sizeof(PartitionID) * CHAR_BIT;
|
||||
|
||||
template <typename T> using Vector = typename util::ShM<T, MemorySetting>::vector;
|
||||
template <typename T> using Vector = typename util::ShM<T, Ownership>::vector;
|
||||
|
||||
public:
|
||||
// Contains all data necessary to describe the level hierarchy
|
||||
@@ -70,8 +70,8 @@ template <osrm::storage::MemorySetting MemorySetting> class MultiLevelPartitionI
|
||||
// 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
|
||||
// basegraph.
|
||||
template <typename = typename std::enable_if<MemorySetting ==
|
||||
osrm::storage::MemorySetting::InternalMemory>>
|
||||
template <typename = typename std::enable_if<Ownership ==
|
||||
osrm::storage::Ownership::Container>>
|
||||
MultiLevelPartitionImpl(const std::vector<std::vector<CellID>> &partitions,
|
||||
const std::vector<std::uint32_t> &lidx_to_num_cells)
|
||||
: level_data(MakeLevelData(lidx_to_num_cells))
|
||||
@@ -79,8 +79,8 @@ template <osrm::storage::MemorySetting MemorySetting> class MultiLevelPartitionI
|
||||
InitializePartitionIDs(partitions);
|
||||
}
|
||||
|
||||
template <typename = typename std::enable_if<MemorySetting ==
|
||||
osrm::storage::MemorySetting::SharedMemory>>
|
||||
template <typename = typename std::enable_if<Ownership ==
|
||||
osrm::storage::Ownership::View>>
|
||||
MultiLevelPartitionImpl(LevelData level_data,
|
||||
Vector<PartitionID> partition_,
|
||||
Vector<CellID> cell_to_children_)
|
||||
@@ -138,9 +138,9 @@ template <osrm::storage::MemorySetting MemorySetting> class MultiLevelPartitionI
|
||||
return cell_to_children[offset + cell + 1];
|
||||
}
|
||||
|
||||
friend void io::read<MemorySetting>(const boost::filesystem::path &file,
|
||||
friend void io::read<Ownership>(const boost::filesystem::path &file,
|
||||
MultiLevelPartitionImpl &mlp);
|
||||
friend void io::write<MemorySetting>(const boost::filesystem::path &file,
|
||||
friend void io::write<Ownership>(const boost::filesystem::path &file,
|
||||
const MultiLevelPartitionImpl &mlp);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user