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
+1 -1
View File
@@ -18,7 +18,7 @@ class NameTable
{
private:
// FIXME should this use shared memory
RangeTable<16, false> m_name_table;
util::RangeTable<16, false> m_name_table;
ShM<char, false>::vector m_names_char_list;
public:
+16
View File
@@ -1,6 +1,7 @@
#ifndef RANGE_TABLE_HPP
#define RANGE_TABLE_HPP
#include "storage/io.hpp"
#include "util/integer_range.hpp"
#include "util/shared_memory_vector_wrapper.hpp"
@@ -138,6 +139,21 @@ template <unsigned BLOCK_SIZE, bool USE_SHARED_MEMORY> class RangeTable
sum_lengths = lengths_prefix_sum;
}
void ReadARangeTable(osrm::storage::io::FileReader &filereader)
{
unsigned number_of_blocks = filereader.ReadElementCount32();
// read total length
filereader.ReadInto(&sum_lengths, 1);
block_offsets.resize(number_of_blocks);
diff_blocks.resize(number_of_blocks);
// read block offsets
filereader.ReadInto(block_offsets.data(), number_of_blocks);
// read blocks
filereader.ReadInto(diff_blocks.data(), number_of_blocks);
}
inline RangeT GetRange(const unsigned id) const
{
BOOST_ASSERT(id < block_offsets.size() + diff_blocks.size() * BLOCK_SIZE);