Don't leak ownership in partition/files
This commit is contained in:
parent
446c865415
commit
2da5da3f16
@ -1,6 +1,8 @@
|
|||||||
#ifndef OSRM_PARTITION_SERILIZATION_HPP
|
#ifndef OSRM_PARTITION_SERILIZATION_HPP
|
||||||
#define OSRM_PARTITION_SERILIZATION_HPP
|
#define OSRM_PARTITION_SERILIZATION_HPP
|
||||||
|
|
||||||
|
#include "customizer/edge_based_graph.hpp"
|
||||||
|
|
||||||
#include "partition/serialization.hpp"
|
#include "partition/serialization.hpp"
|
||||||
|
|
||||||
#include "storage/io.hpp"
|
#include "storage/io.hpp"
|
||||||
@ -13,10 +15,13 @@ namespace files
|
|||||||
{
|
{
|
||||||
|
|
||||||
// reads .osrm.mldgr file
|
// reads .osrm.mldgr file
|
||||||
template <typename EdgeDataT, storage::Ownership Ownership>
|
template <typename MultiLevelGraphT>
|
||||||
inline void readGraph(const boost::filesystem::path &path,
|
inline void readGraph(const boost::filesystem::path &path, MultiLevelGraphT &graph)
|
||||||
MultiLevelGraph<EdgeDataT, Ownership> &graph)
|
|
||||||
{
|
{
|
||||||
|
static_assert(std::is_same<customizer::MultiLevelEdgeBasedGraphView, MultiLevelGraphT>::value ||
|
||||||
|
std::is_same<customizer::MultiLevelEdgeBasedGraph, MultiLevelGraphT>::value,
|
||||||
|
"");
|
||||||
|
|
||||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||||
storage::io::FileReader reader{path, fingerprint};
|
storage::io::FileReader reader{path, fingerprint};
|
||||||
|
|
||||||
@ -24,10 +29,13 @@ inline void readGraph(const boost::filesystem::path &path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// writes .osrm.mldgr file
|
// writes .osrm.mldgr file
|
||||||
template <typename EdgeDataT, storage::Ownership Ownership>
|
template <typename MultiLevelGraphT>
|
||||||
inline void writeGraph(const boost::filesystem::path &path,
|
inline void writeGraph(const boost::filesystem::path &path, const MultiLevelGraphT &graph)
|
||||||
const MultiLevelGraph<EdgeDataT, Ownership> &graph)
|
|
||||||
{
|
{
|
||||||
|
static_assert(std::is_same<customizer::MultiLevelEdgeBasedGraphView, MultiLevelGraphT>::value ||
|
||||||
|
std::is_same<customizer::MultiLevelEdgeBasedGraph, MultiLevelGraphT>::value,
|
||||||
|
"");
|
||||||
|
|
||||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||||
storage::io::FileWriter writer{path, fingerprint};
|
storage::io::FileWriter writer{path, fingerprint};
|
||||||
|
|
||||||
@ -35,10 +43,13 @@ inline void writeGraph(const boost::filesystem::path &path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// read .osrm.partition file
|
// read .osrm.partition file
|
||||||
template <storage::Ownership Ownership>
|
template <typename MultiLevelPartitionT>
|
||||||
inline void readPartition(const boost::filesystem::path &path,
|
inline void readPartition(const boost::filesystem::path &path, MultiLevelPartitionT &mlp)
|
||||||
detail::MultiLevelPartitionImpl<Ownership> &mlp)
|
|
||||||
{
|
{
|
||||||
|
static_assert(std::is_same<MultiLevelPartitionView, MultiLevelPartitionT>::value ||
|
||||||
|
std::is_same<MultiLevelPartition, MultiLevelPartitionT>::value,
|
||||||
|
"");
|
||||||
|
|
||||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||||
storage::io::FileReader reader{path, fingerprint};
|
storage::io::FileReader reader{path, fingerprint};
|
||||||
|
|
||||||
@ -46,10 +57,13 @@ inline void readPartition(const boost::filesystem::path &path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// writes .osrm.partition file
|
// writes .osrm.partition file
|
||||||
template <storage::Ownership Ownership>
|
template <typename MultiLevelPartitionT>
|
||||||
inline void writePartition(const boost::filesystem::path &path,
|
inline void writePartition(const boost::filesystem::path &path, const MultiLevelPartitionT &mlp)
|
||||||
const detail::MultiLevelPartitionImpl<Ownership> &mlp)
|
|
||||||
{
|
{
|
||||||
|
static_assert(std::is_same<MultiLevelPartitionView, MultiLevelPartitionT>::value ||
|
||||||
|
std::is_same<MultiLevelPartition, MultiLevelPartitionT>::value,
|
||||||
|
"");
|
||||||
|
|
||||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||||
storage::io::FileWriter writer{path, fingerprint};
|
storage::io::FileWriter writer{path, fingerprint};
|
||||||
|
|
||||||
@ -57,10 +71,13 @@ inline void writePartition(const boost::filesystem::path &path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reads .osrm.cells file
|
// reads .osrm.cells file
|
||||||
template <storage::Ownership Ownership>
|
template <typename CellStorageT>
|
||||||
inline void readCells(const boost::filesystem::path &path,
|
inline void readCells(const boost::filesystem::path &path, CellStorageT &storage)
|
||||||
detail::CellStorageImpl<Ownership> &storage)
|
|
||||||
{
|
{
|
||||||
|
static_assert(std::is_same<CellStorageView, CellStorageT>::value ||
|
||||||
|
std::is_same<CellStorage, CellStorageT>::value,
|
||||||
|
"");
|
||||||
|
|
||||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||||
storage::io::FileReader reader{path, fingerprint};
|
storage::io::FileReader reader{path, fingerprint};
|
||||||
|
|
||||||
@ -68,10 +85,13 @@ inline void readCells(const boost::filesystem::path &path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// writes .osrm.cells file
|
// writes .osrm.cells file
|
||||||
template <storage::Ownership Ownership>
|
template <typename CellStorageT>
|
||||||
inline void writeCells(const boost::filesystem::path &path,
|
inline void writeCells(const boost::filesystem::path &path, CellStorageT &storage)
|
||||||
const detail::CellStorageImpl<Ownership> &storage)
|
|
||||||
{
|
{
|
||||||
|
static_assert(std::is_same<CellStorageView, CellStorageT>::value ||
|
||||||
|
std::is_same<CellStorage, CellStorageT>::value,
|
||||||
|
"");
|
||||||
|
|
||||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||||
storage::io::FileWriter writer{path, fingerprint};
|
storage::io::FileWriter writer{path, fingerprint};
|
||||||
|
|
||||||
|
@ -83,9 +83,8 @@ auto LoadAndUpdateEdgeExpandedGraph(const CustomizationConfig &config,
|
|||||||
auto directed = partition::splitBidirectionalEdges(edge_based_edge_list);
|
auto directed = partition::splitBidirectionalEdges(edge_based_edge_list);
|
||||||
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 =
|
||||||
partition::MultiLevelGraph<EdgeBasedGraphEdgeData, storage::Ownership::Container>>(
|
std::make_unique <customizer::MultiLevelEdgeBasedGraph>(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: "
|
||||||
<< edge_based_graph->GetNumberOfEdges() << " edges, "
|
<< edge_based_graph->GetNumberOfEdges() << " edges, "
|
||||||
|
Loading…
Reference in New Issue
Block a user