First step for better vector encapsulation
This commit is contained in:
parent
4c2d578561
commit
f558b16147
@ -4,6 +4,7 @@
|
|||||||
#include "storage/block.hpp"
|
#include "storage/block.hpp"
|
||||||
#include "storage/io_fwd.hpp"
|
#include "storage/io_fwd.hpp"
|
||||||
|
|
||||||
|
#include "util/vector_view.hpp"
|
||||||
#include "util/exception.hpp"
|
#include "util/exception.hpp"
|
||||||
#include "util/exception_utils.hpp"
|
#include "util/exception_utils.hpp"
|
||||||
#include "util/log.hpp"
|
#include "util/log.hpp"
|
||||||
@ -86,6 +87,18 @@ class DataLayout
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
util::vector_view<T> GetVector(char* shared_memory, const std::string& name) const
|
||||||
|
{
|
||||||
|
return util::vector_view<T>(GetBlockPtr<T>(shared_memory, name), GetBlockEntries(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
util::vector_view<T> GetWritableVector(char* shared_memory, const std::string& name) const
|
||||||
|
{
|
||||||
|
return util::vector_view<T>(GetBlockPtr<T, true>(shared_memory, name), GetBlockEntries(name));
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, bool WRITE_CANARY = false>
|
template <typename T, bool WRITE_CANARY = false>
|
||||||
inline T *GetBlockPtr(char *shared_memory, const std::string &name) const
|
inline T *GetBlockPtr(char *shared_memory, const std::string &name) const
|
||||||
{
|
{
|
||||||
|
@ -311,17 +311,11 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
|
|||||||
|
|
||||||
// Name data
|
// Name data
|
||||||
{
|
{
|
||||||
const auto name_blocks_ptr =
|
auto blocks =
|
||||||
layout.GetBlockPtr<extractor::NameTableView::IndexedData::BlockReference, true>(
|
layout.GetWritableVector<extractor::NameTableView::IndexedData::BlockReference>(
|
||||||
memory_ptr, "/common/names/blocks");
|
memory_ptr, "/common/names/blocks");
|
||||||
const auto name_values_ptr =
|
auto values = layout.GetWritableVector<extractor::NameTableView::IndexedData::ValueType>(
|
||||||
layout.GetBlockPtr<extractor::NameTableView::IndexedData::ValueType, true>(
|
memory_ptr, "/common/names/values");
|
||||||
memory_ptr, "/common/names/values");
|
|
||||||
|
|
||||||
util::vector_view<extractor::NameTableView::IndexedData::BlockReference> blocks(
|
|
||||||
name_blocks_ptr, layout.GetBlockEntries("/common/names/blocks"));
|
|
||||||
util::vector_view<extractor::NameTableView::IndexedData::ValueType> values(
|
|
||||||
name_values_ptr, layout.GetBlockEntries("/common/names/values"));
|
|
||||||
|
|
||||||
extractor::NameTableView::IndexedData index_data_view{std::move(blocks), std::move(values)};
|
extractor::NameTableView::IndexedData index_data_view{std::move(blocks), std::move(values)};
|
||||||
extractor::NameTableView name_table{index_data_view};
|
extractor::NameTableView name_table{index_data_view};
|
||||||
@ -330,41 +324,28 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
|
|||||||
|
|
||||||
// Turn lane data
|
// Turn lane data
|
||||||
{
|
{
|
||||||
const auto turn_lane_data_ptr = layout.GetBlockPtr<util::guidance::LaneTupleIdPair, true>(
|
auto turn_lane_data = layout.GetWritableVector<util::guidance::LaneTupleIdPair>(
|
||||||
memory_ptr, "/common/turn_lanes/data");
|
memory_ptr, "/common/turn_lanes/data");
|
||||||
util::vector_view<util::guidance::LaneTupleIdPair> turn_lane_data(
|
|
||||||
turn_lane_data_ptr, layout.GetBlockEntries("/common/turn_lanes/data"));
|
|
||||||
|
|
||||||
extractor::files::readTurnLaneData(config.GetPath(".osrm.tld"), turn_lane_data);
|
extractor::files::readTurnLaneData(config.GetPath(".osrm.tld"), turn_lane_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn lane descriptions
|
// Turn lane descriptions
|
||||||
{
|
{
|
||||||
auto offsets_ptr =
|
auto offsets =
|
||||||
layout.GetBlockPtr<std::uint32_t, true>(memory_ptr, "/common/turn_lanes/offsets");
|
layout.GetWritableVector<std::uint32_t>(memory_ptr, "/common/turn_lanes/offsets");
|
||||||
util::vector_view<std::uint32_t> offsets(
|
auto masks = layout.GetWritableVector<extractor::TurnLaneType::Mask>(
|
||||||
offsets_ptr, layout.GetBlockEntries("/common/turn_lanes/offsets"));
|
|
||||||
|
|
||||||
auto masks_ptr = layout.GetBlockPtr<extractor::TurnLaneType::Mask, true>(
|
|
||||||
memory_ptr, "/common/turn_lanes/masks");
|
memory_ptr, "/common/turn_lanes/masks");
|
||||||
util::vector_view<extractor::TurnLaneType::Mask> masks(
|
|
||||||
masks_ptr, layout.GetBlockEntries("/common/turn_lanes/masks"));
|
|
||||||
|
|
||||||
extractor::files::readTurnLaneDescriptions(config.GetPath(".osrm.tls"), offsets, masks);
|
extractor::files::readTurnLaneDescriptions(config.GetPath(".osrm.tls"), offsets, masks);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load edge-based nodes data
|
// Load edge-based nodes data
|
||||||
{
|
{
|
||||||
auto edge_based_node_data_list_ptr = layout.GetBlockPtr<extractor::EdgeBasedNode, true>(
|
auto edge_based_node_data = layout.GetWritableVector<extractor::EdgeBasedNode>(
|
||||||
memory_ptr, "/common/ebg_node_data/nodes");
|
memory_ptr, "/common/ebg_node_data/nodes");
|
||||||
util::vector_view<extractor::EdgeBasedNode> edge_based_node_data(
|
auto annotation_data = layout.GetWritableVector<extractor::NodeBasedEdgeAnnotation>(
|
||||||
edge_based_node_data_list_ptr, layout.GetBlockEntries("/common/ebg_node_data/nodes"));
|
memory_ptr, "/common/ebg_node_data/annotations");
|
||||||
|
|
||||||
auto annotation_data_list_ptr =
|
|
||||||
layout.GetBlockPtr<extractor::NodeBasedEdgeAnnotation, true>(
|
|
||||||
memory_ptr, "/common/ebg_node_data/annotations");
|
|
||||||
util::vector_view<extractor::NodeBasedEdgeAnnotation> annotation_data(
|
|
||||||
annotation_data_list_ptr, layout.GetBlockEntries("/common/ebg_node_data/annotations"));
|
|
||||||
|
|
||||||
extractor::EdgeBasedNodeDataView node_data(std::move(edge_based_node_data),
|
extractor::EdgeBasedNodeDataView node_data(std::move(edge_based_node_data),
|
||||||
std::move(annotation_data));
|
std::move(annotation_data));
|
||||||
@ -374,16 +355,11 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
|
|||||||
|
|
||||||
// Load original edge data
|
// Load original edge data
|
||||||
{
|
{
|
||||||
const auto lane_data_id_ptr =
|
auto lane_data_ids = layout.GetWritableVector<LaneDataID>(
|
||||||
layout.GetBlockPtr<LaneDataID, true>(memory_ptr, "/common/turn_data/lane_data_ids");
|
memory_ptr, "/common/turn_data/lane_data_ids");
|
||||||
util::vector_view<LaneDataID> lane_data_ids(
|
|
||||||
lane_data_id_ptr, layout.GetBlockEntries("/common/turn_data/lane_data_ids"));
|
|
||||||
|
|
||||||
const auto turn_instruction_list_ptr = layout.GetBlockPtr<guidance::TurnInstruction, true>(
|
const auto turn_instructions = layout.GetWritableVector<guidance::TurnInstruction>(
|
||||||
memory_ptr, "/common/turn_data/turn_instructions");
|
memory_ptr, "/common/turn_data/turn_instructions");
|
||||||
util::vector_view<guidance::TurnInstruction> turn_instructions(
|
|
||||||
turn_instruction_list_ptr,
|
|
||||||
layout.GetBlockEntries("/common/turn_data/turn_instructions"));
|
|
||||||
|
|
||||||
const auto entry_class_id_list_ptr =
|
const auto entry_class_id_list_ptr =
|
||||||
layout.GetBlockPtr<EntryClassID, true>(memory_ptr, "/common/turn_data/entry_class_ids");
|
layout.GetBlockPtr<EntryClassID, true>(memory_ptr, "/common/turn_data/entry_class_ids");
|
||||||
|
Loading…
Reference in New Issue
Block a user