Dont leak ownership in extractor::files
This commit is contained in:
parent
0072bf0c59
commit
446c865415
@ -18,11 +18,14 @@ namespace files
|
||||
{
|
||||
|
||||
// reads .osrm.nodes
|
||||
template <storage::Ownership Ownership>
|
||||
template <typename CoordinatesT, typename PackedOSMIDsT>
|
||||
inline void readNodes(const boost::filesystem::path &path,
|
||||
util::ViewOrVector<util::Coordinate, Ownership> &coordinates,
|
||||
util::detail::PackedVector<OSMNodeID, Ownership> &osm_node_ids)
|
||||
CoordinatesT &coordinates,
|
||||
PackedOSMIDsT &osm_node_ids)
|
||||
{
|
||||
static_assert(std::is_same<typename CoordinatesT::value_type, util::Coordinate>::value, "");
|
||||
static_assert(std::is_same<typename PackedOSMIDsT::value_type, OSMNodeID>::value, "");
|
||||
|
||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
|
||||
@ -31,11 +34,14 @@ inline void readNodes(const boost::filesystem::path &path,
|
||||
}
|
||||
|
||||
// writes .osrm.nodes
|
||||
template <storage::Ownership Ownership>
|
||||
template <typename CoordinatesT, typename PackedOSMIDsT>
|
||||
inline void writeNodes(const boost::filesystem::path &path,
|
||||
const util::ViewOrVector<util::Coordinate, Ownership> &coordinates,
|
||||
const util::detail::PackedVector<OSMNodeID, Ownership> &osm_node_ids)
|
||||
const CoordinatesT &coordinates,
|
||||
const PackedOSMIDsT &osm_node_ids)
|
||||
{
|
||||
static_assert(std::is_same<typename CoordinatesT::value_type, util::Coordinate>::value, "");
|
||||
static_assert(std::is_same<typename PackedOSMIDsT::value_type, OSMNodeID>::value, "");
|
||||
|
||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
@ -81,10 +87,12 @@ inline void writeDatasources(const boost::filesystem::path &path, Datasources &s
|
||||
}
|
||||
|
||||
// reads .osrm.geometry
|
||||
template <storage::Ownership Ownership>
|
||||
inline void readSegmentData(const boost::filesystem::path &path,
|
||||
detail::SegmentDataContainerImpl<Ownership> &segment_data)
|
||||
template <typename SegmentDataT>
|
||||
inline void readSegmentData(const boost::filesystem::path &path, SegmentDataT &segment_data)
|
||||
{
|
||||
static_assert(std::is_same<SegmentDataContainer, SegmentDataT>::value ||
|
||||
std::is_same<SegmentDataView, SegmentDataT>::value,
|
||||
"");
|
||||
const auto fingerprint = storage::io::FileReader::HasNoFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
|
||||
@ -92,10 +100,12 @@ inline void readSegmentData(const boost::filesystem::path &path,
|
||||
}
|
||||
|
||||
// writes .osrm.geometry
|
||||
template <storage::Ownership Ownership>
|
||||
inline void writeSegmentData(const boost::filesystem::path &path,
|
||||
const detail::SegmentDataContainerImpl<Ownership> &segment_data)
|
||||
template <typename SegmentDataT>
|
||||
inline void writeSegmentData(const boost::filesystem::path &path, const SegmentDataT &segment_data)
|
||||
{
|
||||
static_assert(std::is_same<SegmentDataContainer, SegmentDataT>::value ||
|
||||
std::is_same<SegmentDataView, SegmentDataT>::value,
|
||||
"");
|
||||
const auto fingerprint = storage::io::FileWriter::HasNoFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
@ -103,10 +113,12 @@ inline void writeSegmentData(const boost::filesystem::path &path,
|
||||
}
|
||||
|
||||
// reads .osrm.edges
|
||||
template <storage::Ownership Ownership>
|
||||
inline void readTurnData(const boost::filesystem::path &path,
|
||||
detail::TurnDataContainerImpl<Ownership> &turn_data)
|
||||
template <typename TurnDataT>
|
||||
inline void readTurnData(const boost::filesystem::path &path, TurnDataT &turn_data)
|
||||
{
|
||||
static_assert(std::is_same<TurnDataContainer, TurnDataT>::value ||
|
||||
std::is_same<TurnDataView, TurnDataT>::value,
|
||||
"");
|
||||
const auto fingerprint = storage::io::FileReader::HasNoFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
|
||||
@ -114,10 +126,12 @@ inline void readTurnData(const boost::filesystem::path &path,
|
||||
}
|
||||
|
||||
// writes .osrm.edges
|
||||
template <storage::Ownership Ownership>
|
||||
inline void writeTurnData(const boost::filesystem::path &path,
|
||||
const detail::TurnDataContainerImpl<Ownership> &turn_data)
|
||||
template <typename TurnDataT>
|
||||
inline void writeTurnData(const boost::filesystem::path &path, const TurnDataT &turn_data)
|
||||
{
|
||||
static_assert(std::is_same<TurnDataContainer, TurnDataT>::value ||
|
||||
std::is_same<TurnDataView, TurnDataT>::value,
|
||||
"");
|
||||
const auto fingerprint = storage::io::FileWriter::HasNoFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
@ -125,12 +139,16 @@ inline void writeTurnData(const boost::filesystem::path &path,
|
||||
}
|
||||
|
||||
// reads .osrm.tls
|
||||
template <storage::Ownership Ownership>
|
||||
inline void readTurnLaneDescriptions(
|
||||
const boost::filesystem::path &path,
|
||||
util::ViewOrVector<std::uint32_t, Ownership> &turn_offsets,
|
||||
util::ViewOrVector<extractor::guidance::TurnLaneType::Mask, Ownership> &turn_masks)
|
||||
template <typename OffsetsT, typename MaskT>
|
||||
inline void readTurnLaneDescriptions(const boost::filesystem::path &path,
|
||||
OffsetsT &turn_offsets,
|
||||
MaskT &turn_masks)
|
||||
{
|
||||
static_assert(
|
||||
std::is_same<typename MaskT::value_type, extractor::guidance::TurnLaneType::Mask>::value,
|
||||
"");
|
||||
static_assert(std::is_same<typename OffsetsT::value_type, std::uint32_t>::value, "");
|
||||
|
||||
const auto fingerprint = storage::io::FileReader::HasNoFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
|
||||
@ -139,12 +157,16 @@ inline void readTurnLaneDescriptions(
|
||||
}
|
||||
|
||||
// writes .osrm.tls
|
||||
template <storage::Ownership Ownership>
|
||||
inline void writeTurnLaneDescriptions(
|
||||
const boost::filesystem::path &path,
|
||||
const util::ViewOrVector<std::uint32_t, Ownership> &turn_offsets,
|
||||
const util::ViewOrVector<extractor::guidance::TurnLaneType::Mask, Ownership> &turn_masks)
|
||||
template <typename OffsetsT, typename MaskT>
|
||||
inline void writeTurnLaneDescriptions(const boost::filesystem::path &path,
|
||||
const OffsetsT &turn_offsets,
|
||||
const MaskT &turn_masks)
|
||||
{
|
||||
static_assert(
|
||||
std::is_same<typename MaskT::value_type, extractor::guidance::TurnLaneType::Mask>::value,
|
||||
"");
|
||||
static_assert(std::is_same<typename OffsetsT::value_type, std::uint32_t>::value, "");
|
||||
|
||||
const auto fingerprint = storage::io::FileWriter::HasNoFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
|
@ -45,6 +45,8 @@ template <typename T, storage::Ownership Ownership> class PackedVector
|
||||
static const constexpr std::size_t PACKSIZE = BITSIZE * ELEMSIZE;
|
||||
|
||||
public:
|
||||
using value_type = T;
|
||||
|
||||
/**
|
||||
* Returns the size of the packed vector datastructure with `elements` packed elements (the size
|
||||
* of
|
||||
|
@ -299,8 +299,7 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
TIMER_STOP(rtree);
|
||||
|
||||
util::Log() << "Writing node map ...";
|
||||
files::writeNodes<storage::Ownership::Container>(
|
||||
config.node_output_path, coordinates, osm_node_ids);
|
||||
files::writeNodes(config.node_output_path, coordinates, osm_node_ids);
|
||||
|
||||
WriteEdgeBasedGraph(config.edge_graph_output_path, max_edge_id, edge_based_edge_list);
|
||||
|
||||
|
@ -566,7 +566,7 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
|
||||
util::vector_view<extractor::guidance::TurnLaneType::Mask> masks(
|
||||
masks_ptr, layout.num_entries[storage::DataLayout::LANE_DESCRIPTION_MASKS]);
|
||||
|
||||
extractor::files::readTurnLaneDescriptions<storage::Ownership::View>(
|
||||
extractor::files::readTurnLaneDescriptions(
|
||||
config.turn_lane_description_path, offsets, masks);
|
||||
}
|
||||
|
||||
@ -695,8 +695,7 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
|
||||
util::PackedVectorView<OSMNodeID> osm_node_ids;
|
||||
osm_node_ids.reset(osmnodeid_ptr, layout.num_entries[DataLayout::OSM_NODE_ID_LIST]);
|
||||
|
||||
extractor::files::readNodes<storage::Ownership::View>(
|
||||
config.nodes_data_path, coordinates, osm_node_ids);
|
||||
extractor::files::readNodes(config.nodes_data_path, coordinates, osm_node_ids);
|
||||
}
|
||||
|
||||
// load turn weight penalties
|
||||
|
Loading…
Reference in New Issue
Block a user