Refactor graph writing code in contractor

This commit is contained in:
Patrick Niklaus
2017-04-02 23:02:57 +00:00
committed by Patrick Niklaus
parent 90c194fc81
commit ef3fcdc6e6
11 changed files with 172 additions and 221 deletions
+2 -2
View File
@@ -68,9 +68,9 @@ class Contractor
void WriteCoreNodeMarker(std::vector<bool> &&is_core_node) const;
void WriteNodeLevels(std::vector<float> &&node_levels) const;
void ReadNodeLevels(std::vector<float> &contraction_order) const;
std::size_t
void
WriteContractedGraph(unsigned number_of_edge_based_nodes,
const util::DeallocatingVector<QueryEdge> &contracted_edge_list);
util::DeallocatingVector<QueryEdge> contracted_edge_list);
void FindComponents(unsigned max_edge_id,
const util::DeallocatingVector<extractor::EdgeBasedEdge> &edges,
std::vector<extractor::EdgeBasedNode> &nodes) const;
+47
View File
@@ -0,0 +1,47 @@
#ifndef OSRM_CONTRACTOR_FILES_HPP
#define OSRM_CONTRACTOR_FILES_HPP
#include "contractor/query_graph.hpp"
#include "util/serialization.hpp"
#include "storage/io.hpp"
namespace osrm
{
namespace contractor
{
namespace files
{
// reads .osrm.hsgr file
template<storage::Ownership Ownership>
inline void readGraph(const boost::filesystem::path &path,
unsigned &checksum,
detail::QueryGraph<Ownership> &graph)
{
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
storage::io::FileReader reader{path, fingerprint};
reader.ReadInto(checksum);
util::serialization::read(reader, graph);
}
// writes .osrm.hsgr file
template<storage::Ownership Ownership>
inline void writeGraph(const boost::filesystem::path &path,
unsigned checksum,
const detail::QueryGraph<Ownership> &graph)
{
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
storage::io::FileWriter writer{path, fingerprint};
writer.WriteOne(checksum);
util::serialization::write(writer, graph);
}
}
}
}
#endif
+27
View File
@@ -0,0 +1,27 @@
#ifndef OSRM_CONTRACTOR_QUERY_GRAPH_HPP
#define OSRM_CONTRACTOR_QUERY_GRAPH_HPP
#include "contractor/query_edge.hpp"
#include "util/typedefs.hpp"
#include "util/static_graph.hpp"
#include <tuple>
namespace osrm
{
namespace contractor
{
namespace detail
{
template <storage::Ownership Ownership> using QueryGraph = util::StaticGraph<typename QueryEdge::EdgeData, Ownership>;
}
using QueryGraph = detail::QueryGraph<storage::Ownership::Container>;
using QueryGraphView = detail::QueryGraph<storage::Ownership::View>;
}
}
#endif // QUERYEDGE_HPP