Add CRC checksums to EBG and turns data
This commit is contained in:
@@ -36,6 +36,16 @@ struct DynamicEdgeBasedGraph : util::DynamicGraph<EdgeBasedGraphEdgeData>
|
||||
{
|
||||
using Base = util::DynamicGraph<EdgeBasedGraphEdgeData>;
|
||||
using Base::Base;
|
||||
|
||||
template <class ContainerT>
|
||||
DynamicEdgeBasedGraph(const NodeIterator nodes,
|
||||
const ContainerT &graph,
|
||||
std::uint32_t connectivity_checksum)
|
||||
: Base(nodes, graph), connectivity_checksum(connectivity_checksum)
|
||||
{
|
||||
}
|
||||
|
||||
std::uint32_t connectivity_checksum;
|
||||
};
|
||||
|
||||
struct DynamicEdgeBasedGraphEdge : DynamicEdgeBasedGraph::InputEdge
|
||||
|
||||
@@ -187,12 +187,13 @@ inline DynamicEdgeBasedGraph LoadEdgeBasedGraph(const boost::filesystem::path &p
|
||||
{
|
||||
EdgeID number_of_edge_based_nodes;
|
||||
std::vector<extractor::EdgeBasedEdge> edges;
|
||||
extractor::files::readEdgeBasedGraph(path, number_of_edge_based_nodes, edges);
|
||||
std::uint32_t checksum;
|
||||
extractor::files::readEdgeBasedGraph(path, number_of_edge_based_nodes, edges, checksum);
|
||||
|
||||
auto directed = splitBidirectionalEdges(edges);
|
||||
auto tidied = prepareEdgesForUsageInGraph<DynamicEdgeBasedGraphEdge>(std::move(directed));
|
||||
|
||||
return DynamicEdgeBasedGraph(number_of_edge_based_nodes, std::move(tidied));
|
||||
return DynamicEdgeBasedGraph(number_of_edge_based_nodes, std::move(tidied), checksum);
|
||||
}
|
||||
|
||||
} // ns partition
|
||||
|
||||
@@ -16,7 +16,9 @@ namespace files
|
||||
|
||||
// reads .osrm.mldgr file
|
||||
template <typename MultiLevelGraphT>
|
||||
inline void readGraph(const boost::filesystem::path &path, MultiLevelGraphT &graph)
|
||||
inline void readGraph(const boost::filesystem::path &path,
|
||||
MultiLevelGraphT &graph,
|
||||
std::uint32_t &connectivity_checksum)
|
||||
{
|
||||
static_assert(std::is_same<customizer::MultiLevelEdgeBasedGraphView, MultiLevelGraphT>::value ||
|
||||
std::is_same<customizer::MultiLevelEdgeBasedGraph, MultiLevelGraphT>::value,
|
||||
@@ -25,12 +27,14 @@ inline void readGraph(const boost::filesystem::path &path, MultiLevelGraphT &gra
|
||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
|
||||
serialization::read(reader, graph);
|
||||
serialization::read(reader, graph, connectivity_checksum);
|
||||
}
|
||||
|
||||
// writes .osrm.mldgr file
|
||||
template <typename MultiLevelGraphT>
|
||||
inline void writeGraph(const boost::filesystem::path &path, const MultiLevelGraphT &graph)
|
||||
inline void writeGraph(const boost::filesystem::path &path,
|
||||
const MultiLevelGraphT &graph,
|
||||
const std::uint32_t connectivity_checksum)
|
||||
{
|
||||
static_assert(std::is_same<customizer::MultiLevelEdgeBasedGraphView, MultiLevelGraphT>::value ||
|
||||
std::is_same<customizer::MultiLevelEdgeBasedGraph, MultiLevelGraphT>::value,
|
||||
@@ -39,7 +43,7 @@ inline void writeGraph(const boost::filesystem::path &path, const MultiLevelGrap
|
||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
serialization::write(writer, graph);
|
||||
serialization::write(writer, graph, connectivity_checksum);
|
||||
}
|
||||
|
||||
// read .osrm.partition file
|
||||
|
||||
@@ -24,10 +24,14 @@ template <typename EdgeDataT, storage::Ownership Ownership> class MultiLevelGrap
|
||||
namespace serialization
|
||||
{
|
||||
template <typename EdgeDataT, storage::Ownership Ownership>
|
||||
void read(storage::io::FileReader &reader, MultiLevelGraph<EdgeDataT, Ownership> &graph);
|
||||
void read(storage::io::FileReader &reader,
|
||||
MultiLevelGraph<EdgeDataT, Ownership> &graph,
|
||||
std::uint32_t &connectivity_checksum);
|
||||
|
||||
template <typename EdgeDataT, storage::Ownership Ownership>
|
||||
void write(storage::io::FileWriter &writer, const MultiLevelGraph<EdgeDataT, Ownership> &graph);
|
||||
void write(storage::io::FileWriter &writer,
|
||||
const MultiLevelGraph<EdgeDataT, Ownership> &graph,
|
||||
const std::uint32_t connectivity_checksum);
|
||||
}
|
||||
|
||||
template <typename EdgeDataT, storage::Ownership Ownership>
|
||||
@@ -199,12 +203,15 @@ class MultiLevelGraph : public util::StaticGraph<EdgeDataT, Ownership>
|
||||
|
||||
friend void
|
||||
serialization::read<EdgeDataT, Ownership>(storage::io::FileReader &reader,
|
||||
MultiLevelGraph<EdgeDataT, Ownership> &graph);
|
||||
MultiLevelGraph<EdgeDataT, Ownership> &graph,
|
||||
std::uint32_t &connectivity_checksum);
|
||||
friend void
|
||||
serialization::write<EdgeDataT, Ownership>(storage::io::FileWriter &writer,
|
||||
const MultiLevelGraph<EdgeDataT, Ownership> &graph);
|
||||
const MultiLevelGraph<EdgeDataT, Ownership> &graph,
|
||||
const std::uint32_t connectivity_checksum);
|
||||
|
||||
Vector<EdgeOffset> node_to_edge_offset;
|
||||
std::uint32_t connectivity_checksum;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,20 +18,25 @@ namespace serialization
|
||||
{
|
||||
|
||||
template <typename EdgeDataT, storage::Ownership Ownership>
|
||||
inline void read(storage::io::FileReader &reader, MultiLevelGraph<EdgeDataT, Ownership> &graph)
|
||||
inline void read(storage::io::FileReader &reader,
|
||||
MultiLevelGraph<EdgeDataT, Ownership> &graph,
|
||||
std::uint32_t &connectivity_checksum)
|
||||
{
|
||||
storage::serialization::read(reader, graph.node_array);
|
||||
storage::serialization::read(reader, graph.edge_array);
|
||||
storage::serialization::read(reader, graph.node_to_edge_offset);
|
||||
reader.ReadInto(connectivity_checksum);
|
||||
}
|
||||
|
||||
template <typename EdgeDataT, storage::Ownership Ownership>
|
||||
inline void write(storage::io::FileWriter &writer,
|
||||
const MultiLevelGraph<EdgeDataT, Ownership> &graph)
|
||||
const MultiLevelGraph<EdgeDataT, Ownership> &graph,
|
||||
const std::uint32_t connectivity_checksum)
|
||||
{
|
||||
storage::serialization::write(writer, graph.node_array);
|
||||
storage::serialization::write(writer, graph.edge_array);
|
||||
storage::serialization::write(writer, graph.node_to_edge_offset);
|
||||
writer.WriteOne(connectivity_checksum);
|
||||
}
|
||||
|
||||
template <storage::Ownership Ownership>
|
||||
|
||||
Reference in New Issue
Block a user