2017-04-01 17:56:47 -04:00
|
|
|
#ifndef OSRM_PARTITION_SERIALIZATION_HPP
|
|
|
|
#define OSRM_PARTITION_SERIALIZATION_HPP
|
2017-03-01 17:55:18 -05:00
|
|
|
|
2017-03-06 09:50:04 -05:00
|
|
|
#include "partition/cell_storage.hpp"
|
2017-03-10 17:35:46 -05:00
|
|
|
#include "partition/edge_based_graph.hpp"
|
2017-03-06 22:59:28 -05:00
|
|
|
#include "partition/multi_level_graph.hpp"
|
2017-03-07 07:57:55 -05:00
|
|
|
#include "partition/multi_level_partition.hpp"
|
2017-03-04 13:54:06 -05:00
|
|
|
|
2017-03-01 17:55:18 -05:00
|
|
|
#include "storage/io.hpp"
|
2017-04-04 03:52:00 -04:00
|
|
|
#include "storage/shared_memory_ownership.hpp"
|
2017-03-01 17:55:18 -05:00
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace partition
|
|
|
|
{
|
2017-04-01 17:56:47 -04:00
|
|
|
namespace serialization
|
2017-03-01 17:55:18 -05:00
|
|
|
{
|
|
|
|
|
2017-04-04 03:52:00 -04:00
|
|
|
template <typename EdgeDataT, storage::Ownership Ownership>
|
2017-04-02 12:35:28 -04:00
|
|
|
inline void read(storage::io::FileReader &reader, MultiLevelGraph<EdgeDataT, Ownership> &graph)
|
2017-03-06 22:59:28 -05:00
|
|
|
{
|
|
|
|
reader.DeserializeVector(graph.node_array);
|
|
|
|
reader.DeserializeVector(graph.edge_array);
|
2017-04-02 19:13:24 -04:00
|
|
|
reader.DeserializeVector(graph.node_to_edge_offset);
|
2017-03-06 22:59:28 -05:00
|
|
|
}
|
|
|
|
|
2017-04-04 03:52:00 -04:00
|
|
|
template <typename EdgeDataT, storage::Ownership Ownership>
|
2017-04-01 17:56:47 -04:00
|
|
|
inline void write(storage::io::FileWriter &writer,
|
2017-04-03 03:51:41 -04:00
|
|
|
const MultiLevelGraph<EdgeDataT, Ownership> &graph)
|
2017-03-06 22:59:28 -05:00
|
|
|
{
|
|
|
|
writer.SerializeVector(graph.node_array);
|
|
|
|
writer.SerializeVector(graph.edge_array);
|
|
|
|
writer.SerializeVector(graph.node_to_edge_offset);
|
|
|
|
}
|
|
|
|
|
2017-04-02 12:35:28 -04:00
|
|
|
template <storage::Ownership Ownership>
|
|
|
|
inline void read(storage::io::FileReader &reader, detail::MultiLevelPartitionImpl<Ownership> &mlp)
|
2017-03-06 09:50:04 -05:00
|
|
|
{
|
2017-04-02 12:35:28 -04:00
|
|
|
reader.ReadInto(*mlp.level_data);
|
2017-03-06 09:50:04 -05:00
|
|
|
reader.DeserializeVector(mlp.partition);
|
|
|
|
reader.DeserializeVector(mlp.cell_to_children);
|
|
|
|
}
|
|
|
|
|
2017-04-02 12:35:28 -04:00
|
|
|
template <storage::Ownership Ownership>
|
|
|
|
inline void write(storage::io::FileWriter &writer,
|
|
|
|
const detail::MultiLevelPartitionImpl<Ownership> &mlp)
|
2017-03-01 17:55:18 -05:00
|
|
|
{
|
2017-04-02 12:35:28 -04:00
|
|
|
writer.WriteOne(*mlp.level_data);
|
2017-03-01 17:55:18 -05:00
|
|
|
writer.SerializeVector(mlp.partition);
|
|
|
|
writer.SerializeVector(mlp.cell_to_children);
|
|
|
|
}
|
2017-03-04 13:36:29 -05:00
|
|
|
|
2017-04-02 12:35:28 -04:00
|
|
|
template <storage::Ownership Ownership>
|
|
|
|
inline void read(storage::io::FileReader &reader, detail::CellStorageImpl<Ownership> &storage)
|
2017-03-07 09:43:41 -05:00
|
|
|
{
|
|
|
|
reader.DeserializeVector(storage.weights);
|
|
|
|
reader.DeserializeVector(storage.source_boundary);
|
|
|
|
reader.DeserializeVector(storage.destination_boundary);
|
|
|
|
reader.DeserializeVector(storage.cells);
|
|
|
|
reader.DeserializeVector(storage.level_to_cell_offset);
|
|
|
|
}
|
|
|
|
|
2017-04-02 12:35:28 -04:00
|
|
|
template <storage::Ownership Ownership>
|
|
|
|
inline void write(storage::io::FileWriter &writer,
|
|
|
|
const detail::CellStorageImpl<Ownership> &storage)
|
2017-03-04 13:36:29 -05:00
|
|
|
{
|
|
|
|
writer.SerializeVector(storage.weights);
|
|
|
|
writer.SerializeVector(storage.source_boundary);
|
|
|
|
writer.SerializeVector(storage.destination_boundary);
|
|
|
|
writer.SerializeVector(storage.cells);
|
|
|
|
writer.SerializeVector(storage.level_to_cell_offset);
|
|
|
|
}
|
2017-03-01 17:55:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|