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