Consolidate file reading through the new FileReader class/interface. (#3321)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user