2018-02-01 10:47:43 -05:00
|
|
|
#ifndef OSRM_PARTITIONER_SERIALIZATION_HPP
|
|
|
|
#define OSRM_PARTITIONER_SERIALIZATION_HPP
|
2017-03-01 17:55:18 -05:00
|
|
|
|
2018-02-01 10:47:43 -05:00
|
|
|
#include "partitioner/cell_storage.hpp"
|
|
|
|
#include "partitioner/edge_based_graph.hpp"
|
|
|
|
#include "partitioner/multi_level_graph.hpp"
|
|
|
|
#include "partitioner/multi_level_partition.hpp"
|
2017-03-04 13:54:06 -05:00
|
|
|
|
2018-03-13 09:25:22 -04:00
|
|
|
#include "storage/block.hpp"
|
2017-03-01 17:55:18 -05:00
|
|
|
#include "storage/io.hpp"
|
2017-04-04 18:00:17 -04:00
|
|
|
#include "storage/serialization.hpp"
|
2017-04-04 03:52:00 -04:00
|
|
|
#include "storage/shared_memory_ownership.hpp"
|
2018-03-15 11:03:48 -04:00
|
|
|
#include "storage/tar.hpp"
|
2017-03-01 17:55:18 -05:00
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
2018-02-01 10:47:43 -05:00
|
|
|
namespace partitioner
|
2017-03-01 17:55:18 -05:00
|
|
|
{
|
2017-04-01 17:56:47 -04:00
|
|
|
namespace serialization
|
2017-03-01 17:55:18 -05:00
|
|
|
{
|
|
|
|
|
2017-04-02 12:35:28 -04:00
|
|
|
template <storage::Ownership Ownership>
|
2018-03-15 11:03:48 -04:00
|
|
|
inline void read(storage::tar::FileReader &reader,
|
|
|
|
const std::string &name,
|
|
|
|
detail::MultiLevelPartitionImpl<Ownership> &mlp)
|
2017-03-06 09:50:04 -05:00
|
|
|
{
|
2018-03-19 19:31:49 -04:00
|
|
|
reader.ReadInto(name + "/level_data", *mlp.level_data);
|
2018-03-15 11:03:48 -04:00
|
|
|
storage::serialization::read(reader, name + "/partition", mlp.partition);
|
|
|
|
storage::serialization::read(reader, name + "/cell_to_children", mlp.cell_to_children);
|
2017-03-06 09:50:04 -05:00
|
|
|
}
|
|
|
|
|
2017-04-02 12:35:28 -04:00
|
|
|
template <storage::Ownership Ownership>
|
2018-03-15 11:03:48 -04:00
|
|
|
inline void write(storage::tar::FileWriter &writer,
|
|
|
|
const std::string &name,
|
2017-04-02 12:35:28 -04:00
|
|
|
const detail::MultiLevelPartitionImpl<Ownership> &mlp)
|
2017-03-01 17:55:18 -05:00
|
|
|
{
|
2018-03-15 11:03:48 -04:00
|
|
|
writer.WriteElementCount64(name + "/level_data", 1);
|
2018-03-19 19:31:49 -04:00
|
|
|
writer.WriteFrom(name + "/level_data", *mlp.level_data);
|
2018-03-15 11:03:48 -04:00
|
|
|
storage::serialization::write(writer, name + "/partition", mlp.partition);
|
|
|
|
storage::serialization::write(writer, name + "/cell_to_children", mlp.cell_to_children);
|
2017-03-01 17:55:18 -05:00
|
|
|
}
|
2017-03-04 13:36:29 -05:00
|
|
|
|
2017-04-02 12:35:28 -04:00
|
|
|
template <storage::Ownership Ownership>
|
2018-03-15 11:03:48 -04:00
|
|
|
inline void read(storage::tar::FileReader &reader,
|
|
|
|
const std::string &name,
|
|
|
|
detail::CellStorageImpl<Ownership> &storage)
|
2017-03-07 09:43:41 -05:00
|
|
|
{
|
2018-03-15 11:03:48 -04:00
|
|
|
storage::serialization::read(reader, name + "/source_boundary", storage.source_boundary);
|
|
|
|
storage::serialization::read(
|
|
|
|
reader, name + "/destination_boundary", storage.destination_boundary);
|
|
|
|
storage::serialization::read(reader, name + "/cells", storage.cells);
|
|
|
|
storage::serialization::read(
|
|
|
|
reader, name + "/level_to_cell_offset", storage.level_to_cell_offset);
|
2017-03-07 09:43:41 -05:00
|
|
|
}
|
|
|
|
|
2017-04-02 12:35:28 -04:00
|
|
|
template <storage::Ownership Ownership>
|
2018-03-15 11:03:48 -04:00
|
|
|
inline void write(storage::tar::FileWriter &writer,
|
|
|
|
const std::string &name,
|
2017-04-02 12:35:28 -04:00
|
|
|
const detail::CellStorageImpl<Ownership> &storage)
|
2017-03-04 13:36:29 -05:00
|
|
|
{
|
2018-03-15 11:03:48 -04:00
|
|
|
storage::serialization::write(writer, name + "/source_boundary", storage.source_boundary);
|
|
|
|
storage::serialization::write(
|
|
|
|
writer, name + "/destination_boundary", storage.destination_boundary);
|
|
|
|
storage::serialization::write(writer, name + "/cells", storage.cells);
|
|
|
|
storage::serialization::write(
|
|
|
|
writer, name + "/level_to_cell_offset", storage.level_to_cell_offset);
|
2017-03-04 13:36:29 -05:00
|
|
|
}
|
2020-11-26 10:21:39 -05:00
|
|
|
} // namespace serialization
|
|
|
|
} // namespace partitioner
|
|
|
|
} // namespace osrm
|
2017-03-01 17:55:18 -05:00
|
|
|
|
|
|
|
#endif
|