Consolidate datafacade file loading logic.

Both datafacades now use a single large memory block and common
file loading logic.
This commit is contained in:
Daniel Patterson
2016-10-24 21:27:56 -06:00
parent 8f6dd805e5
commit bf6df74d44
10 changed files with 1054 additions and 1753 deletions
+18 -3
View File
@@ -7,6 +7,7 @@
#include <cstdint>
#include <array>
#include <iostream>
namespace osrm
{
@@ -54,7 +55,7 @@ const constexpr char *block_id_to_name[] = {"NAME_OFFSETS",
"LANE_DESCRIPTION_OFFSETS",
"LANE_DESCRIPTION_MASKS"};
struct SharedDataLayout
struct DataLayout
{
enum BlockID
{
@@ -101,7 +102,7 @@ struct SharedDataLayout
std::array<uint64_t, NUM_BLOCKS> num_entries;
std::array<uint64_t, NUM_BLOCKS> entry_size;
SharedDataLayout() : num_entries(), entry_size() {}
DataLayout() : num_entries(), entry_size() {}
template <typename T> inline void SetBlockSize(BlockID bid, uint64_t entries)
{
@@ -171,6 +172,20 @@ struct SharedDataLayout
return ptr;
}
friend std::ostream &operator<<(std::ostream &os, const DataLayout &layout)
{
os << "Memory layout: " << std::endl;
os << " Total size: " << layout.GetSizeOfLayout() << std::endl;
for (unsigned bid = 0; bid < BlockID::NUM_BLOCKS; bid++)
{
os << " " << block_id_to_name[bid]
<< " offset: " << layout.GetBlockOffset(BlockID(bid))
<< " size: " << layout.GetBlockSize(BlockID(bid)) << std::endl;
}
return os;
}
};
enum SharedDataType
@@ -214,7 +229,7 @@ inline std::string regionToString(const SharedDataType region)
}
}
static_assert(sizeof(block_id_to_name) / sizeof(*block_id_to_name) == SharedDataLayout::NUM_BLOCKS,
static_assert(sizeof(block_id_to_name) / sizeof(*block_id_to_name) == DataLayout::NUM_BLOCKS,
"Number of blocks needs to match the number of Block names.");
}
}
+4
View File
@@ -29,6 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define STORAGE_HPP
#include "storage/storage_config.hpp"
#include "storage/shared_datatype.hpp"
#include <boost/filesystem/path.hpp>
@@ -52,6 +53,9 @@ class Storage
ReturnCode Run(int max_wait);
void LoadLayout(DataLayout *layout);
void LoadData(DataLayout *layout_ptr, char *memory_ptr);
private:
StorageConfig config;
};