2016-01-07 04:33:47 -05:00
|
|
|
#ifndef OSRM_INCLUDE_UTIL_IO_HPP_
|
|
|
|
#define OSRM_INCLUDE_UTIL_IO_HPP_
|
|
|
|
|
2016-12-06 15:30:46 -05:00
|
|
|
#include "util/log.hpp"
|
2016-01-07 04:33:47 -05:00
|
|
|
|
|
|
|
#include <boost/filesystem.hpp>
|
2016-06-21 04:41:08 -04:00
|
|
|
#include <boost/numeric/conversion/cast.hpp>
|
2016-01-07 04:33:47 -05:00
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
#include <bitset>
|
2016-04-26 07:27:40 -04:00
|
|
|
#include <fstream>
|
2016-06-21 04:41:08 -04:00
|
|
|
#include <stxxl/vector>
|
2016-01-07 04:33:47 -05:00
|
|
|
#include <vector>
|
|
|
|
|
2016-11-11 08:52:21 -05:00
|
|
|
#include "storage/io.hpp"
|
2016-11-16 08:40:11 -05:00
|
|
|
#include "util/fingerprint.hpp"
|
2016-01-07 04:33:47 -05:00
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace util
|
|
|
|
{
|
|
|
|
|
2016-06-21 04:41:08 -04:00
|
|
|
template <typename simple_type>
|
2016-11-15 03:08:45 -05:00
|
|
|
void deserializeAdjacencyArray(const std::string &filename,
|
2016-06-21 04:41:08 -04:00
|
|
|
std::vector<std::uint32_t> &offsets,
|
2016-07-26 09:00:58 -04:00
|
|
|
std::vector<simple_type> &data)
|
2016-06-21 04:41:08 -04:00
|
|
|
{
|
2016-11-15 17:49:28 -05:00
|
|
|
storage::io::FileReader file(filename, storage::io::FileReader::HasNoFingerprint);
|
2016-06-21 04:41:08 -04:00
|
|
|
|
2016-11-15 03:08:45 -05:00
|
|
|
file.DeserializeVector(offsets);
|
|
|
|
file.DeserializeVector(data);
|
2016-06-21 04:41:08 -04:00
|
|
|
|
|
|
|
// offsets have to match up with the size of the data
|
|
|
|
if (offsets.empty() || (offsets.back() != boost::numeric_cast<std::uint32_t>(data.size())))
|
2016-12-06 15:30:46 -05:00
|
|
|
throw util::exception(
|
|
|
|
"Error in " + filename +
|
|
|
|
(offsets.empty() ? "Offsets are empty" : "Offset and data size do not match") +
|
|
|
|
SOURCE_REF);
|
2016-06-21 04:41:08 -04:00
|
|
|
}
|
|
|
|
|
2016-01-07 04:33:47 -05:00
|
|
|
} // namespace util
|
|
|
|
} // namespace osrm
|
|
|
|
|
|
|
|
#endif // OSRM_INCLUDE_UTIL_IO_HPP_
|