Consolidate file reading through the new FileReader class/interface. (#3321)

This commit is contained in:
Daniel Patterson
2016-11-30 19:08:01 -08:00
committed by GitHub
parent ef087f963d
commit 5a311012af
11 changed files with 438 additions and 290 deletions
+5 -4
View File
@@ -2,6 +2,7 @@
#include "extractor/edge_based_node.hpp"
#include "extractor/query_node.hpp"
#include "mocks/mock_datafacade.hpp"
#include "storage/io.hpp"
#include "engine/geospatial_query.hpp"
#include "util/coordinate.hpp"
#include "util/timing_util.hpp"
@@ -31,15 +32,15 @@ using BenchStaticRTree =
std::vector<util::Coordinate> loadCoordinates(const boost::filesystem::path &nodes_file)
{
boost::filesystem::ifstream nodes_input_stream(nodes_file, std::ios::binary);
osrm::storage::io::FileReader nodes_path_file_reader(
nodes_file, osrm::storage::io::FileReader::HasNoFingerprint);
extractor::QueryNode current_node;
std::uint64_t coordinate_count = 0;
nodes_input_stream.read((char *)&coordinate_count, sizeof(std::uint64_t));
unsigned coordinate_count = nodes_path_file_reader.ReadElementCount32();
std::vector<util::Coordinate> coords(coordinate_count);
for (unsigned i = 0; i < coordinate_count; ++i)
{
nodes_input_stream.read((char *)&current_node, sizeof(extractor::QueryNode));
nodes_path_file_reader.ReadInto(&current_node, 1);
coords[i] = util::Coordinate(current_node.lon, current_node.lat);
}
return coords;