Initial support for SharedDataFacade

SharedDataLayout was refactored to include canary values at the
boundaries of each memory block. This makes it easy to detect overruns
and block-size mismatches between osrm-datastore and the
SharedDataFacade.
This commit is contained in:
Patrick Niklaus
2014-06-05 17:18:28 +02:00
parent 7a7d0c09d9
commit 807f1d7c1c
7 changed files with 320 additions and 338 deletions
+15 -5
View File
@@ -1,6 +1,9 @@
#ifndef __RANGE_TABLE_H__
#define __RANGE_TABLE_H__
#include <boost/range/irange.hpp>
#include <fstream>
#include <vector>
#if defined(__GNUC__) && defined(__SSE2__)
@@ -8,6 +11,9 @@
#include <xmmintrin.h>
#endif
#include "SharedMemoryFactory.h"
#include "SharedMemoryVectorWrapper.h"
/*
* These pre-declarations are needed because parsing C++ is hard
* and otherwise the compiler gets confused.
@@ -21,9 +27,6 @@ std::ostream& operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, USE_SHA
template<unsigned BLOCK_SIZE, bool USE_SHARED_MEMORY>
std::istream& operator>>(std::istream &in, RangeTable<BLOCK_SIZE, USE_SHARED_MEMORY> &table);
#include "SharedMemoryFactory.h"
#include "SharedMemoryVectorWrapper.h"
/**
* Stores adjacent ranges in a compressed format.
*
@@ -49,6 +52,7 @@ public:
typedef typename ShM<BlockT, USE_SHARED_MEMORY>::vector BlockContainerT;
typedef typename ShM<unsigned, USE_SHARED_MEMORY>::vector OffsetContainerT;
typedef decltype(boost::irange(0u,0u)) RangeT;
friend std::ostream& operator<< <>(std::ostream &out, const RangeTable &table);
friend std::istream& operator>> <>(std::istream &in, RangeTable &table);
@@ -56,7 +60,8 @@ public:
RangeTable() {}
// for loading from shared memory
explicit RangeTable(OffsetContainerT& external_offsets, BlockContainerT& external_blocks)
explicit RangeTable(OffsetContainerT& external_offsets, BlockContainerT& external_blocks, unsigned sum_lengths)
: sum_lengths(sum_lengths)
{
block_offsets.swap(external_offsets);
diff_blocks.swap(external_blocks);
@@ -134,7 +139,7 @@ public:
sum_lengths = lengths_prefix_sum;
}
inline void GetRange(const unsigned id, unsigned& begin_idx, unsigned& end_idx) const
inline RangeT GetRange(const unsigned id) const
{
BOOST_ASSERT(id < block_offsets.size() + diff_blocks.size() * BLOCK_SIZE);
// internal_idx 0 is implicitly stored in block_offsets[block_idx]
@@ -143,6 +148,8 @@ public:
BOOST_ASSERT(block_idx < diff_blocks.size());
unsigned begin_idx = 0;
unsigned end_idx = 0;
begin_idx = block_offsets[block_idx];
const BlockT& block = diff_blocks[block_idx];
if (internal_idx > 0)
@@ -163,6 +170,9 @@ public:
}
BOOST_ASSERT(begin_idx < sum_lengths && end_idx <= sum_lengths);
BOOST_ASSERT(begin_idx <= end_idx);
return boost::irange(begin_idx, end_idx);
}
private:
+2
View File
@@ -766,7 +766,9 @@ class StaticRTree
}
const uint64_t seek_pos = sizeof(uint64_t) + leaf_id * sizeof(LeafNode);
thread_local_rtree_stream->seekg(seek_pos);
BOOST_ASSERT_MSG(thread_local_rtree_stream->good(), "Seeking to position in leaf file failed.");
thread_local_rtree_stream->read((char *)&result_node, sizeof(LeafNode));
BOOST_ASSERT_MSG(thread_local_rtree_stream->good(), "Reading from leaf file failed.");
}
inline bool EdgesAreEquivalent(const FixedPointCoordinate &a,