Remove fixed block identifiers
This commit is contained in:
committed by
Patrick Niklaus
parent
f3b7ab92ff
commit
4a9fdca7b2
@@ -16,7 +16,7 @@ class ContiguousBlockAllocator
|
||||
virtual ~ContiguousBlockAllocator() = default;
|
||||
|
||||
// interface to give access to the datafacades
|
||||
virtual storage::DataLayout &GetLayout() = 0;
|
||||
virtual const storage::DataLayout &GetLayout() = 0;
|
||||
virtual char *GetMemory() = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -81,26 +81,25 @@ class ContiguousInternalMemoryAlgorithmDataFacade<CH> : public datafacade::Algor
|
||||
// allocator that keeps the allocation data
|
||||
std::shared_ptr<ContiguousBlockAllocator> allocator;
|
||||
|
||||
void InitializeGraphPointer(storage::DataLayout &data_layout,
|
||||
void InitializeGraphPointer(const storage::DataLayout &data_layout,
|
||||
char *memory_block,
|
||||
const std::size_t exclude_index)
|
||||
{
|
||||
auto graph_nodes_ptr = data_layout.GetBlockPtr<GraphNode>(
|
||||
memory_block, storage::DataLayout::CH_GRAPH_NODE_LIST);
|
||||
auto graph_nodes_ptr =
|
||||
data_layout.GetBlockPtr<GraphNode>(memory_block, "/ch/contracted_graph/node_array");
|
||||
|
||||
auto graph_edges_ptr = data_layout.GetBlockPtr<GraphEdge>(
|
||||
memory_block, storage::DataLayout::CH_GRAPH_EDGE_LIST);
|
||||
auto graph_edges_ptr =
|
||||
data_layout.GetBlockPtr<GraphEdge>(memory_block, "/ch/contracted_graph/edge_array");
|
||||
|
||||
auto filter_block_id = static_cast<storage::DataLayout::BlockID>(
|
||||
storage::DataLayout::CH_EDGE_FILTER_0 + exclude_index);
|
||||
auto filter_block_id = "/ch/edge_filter/" + std::to_string(exclude_index);
|
||||
|
||||
auto edge_filter_ptr =
|
||||
data_layout.GetBlockPtr<util::vector_view<bool>::Word>(memory_block, filter_block_id);
|
||||
|
||||
util::vector_view<GraphNode> node_list(
|
||||
graph_nodes_ptr, data_layout.GetBlockEntries(storage::DataLayout::CH_GRAPH_NODE_LIST));
|
||||
graph_nodes_ptr, data_layout.GetBlockEntries("/ch/contracted_graph/node_array"));
|
||||
util::vector_view<GraphEdge> edge_list(
|
||||
graph_edges_ptr, data_layout.GetBlockEntries(storage::DataLayout::CH_GRAPH_EDGE_LIST));
|
||||
graph_edges_ptr, data_layout.GetBlockEntries("/ch/contracted_graph/edge_array"));
|
||||
|
||||
util::vector_view<bool> edge_filter(edge_filter_ptr,
|
||||
data_layout.GetBlockEntries(filter_block_id));
|
||||
@@ -115,7 +114,7 @@ class ContiguousInternalMemoryAlgorithmDataFacade<CH> : public datafacade::Algor
|
||||
InitializeInternalPointers(allocator->GetLayout(), allocator->GetMemory(), exclude_index);
|
||||
}
|
||||
|
||||
void InitializeInternalPointers(storage::DataLayout &data_layout,
|
||||
void InitializeInternalPointers(const storage::DataLayout &data_layout,
|
||||
char *memory_block,
|
||||
const std::size_t exclude_index)
|
||||
{
|
||||
@@ -224,29 +223,28 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
// allocator that keeps the allocation data
|
||||
std::shared_ptr<ContiguousBlockAllocator> allocator;
|
||||
|
||||
void InitializeProfilePropertiesPointer(storage::DataLayout &data_layout,
|
||||
void InitializeProfilePropertiesPointer(const storage::DataLayout &data_layout,
|
||||
char *memory_block,
|
||||
const std::size_t exclude_index)
|
||||
{
|
||||
m_profile_properties = data_layout.GetBlockPtr<extractor::ProfileProperties>(
|
||||
memory_block, storage::DataLayout::PROPERTIES);
|
||||
memory_block, "/common/properties");
|
||||
|
||||
exclude_mask = m_profile_properties->excludable_classes[exclude_index];
|
||||
}
|
||||
|
||||
void InitializeChecksumPointer(storage::DataLayout &data_layout, char *memory_block)
|
||||
void InitializeChecksumPointer(const storage::DataLayout &data_layout, char *memory_block)
|
||||
{
|
||||
m_check_sum =
|
||||
*data_layout.GetBlockPtr<unsigned>(memory_block, storage::DataLayout::HSGR_CHECKSUM);
|
||||
m_check_sum = *data_layout.GetBlockPtr<unsigned>(memory_block, "/ch/checksum");
|
||||
util::Log() << "set checksum: " << m_check_sum;
|
||||
}
|
||||
|
||||
void InitializeRTreePointers(storage::DataLayout &data_layout, char *memory_block)
|
||||
void InitializeRTreePointers(const storage::DataLayout &data_layout, char *memory_block)
|
||||
{
|
||||
BOOST_ASSERT_MSG(!m_coordinate_list.empty(), "coordinates must be loaded before r-tree");
|
||||
|
||||
const auto file_index_ptr =
|
||||
data_layout.GetBlockPtr<char>(memory_block, storage::DataLayout::FILE_INDEX_PATH);
|
||||
data_layout.GetBlockPtr<char>(memory_block, "/common/rtree/file_index_path");
|
||||
file_index_path = boost::filesystem::path(file_index_ptr);
|
||||
if (!boost::filesystem::exists(file_index_path))
|
||||
{
|
||||
@@ -256,15 +254,15 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
}
|
||||
|
||||
const auto rtree_ptr =
|
||||
data_layout.GetBlockPtr<RTreeNode>(memory_block, storage::DataLayout::R_SEARCH_TREE);
|
||||
data_layout.GetBlockPtr<RTreeNode>(memory_block, "/common/rtree/search_tree");
|
||||
util::vector_view<RTreeNode> search_tree(
|
||||
rtree_ptr, data_layout.GetBlockEntries(storage::DataLayout::R_SEARCH_TREE));
|
||||
rtree_ptr, data_layout.GetBlockEntries("/common/rtree/search_tree"));
|
||||
|
||||
const auto rtree_levelstarts_ptr = data_layout.GetBlockPtr<std::uint64_t>(
|
||||
memory_block, storage::DataLayout::R_SEARCH_TREE_LEVEL_STARTS);
|
||||
memory_block, "/common/rtree/search_tree_level_starts");
|
||||
util::vector_view<std::uint64_t> rtree_level_starts(
|
||||
rtree_levelstarts_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::R_SEARCH_TREE_LEVEL_STARTS));
|
||||
data_layout.GetBlockEntries("/common/rtree/search_tree_level_starts"));
|
||||
|
||||
m_static_rtree.reset(new SharedRTree{std::move(search_tree),
|
||||
std::move(rtree_level_starts),
|
||||
@@ -274,70 +272,67 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
new SharedGeospatialQuery(*m_static_rtree, m_coordinate_list, *this));
|
||||
}
|
||||
|
||||
void InitializeNodeInformationPointers(storage::DataLayout &layout, char *memory_ptr)
|
||||
void InitializeNodeInformationPointers(const storage::DataLayout &layout, char *memory_ptr)
|
||||
{
|
||||
const auto coordinate_list_ptr =
|
||||
layout.GetBlockPtr<util::Coordinate>(memory_ptr, storage::DataLayout::COORDINATE_LIST);
|
||||
m_coordinate_list.reset(coordinate_list_ptr,
|
||||
layout.GetBlockEntries(storage::DataLayout::COORDINATE_LIST));
|
||||
layout.GetBlockPtr<util::Coordinate>(memory_ptr, "/common/coordinates");
|
||||
m_coordinate_list.reset(coordinate_list_ptr, layout.GetBlockEntries("/common/coordinates"));
|
||||
|
||||
const auto osmnodeid_ptr = layout.GetBlockPtr<extractor::PackedOSMIDsView::block_type>(
|
||||
memory_ptr, storage::DataLayout::OSM_NODE_ID_LIST);
|
||||
memory_ptr, "/common/osm_node_ids/packed");
|
||||
m_osmnodeid_list = extractor::PackedOSMIDsView(
|
||||
util::vector_view<extractor::PackedOSMIDsView::block_type>(
|
||||
osmnodeid_ptr, layout.GetBlockEntries(storage::DataLayout::OSM_NODE_ID_LIST)),
|
||||
osmnodeid_ptr, layout.GetBlockEntries("/common/osm_node_ids/packed")),
|
||||
// We (ab)use the number of coordinates here because we know we have the same amount of
|
||||
// ids
|
||||
layout.GetBlockEntries(storage::DataLayout::COORDINATE_LIST));
|
||||
layout.GetBlockEntries("/common/coordinates"));
|
||||
}
|
||||
|
||||
void InitializeEdgeBasedNodeDataInformationPointers(storage::DataLayout &layout,
|
||||
void InitializeEdgeBasedNodeDataInformationPointers(const storage::DataLayout &layout,
|
||||
char *memory_ptr)
|
||||
{
|
||||
const auto edge_based_node_list_ptr = layout.GetBlockPtr<extractor::EdgeBasedNode>(
|
||||
memory_ptr, storage::DataLayout::EDGE_BASED_NODE_DATA_LIST);
|
||||
const auto edge_based_node_list_ptr =
|
||||
layout.GetBlockPtr<extractor::EdgeBasedNode>(memory_ptr, "/common/ebg_node_data/nodes");
|
||||
util::vector_view<extractor::EdgeBasedNode> edge_based_node_data_list(
|
||||
edge_based_node_list_ptr,
|
||||
layout.GetBlockEntries(storage::DataLayout::EDGE_BASED_NODE_DATA_LIST));
|
||||
edge_based_node_list_ptr, layout.GetBlockEntries("/common/ebg_node_data/nodes"));
|
||||
|
||||
const auto annotation_data_list_ptr =
|
||||
layout.GetBlockPtr<extractor::NodeBasedEdgeAnnotation>(
|
||||
memory_ptr, storage::DataLayout::ANNOTATION_DATA_LIST);
|
||||
memory_ptr, "/common/ebg_node_data/annotations");
|
||||
util::vector_view<extractor::NodeBasedEdgeAnnotation> annotation_data(
|
||||
annotation_data_list_ptr,
|
||||
layout.GetBlockEntries(storage::DataLayout::ANNOTATION_DATA_LIST));
|
||||
annotation_data_list_ptr, layout.GetBlockEntries("/common/ebg_node_data/annotations"));
|
||||
|
||||
edge_based_node_data = extractor::EdgeBasedNodeDataView(
|
||||
std::move(edge_based_node_data_list), std::move(annotation_data));
|
||||
}
|
||||
|
||||
void InitializeEdgeInformationPointers(storage::DataLayout &layout, char *memory_ptr)
|
||||
void InitializeEdgeInformationPointers(const storage::DataLayout &layout, char *memory_ptr)
|
||||
{
|
||||
const auto lane_data_id_ptr =
|
||||
layout.GetBlockPtr<LaneDataID>(memory_ptr, storage::DataLayout::LANE_DATA_ID);
|
||||
layout.GetBlockPtr<LaneDataID>(memory_ptr, "/common/turn_data/lane_data_ids");
|
||||
util::vector_view<LaneDataID> lane_data_ids(
|
||||
lane_data_id_ptr, layout.GetBlockEntries(storage::DataLayout::LANE_DATA_ID));
|
||||
lane_data_id_ptr, layout.GetBlockEntries("/common/turn_data/lane_data_ids"));
|
||||
|
||||
const auto turn_instruction_list_ptr = layout.GetBlockPtr<guidance::TurnInstruction>(
|
||||
memory_ptr, storage::DataLayout::TURN_INSTRUCTION);
|
||||
memory_ptr, "/common/turn_data/turn_instructions");
|
||||
util::vector_view<guidance::TurnInstruction> turn_instructions(
|
||||
turn_instruction_list_ptr,
|
||||
layout.GetBlockEntries(storage::DataLayout::TURN_INSTRUCTION));
|
||||
layout.GetBlockEntries("/common/turn_data/turn_instructions"));
|
||||
|
||||
const auto entry_class_id_list_ptr =
|
||||
layout.GetBlockPtr<EntryClassID>(memory_ptr, storage::DataLayout::ENTRY_CLASSID);
|
||||
layout.GetBlockPtr<EntryClassID>(memory_ptr, "/common/turn_data/entry_class_ids");
|
||||
util::vector_view<EntryClassID> entry_class_ids(
|
||||
entry_class_id_list_ptr, layout.GetBlockEntries(storage::DataLayout::ENTRY_CLASSID));
|
||||
entry_class_id_list_ptr, layout.GetBlockEntries("/common/turn_data/entry_class_ids"));
|
||||
|
||||
const auto pre_turn_bearing_ptr = layout.GetBlockPtr<guidance::TurnBearing>(
|
||||
memory_ptr, storage::DataLayout::PRE_TURN_BEARING);
|
||||
memory_ptr, "/common/turn_data/pre_turn_bearings");
|
||||
util::vector_view<guidance::TurnBearing> pre_turn_bearings(
|
||||
pre_turn_bearing_ptr, layout.GetBlockEntries(storage::DataLayout::PRE_TURN_BEARING));
|
||||
pre_turn_bearing_ptr, layout.GetBlockEntries("/common/turn_data/pre_turn_bearings"));
|
||||
|
||||
const auto post_turn_bearing_ptr = layout.GetBlockPtr<guidance::TurnBearing>(
|
||||
memory_ptr, storage::DataLayout::POST_TURN_BEARING);
|
||||
memory_ptr, "/common/turn_data/post_turn_bearings");
|
||||
util::vector_view<guidance::TurnBearing> post_turn_bearings(
|
||||
post_turn_bearing_ptr, layout.GetBlockEntries(storage::DataLayout::POST_TURN_BEARING));
|
||||
post_turn_bearing_ptr, layout.GetBlockEntries("/common/turn_data/post_turn_bearings"));
|
||||
|
||||
turn_data = guidance::TurnDataView(std::move(turn_instructions),
|
||||
std::move(lane_data_ids),
|
||||
@@ -346,124 +341,120 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
std::move(post_turn_bearings));
|
||||
}
|
||||
|
||||
void InitializeNamePointers(storage::DataLayout &data_layout, char *memory_block)
|
||||
void InitializeNamePointers(const storage::DataLayout &data_layout, char *memory_block)
|
||||
{
|
||||
const auto name_blocks_ptr =
|
||||
data_layout.GetBlockPtr<extractor::NameTableView::IndexedData::BlockReference>(
|
||||
memory_block, storage::DataLayout::NAME_BLOCKS);
|
||||
memory_block, "/common/names/blocks");
|
||||
const auto name_values_ptr =
|
||||
data_layout.GetBlockPtr<extractor::NameTableView::IndexedData::ValueType>(
|
||||
memory_block, storage::DataLayout::NAME_VALUES);
|
||||
memory_block, "/common/names/values");
|
||||
|
||||
util::vector_view<extractor::NameTableView::IndexedData::BlockReference> blocks(
|
||||
name_blocks_ptr, data_layout.GetBlockEntries(storage::DataLayout::NAME_BLOCKS));
|
||||
name_blocks_ptr, data_layout.GetBlockEntries("/common/names/blocks"));
|
||||
util::vector_view<extractor::NameTableView::IndexedData::ValueType> values(
|
||||
name_values_ptr, data_layout.GetBlockEntries(storage::DataLayout::NAME_VALUES));
|
||||
name_values_ptr, data_layout.GetBlockEntries("/common/names/values"));
|
||||
|
||||
extractor::NameTableView::IndexedData index_data_view{std::move(blocks), std::move(values)};
|
||||
m_name_table = extractor::NameTableView{std::move(index_data_view)};
|
||||
}
|
||||
|
||||
void InitializeTurnLaneDescriptionsPointers(storage::DataLayout &data_layout,
|
||||
void InitializeTurnLaneDescriptionsPointers(const storage::DataLayout &data_layout,
|
||||
char *memory_block)
|
||||
{
|
||||
auto offsets_ptr = data_layout.GetBlockPtr<std::uint32_t>(
|
||||
memory_block, storage::DataLayout::LANE_DESCRIPTION_OFFSETS);
|
||||
auto offsets_ptr =
|
||||
data_layout.GetBlockPtr<std::uint32_t>(memory_block, "/common/turn_lanes/offsets");
|
||||
util::vector_view<std::uint32_t> offsets(
|
||||
offsets_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::LANE_DESCRIPTION_OFFSETS));
|
||||
offsets_ptr, data_layout.GetBlockEntries("/common/turn_lanes/offsets"));
|
||||
m_lane_description_offsets = std::move(offsets);
|
||||
|
||||
auto masks_ptr = data_layout.GetBlockPtr<extractor::TurnLaneType::Mask>(
|
||||
memory_block, storage::DataLayout::LANE_DESCRIPTION_MASKS);
|
||||
memory_block, "/common/turn_lanes/masks");
|
||||
|
||||
util::vector_view<extractor::TurnLaneType::Mask> masks(
|
||||
masks_ptr, data_layout.GetBlockEntries(storage::DataLayout::LANE_DESCRIPTION_MASKS));
|
||||
masks_ptr, data_layout.GetBlockEntries("/common/turn_lanes/masks"));
|
||||
m_lane_description_masks = std::move(masks);
|
||||
|
||||
const auto lane_tupel_id_pair_ptr =
|
||||
data_layout.GetBlockPtr<util::guidance::LaneTupleIdPair>(
|
||||
memory_block, storage::DataLayout::TURN_LANE_DATA);
|
||||
data_layout.GetBlockPtr<util::guidance::LaneTupleIdPair>(memory_block,
|
||||
"/common/turn_lanes/data");
|
||||
util::vector_view<util::guidance::LaneTupleIdPair> lane_tupel_id_pair(
|
||||
lane_tupel_id_pair_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::TURN_LANE_DATA));
|
||||
lane_tupel_id_pair_ptr, data_layout.GetBlockEntries("/common/turn_lanes/data"));
|
||||
m_lane_tupel_id_pairs = std::move(lane_tupel_id_pair);
|
||||
}
|
||||
|
||||
void InitializeTurnPenalties(storage::DataLayout &data_layout, char *memory_block)
|
||||
void InitializeTurnPenalties(const storage::DataLayout &data_layout, char *memory_block)
|
||||
{
|
||||
auto turn_weight_penalties_ptr = data_layout.GetBlockPtr<TurnPenalty>(
|
||||
memory_block, storage::DataLayout::TURN_WEIGHT_PENALTIES);
|
||||
auto turn_weight_penalties_ptr =
|
||||
data_layout.GetBlockPtr<TurnPenalty>(memory_block, "/common/turn_penalty/weight");
|
||||
m_turn_weight_penalties = util::vector_view<TurnPenalty>(
|
||||
turn_weight_penalties_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::TURN_WEIGHT_PENALTIES));
|
||||
auto turn_duration_penalties_ptr = data_layout.GetBlockPtr<TurnPenalty>(
|
||||
memory_block, storage::DataLayout::TURN_DURATION_PENALTIES);
|
||||
turn_weight_penalties_ptr, data_layout.GetBlockEntries("/common/turn_penalty/weight"));
|
||||
auto turn_duration_penalties_ptr =
|
||||
data_layout.GetBlockPtr<TurnPenalty>(memory_block, "/common/turn_penalty/duration");
|
||||
m_turn_duration_penalties = util::vector_view<TurnPenalty>(
|
||||
turn_duration_penalties_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::TURN_DURATION_PENALTIES));
|
||||
data_layout.GetBlockEntries("/common/turn_penalty/duration"));
|
||||
}
|
||||
|
||||
void InitializeGeometryPointers(storage::DataLayout &data_layout, char *memory_block)
|
||||
void InitializeGeometryPointers(const storage::DataLayout &data_layout, char *memory_block)
|
||||
{
|
||||
auto geometries_index_ptr =
|
||||
data_layout.GetBlockPtr<unsigned>(memory_block, storage::DataLayout::GEOMETRIES_INDEX);
|
||||
data_layout.GetBlockPtr<unsigned>(memory_block, "/common/segment_data/index");
|
||||
util::vector_view<unsigned> geometry_begin_indices(
|
||||
geometries_index_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::GEOMETRIES_INDEX));
|
||||
geometries_index_ptr, data_layout.GetBlockEntries("/common/segment_data/index"));
|
||||
|
||||
auto num_entries = data_layout.GetBlockEntries(storage::DataLayout::GEOMETRIES_NODE_LIST);
|
||||
auto geometries_node_list_ptr = data_layout.GetBlockPtr<NodeID>(
|
||||
memory_block, storage::DataLayout::GEOMETRIES_NODE_LIST);
|
||||
auto num_entries = data_layout.GetBlockEntries("/common/segment_data/nodes");
|
||||
auto geometries_node_list_ptr =
|
||||
data_layout.GetBlockPtr<NodeID>(memory_block, "/common/segment_data/nodes");
|
||||
util::vector_view<NodeID> geometry_node_list(geometries_node_list_ptr, num_entries);
|
||||
|
||||
auto geometries_fwd_weight_list_ptr =
|
||||
data_layout.GetBlockPtr<extractor::SegmentDataView::SegmentWeightVector::block_type>(
|
||||
memory_block, storage::DataLayout::GEOMETRIES_FWD_WEIGHT_LIST);
|
||||
memory_block, "/common/segment_data/forward_weights/packed");
|
||||
extractor::SegmentDataView::SegmentWeightVector geometry_fwd_weight_list(
|
||||
util::vector_view<extractor::SegmentDataView::SegmentWeightVector::block_type>(
|
||||
geometries_fwd_weight_list_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::GEOMETRIES_FWD_WEIGHT_LIST)),
|
||||
data_layout.GetBlockEntries("/common/segment_data/forward_weights/packed")),
|
||||
num_entries);
|
||||
|
||||
auto geometries_rev_weight_list_ptr =
|
||||
data_layout.GetBlockPtr<extractor::SegmentDataView::SegmentWeightVector::block_type>(
|
||||
memory_block, storage::DataLayout::GEOMETRIES_REV_WEIGHT_LIST);
|
||||
memory_block, "/common/segment_data/reverse_weights/packed");
|
||||
extractor::SegmentDataView::SegmentWeightVector geometry_rev_weight_list(
|
||||
util::vector_view<extractor::SegmentDataView::SegmentWeightVector::block_type>(
|
||||
geometries_rev_weight_list_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::GEOMETRIES_REV_WEIGHT_LIST)),
|
||||
data_layout.GetBlockEntries("/common/segment_data/reverse_weights/packed")),
|
||||
num_entries);
|
||||
|
||||
auto geometries_fwd_duration_list_ptr =
|
||||
data_layout.GetBlockPtr<extractor::SegmentDataView::SegmentDurationVector::block_type>(
|
||||
memory_block, storage::DataLayout::GEOMETRIES_FWD_DURATION_LIST);
|
||||
memory_block, "/common/segment_data/forward_durations/packed");
|
||||
extractor::SegmentDataView::SegmentDurationVector geometry_fwd_duration_list(
|
||||
util::vector_view<extractor::SegmentDataView::SegmentDurationVector::block_type>(
|
||||
geometries_fwd_duration_list_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::GEOMETRIES_FWD_DURATION_LIST)),
|
||||
data_layout.GetBlockEntries("/common/segment_data/forward_durations/packed")),
|
||||
num_entries);
|
||||
|
||||
auto geometries_rev_duration_list_ptr =
|
||||
data_layout.GetBlockPtr<extractor::SegmentDataView::SegmentDurationVector::block_type>(
|
||||
memory_block, storage::DataLayout::GEOMETRIES_REV_DURATION_LIST);
|
||||
memory_block, "/common/segment_data/reverse_durations/packed");
|
||||
extractor::SegmentDataView::SegmentDurationVector geometry_rev_duration_list(
|
||||
util::vector_view<extractor::SegmentDataView::SegmentDurationVector::block_type>(
|
||||
geometries_rev_duration_list_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::GEOMETRIES_REV_DURATION_LIST)),
|
||||
data_layout.GetBlockEntries("/common/segment_data/reverse_durations/packed")),
|
||||
num_entries);
|
||||
|
||||
auto geometries_fwd_datasources_list_ptr = data_layout.GetBlockPtr<DatasourceID>(
|
||||
memory_block, storage::DataLayout::GEOMETRIES_FWD_DATASOURCES_LIST);
|
||||
memory_block, "/common/segment_data/forward_data_sources");
|
||||
util::vector_view<DatasourceID> geometry_fwd_datasources_list(
|
||||
geometries_fwd_datasources_list_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::GEOMETRIES_FWD_DATASOURCES_LIST));
|
||||
data_layout.GetBlockEntries("/common/segment_data/forward_data_sources"));
|
||||
|
||||
auto geometries_rev_datasources_list_ptr = data_layout.GetBlockPtr<DatasourceID>(
|
||||
memory_block, storage::DataLayout::GEOMETRIES_REV_DATASOURCES_LIST);
|
||||
memory_block, "/common/segment_data/reverse_data_sources");
|
||||
util::vector_view<DatasourceID> geometry_rev_datasources_list(
|
||||
geometries_rev_datasources_list_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::GEOMETRIES_REV_DATASOURCES_LIST));
|
||||
data_layout.GetBlockEntries("/common/segment_data/reverse_data_sources"));
|
||||
|
||||
segment_data = extractor::SegmentDataView{std::move(geometry_begin_indices),
|
||||
std::move(geometry_node_list),
|
||||
@@ -475,30 +466,36 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
std::move(geometry_rev_datasources_list)};
|
||||
|
||||
m_datasources = data_layout.GetBlockPtr<extractor::Datasources>(
|
||||
memory_block, storage::DataLayout::DATASOURCES_NAMES);
|
||||
memory_block, "/common/data_sources_names");
|
||||
}
|
||||
|
||||
void InitializeIntersectionClassPointers(storage::DataLayout &data_layout, char *memory_block)
|
||||
void InitializeIntersectionClassPointers(const storage::DataLayout &data_layout,
|
||||
char *memory_block)
|
||||
{
|
||||
auto bearing_class_id_ptr = data_layout.GetBlockPtr<BearingClassID>(
|
||||
memory_block, storage::DataLayout::BEARING_CLASSID);
|
||||
memory_block, "/common/intersection_bearings/node_to_class_id");
|
||||
util::vector_view<BearingClassID> bearing_class_id(
|
||||
bearing_class_id_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::BEARING_CLASSID));
|
||||
data_layout.GetBlockEntries("/common/intersection_bearings/node_to_class_id"));
|
||||
|
||||
auto bearing_values_ptr = data_layout.GetBlockPtr<DiscreteBearing>(
|
||||
memory_block, storage::DataLayout::BEARING_VALUES);
|
||||
memory_block, "/common/intersection_bearings/bearing_values");
|
||||
util::vector_view<DiscreteBearing> bearing_values(
|
||||
bearing_values_ptr, data_layout.GetBlockEntries(storage::DataLayout::BEARING_VALUES));
|
||||
bearing_values_ptr,
|
||||
data_layout.GetBlockEntries("/common/intersection_bearings/bearing_values"));
|
||||
|
||||
auto offsets_ptr =
|
||||
data_layout.GetBlockPtr<unsigned>(memory_block, storage::DataLayout::BEARING_OFFSETS);
|
||||
auto blocks_ptr =
|
||||
data_layout.GetBlockPtr<IndexBlock>(memory_block, storage::DataLayout::BEARING_BLOCKS);
|
||||
auto offsets_ptr = data_layout.GetBlockPtr<unsigned>(
|
||||
memory_block, "/common/intersection_bearings/class_id_to_ranges/block_offsets");
|
||||
auto blocks_ptr = data_layout.GetBlockPtr<IndexBlock>(
|
||||
memory_block, "/common/intersection_bearings/class_id_to_ranges/diff_blocks");
|
||||
util::vector_view<unsigned> bearing_offsets(
|
||||
offsets_ptr, data_layout.GetBlockEntries(storage::DataLayout::BEARING_OFFSETS));
|
||||
offsets_ptr,
|
||||
data_layout.GetBlockEntries(
|
||||
"/common/intersection_bearings/class_id_to_ranges/block_offsets"));
|
||||
util::vector_view<IndexBlock> bearing_blocks(
|
||||
blocks_ptr, data_layout.GetBlockEntries(storage::DataLayout::BEARING_BLOCKS));
|
||||
blocks_ptr,
|
||||
data_layout.GetBlockEntries(
|
||||
"/common/intersection_bearings/class_id_to_ranges/diff_blocks"));
|
||||
|
||||
util::RangeTable<16, storage::Ownership::View> bearing_range_table(
|
||||
bearing_offsets, bearing_blocks, static_cast<unsigned>(bearing_values.size()));
|
||||
@@ -507,28 +504,29 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
std::move(bearing_values), std::move(bearing_class_id), std::move(bearing_range_table)};
|
||||
|
||||
auto entry_class_ptr = data_layout.GetBlockPtr<util::guidance::EntryClass>(
|
||||
memory_block, storage::DataLayout::ENTRY_CLASS);
|
||||
memory_block, "/common/entry_classes");
|
||||
util::vector_view<util::guidance::EntryClass> entry_class_table(
|
||||
entry_class_ptr, data_layout.GetBlockEntries(storage::DataLayout::ENTRY_CLASS));
|
||||
entry_class_ptr, data_layout.GetBlockEntries("/common/entry_classes"));
|
||||
m_entry_class_table = std::move(entry_class_table);
|
||||
}
|
||||
|
||||
void InitializeManeuverOverridePointers(storage::DataLayout &data_layout, char *memory_block)
|
||||
void InitializeManeuverOverridePointers(const storage::DataLayout &data_layout,
|
||||
char *memory_block)
|
||||
{
|
||||
auto maneuver_overrides_ptr = data_layout.GetBlockPtr<extractor::StorageManeuverOverride>(
|
||||
memory_block, storage::DataLayout::MANEUVER_OVERRIDES);
|
||||
memory_block, "/common/maneuver_overrides/overrides");
|
||||
m_maneuver_overrides = util::vector_view<extractor::StorageManeuverOverride>(
|
||||
maneuver_overrides_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::MANEUVER_OVERRIDES));
|
||||
data_layout.GetBlockEntries("/common/maneuver_overrides/overrides"));
|
||||
|
||||
auto maneuver_override_node_sequences_ptr = data_layout.GetBlockPtr<NodeID>(
|
||||
memory_block, storage::DataLayout::MANEUVER_OVERRIDE_NODE_SEQUENCES);
|
||||
memory_block, "/common/maneuver_overrides/node_sequences");
|
||||
m_maneuver_override_node_sequences = util::vector_view<NodeID>(
|
||||
maneuver_override_node_sequences_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::MANEUVER_OVERRIDE_NODE_SEQUENCES));
|
||||
data_layout.GetBlockEntries("/common/maneuver_overrides/node_sequences"));
|
||||
}
|
||||
|
||||
void InitializeInternalPointers(storage::DataLayout &data_layout,
|
||||
void InitializeInternalPointers(const storage::DataLayout &data_layout,
|
||||
char *memory_block,
|
||||
const std::size_t exclude_index)
|
||||
{
|
||||
@@ -939,7 +937,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
auto found_range = std::equal_range(
|
||||
m_maneuver_overrides.begin(), m_maneuver_overrides.end(), edge_based_node_id, Comp{});
|
||||
|
||||
std::for_each(found_range.first, found_range.second, [&](const auto & override) {
|
||||
std::for_each(found_range.first, found_range.second, [&](const auto &override) {
|
||||
std::vector<NodeID> sequence(
|
||||
m_maneuver_override_node_sequences.begin() + override.node_sequence_offset_begin,
|
||||
m_maneuver_override_node_sequences.begin() + override.node_sequence_offset_end);
|
||||
@@ -981,7 +979,7 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public Algo
|
||||
|
||||
QueryGraph query_graph;
|
||||
|
||||
void InitializeInternalPointers(storage::DataLayout &data_layout,
|
||||
void InitializeInternalPointers(const storage::DataLayout &data_layout,
|
||||
char *memory_block,
|
||||
const std::size_t exclude_index)
|
||||
{
|
||||
@@ -989,39 +987,38 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public Algo
|
||||
InitializeGraphPointer(data_layout, memory_block);
|
||||
}
|
||||
|
||||
void InitializeMLDDataPointers(storage::DataLayout &data_layout,
|
||||
void InitializeMLDDataPointers(const storage::DataLayout &data_layout,
|
||||
char *memory_block,
|
||||
const std::size_t exclude_index)
|
||||
{
|
||||
if (data_layout.GetBlockSize(storage::DataLayout::MLD_PARTITION) > 0)
|
||||
if (data_layout.GetBlockSize("/mld/multilevelpartition/partition") > 0)
|
||||
{
|
||||
BOOST_ASSERT(data_layout.GetBlockSize(storage::DataLayout::MLD_LEVEL_DATA) > 0);
|
||||
BOOST_ASSERT(data_layout.GetBlockSize(storage::DataLayout::MLD_CELL_TO_CHILDREN) > 0);
|
||||
BOOST_ASSERT(data_layout.GetBlockSize("/mld/multilevelpartition/level_data") > 0);
|
||||
BOOST_ASSERT(data_layout.GetBlockSize("/mld/multilevelpartition/cell_to_children") > 0);
|
||||
|
||||
auto level_data =
|
||||
data_layout.GetBlockPtr<partitioner::MultiLevelPartitionView::LevelData>(
|
||||
memory_block, storage::DataLayout::MLD_LEVEL_DATA);
|
||||
memory_block, "/mld/multilevelpartition/level_data");
|
||||
|
||||
auto mld_partition_ptr = data_layout.GetBlockPtr<PartitionID>(
|
||||
memory_block, storage::DataLayout::MLD_PARTITION);
|
||||
memory_block, "/mld/multilevelpartition/partition");
|
||||
auto partition_entries_count =
|
||||
data_layout.GetBlockEntries(storage::DataLayout::MLD_PARTITION);
|
||||
data_layout.GetBlockEntries("/mld/multilevelpartition/partition");
|
||||
util::vector_view<PartitionID> partition(mld_partition_ptr, partition_entries_count);
|
||||
|
||||
auto mld_chilren_ptr = data_layout.GetBlockPtr<CellID>(
|
||||
memory_block, storage::DataLayout::MLD_CELL_TO_CHILDREN);
|
||||
memory_block, "/mld/multilevelpartition/cell_to_children");
|
||||
auto children_entries_count =
|
||||
data_layout.GetBlockEntries(storage::DataLayout::MLD_CELL_TO_CHILDREN);
|
||||
data_layout.GetBlockEntries("/mld/multilevelpartition/cell_to_children");
|
||||
util::vector_view<CellID> cell_to_children(mld_chilren_ptr, children_entries_count);
|
||||
|
||||
mld_partition =
|
||||
partitioner::MultiLevelPartitionView{level_data, partition, cell_to_children};
|
||||
}
|
||||
|
||||
const auto weights_block_id = static_cast<storage::DataLayout::BlockID>(
|
||||
storage::DataLayout::MLD_CELL_WEIGHTS_0 + exclude_index);
|
||||
const auto durations_block_id = static_cast<storage::DataLayout::BlockID>(
|
||||
storage::DataLayout::MLD_CELL_DURATIONS_0 + exclude_index);
|
||||
const auto weights_block_id = "/mld/metrics/" + std::to_string(exclude_index) + "/weights";
|
||||
const auto durations_block_id =
|
||||
"/mld/metrics/" + std::to_string(exclude_index) + "/durations";
|
||||
|
||||
if (data_layout.GetBlockSize(weights_block_id) > 0)
|
||||
{
|
||||
@@ -1029,10 +1026,8 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public Algo
|
||||
data_layout.GetBlockPtr<EdgeWeight>(memory_block, weights_block_id);
|
||||
auto mld_cell_durations_ptr =
|
||||
data_layout.GetBlockPtr<EdgeDuration>(memory_block, durations_block_id);
|
||||
auto weight_entries_count =
|
||||
data_layout.GetBlockEntries(storage::DataLayout::MLD_CELL_WEIGHTS_0);
|
||||
auto duration_entries_count =
|
||||
data_layout.GetBlockEntries(storage::DataLayout::MLD_CELL_DURATIONS_0);
|
||||
auto weight_entries_count = data_layout.GetBlockEntries("/mld/metrics/0/weights");
|
||||
auto duration_entries_count = data_layout.GetBlockEntries("/mld/metrics/0/durations");
|
||||
BOOST_ASSERT(weight_entries_count == duration_entries_count);
|
||||
util::vector_view<EdgeWeight> weights(mld_cell_weights_ptr, weight_entries_count);
|
||||
util::vector_view<EdgeDuration> durations(mld_cell_durations_ptr,
|
||||
@@ -1041,25 +1036,25 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public Algo
|
||||
mld_cell_metric = customizer::CellMetricView{std::move(weights), std::move(durations)};
|
||||
}
|
||||
|
||||
if (data_layout.GetBlockSize(storage::DataLayout::MLD_CELLS) > 0)
|
||||
if (data_layout.GetBlockSize("/mld/cellstorage/cells") > 0)
|
||||
{
|
||||
|
||||
auto mld_source_boundary_ptr = data_layout.GetBlockPtr<NodeID>(
|
||||
memory_block, storage::DataLayout::MLD_CELL_SOURCE_BOUNDARY);
|
||||
auto mld_source_boundary_ptr =
|
||||
data_layout.GetBlockPtr<NodeID>(memory_block, "/mld/cellstorage/source_boundary");
|
||||
auto mld_destination_boundary_ptr = data_layout.GetBlockPtr<NodeID>(
|
||||
memory_block, storage::DataLayout::MLD_CELL_DESTINATION_BOUNDARY);
|
||||
memory_block, "/mld/cellstorage/destination_boundary");
|
||||
auto mld_cells_ptr = data_layout.GetBlockPtr<partitioner::CellStorageView::CellData>(
|
||||
memory_block, storage::DataLayout::MLD_CELLS);
|
||||
memory_block, "/mld/cellstorage/cells");
|
||||
auto mld_cell_level_offsets_ptr = data_layout.GetBlockPtr<std::uint64_t>(
|
||||
memory_block, storage::DataLayout::MLD_CELL_LEVEL_OFFSETS);
|
||||
memory_block, "/mld/cellstorage/level_to_cell_offset");
|
||||
|
||||
auto source_boundary_entries_count =
|
||||
data_layout.GetBlockEntries(storage::DataLayout::MLD_CELL_SOURCE_BOUNDARY);
|
||||
data_layout.GetBlockEntries("/mld/cellstorage/source_boundary");
|
||||
auto destination_boundary_entries_count =
|
||||
data_layout.GetBlockEntries(storage::DataLayout::MLD_CELL_DESTINATION_BOUNDARY);
|
||||
auto cells_entries_counts = data_layout.GetBlockEntries(storage::DataLayout::MLD_CELLS);
|
||||
data_layout.GetBlockEntries("/mld/cellstorage/destination_boundary");
|
||||
auto cells_entries_counts = data_layout.GetBlockEntries("/mld/cellstorage/cells");
|
||||
auto cell_level_offsets_entries_count =
|
||||
data_layout.GetBlockEntries(storage::DataLayout::MLD_CELL_LEVEL_OFFSETS);
|
||||
data_layout.GetBlockEntries("/mld/cellstorage/level_to_cell_offset");
|
||||
|
||||
util::vector_view<NodeID> source_boundary(mld_source_boundary_ptr,
|
||||
source_boundary_entries_count);
|
||||
@@ -1076,24 +1071,24 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public Algo
|
||||
std::move(level_offsets)};
|
||||
}
|
||||
}
|
||||
void InitializeGraphPointer(storage::DataLayout &data_layout, char *memory_block)
|
||||
void InitializeGraphPointer(const storage::DataLayout &data_layout, char *memory_block)
|
||||
{
|
||||
auto graph_nodes_ptr = data_layout.GetBlockPtr<GraphNode>(
|
||||
memory_block, storage::DataLayout::MLD_GRAPH_NODE_LIST);
|
||||
auto graph_nodes_ptr =
|
||||
data_layout.GetBlockPtr<GraphNode>(memory_block, "/mld/multilevelgraph/node_array");
|
||||
|
||||
auto graph_edges_ptr = data_layout.GetBlockPtr<GraphEdge>(
|
||||
memory_block, storage::DataLayout::MLD_GRAPH_EDGE_LIST);
|
||||
auto graph_edges_ptr =
|
||||
data_layout.GetBlockPtr<GraphEdge>(memory_block, "/mld/multilevelgraph/edge_array");
|
||||
|
||||
auto graph_node_to_offset_ptr = data_layout.GetBlockPtr<QueryGraph::EdgeOffset>(
|
||||
memory_block, storage::DataLayout::MLD_GRAPH_NODE_TO_OFFSET);
|
||||
memory_block, "/mld/multilevelgraph/node_to_edge_offset");
|
||||
|
||||
util::vector_view<GraphNode> node_list(
|
||||
graph_nodes_ptr, data_layout.GetBlockEntries(storage::DataLayout::MLD_GRAPH_NODE_LIST));
|
||||
graph_nodes_ptr, data_layout.GetBlockEntries("/mld/multilevelgraph/node_array"));
|
||||
util::vector_view<GraphEdge> edge_list(
|
||||
graph_edges_ptr, data_layout.GetBlockEntries(storage::DataLayout::MLD_GRAPH_EDGE_LIST));
|
||||
graph_edges_ptr, data_layout.GetBlockEntries("/mld/multilevelgraph/edge_array"));
|
||||
util::vector_view<QueryGraph::EdgeOffset> node_to_offset(
|
||||
graph_node_to_offset_ptr,
|
||||
data_layout.GetBlockEntries(storage::DataLayout::MLD_GRAPH_NODE_TO_OFFSET));
|
||||
data_layout.GetBlockEntries("/mld/multilevelgraph/node_to_edge_offset"));
|
||||
|
||||
query_graph =
|
||||
QueryGraph(std::move(node_list), std::move(edge_list), std::move(node_to_offset));
|
||||
|
||||
@@ -27,12 +27,12 @@ class ProcessMemoryAllocator : public ContiguousBlockAllocator
|
||||
~ProcessMemoryAllocator() override final;
|
||||
|
||||
// interface to give access to the datafacades
|
||||
storage::DataLayout &GetLayout() override final;
|
||||
const storage::DataLayout &GetLayout() override final;
|
||||
char *GetMemory() override final;
|
||||
|
||||
private:
|
||||
storage::DataLayout internal_layout;
|
||||
std::unique_ptr<char[]> internal_memory;
|
||||
std::unique_ptr<storage::DataLayout> internal_layout;
|
||||
};
|
||||
|
||||
} // namespace datafacade
|
||||
|
||||
@@ -27,10 +27,12 @@ class SharedMemoryAllocator : public ContiguousBlockAllocator
|
||||
~SharedMemoryAllocator() override final;
|
||||
|
||||
// interface to give access to the datafacades
|
||||
storage::DataLayout &GetLayout() override final;
|
||||
const storage::DataLayout &GetLayout() override final;
|
||||
char *GetMemory() override final;
|
||||
|
||||
private:
|
||||
std::size_t layout_size;
|
||||
storage::DataLayout data_layout;
|
||||
std::unique_ptr<storage::SharedMemory> m_large_memory;
|
||||
};
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ template <template <typename A> class FacadeT, typename AlgorithmT> class DataFa
|
||||
}
|
||||
|
||||
properties = allocator->GetLayout().template GetBlockPtr<extractor::ProfileProperties>(
|
||||
allocator->GetMemory(), storage::DataLayout::PROPERTIES);
|
||||
allocator->GetMemory(), "/common/properties");
|
||||
|
||||
for (const auto index : util::irange<std::size_t>(0, properties->class_names.size()))
|
||||
{
|
||||
|
||||
+13
-13
@@ -152,8 +152,8 @@ bool Engine<routing_algorithms::ch::Algorithm>::CheckCompatibility(const EngineC
|
||||
|
||||
auto mem = storage::makeSharedMemory(barrier.data().region);
|
||||
auto layout = reinterpret_cast<storage::DataLayout *>(mem->Ptr());
|
||||
return layout->GetBlockSize(storage::DataLayout::CH_GRAPH_NODE_LIST) > 4 &&
|
||||
layout->GetBlockSize(storage::DataLayout::CH_GRAPH_EDGE_LIST) > 4;
|
||||
return layout->GetBlockSize("/ch/contracted_graph/node_array") > 4 &&
|
||||
layout->GetBlockSize("/ch/contracted_graph/edge_array") > 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -173,19 +173,19 @@ bool Engine<routing_algorithms::mld::Algorithm>::CheckCompatibility(const Engine
|
||||
auto mem = storage::makeSharedMemory(barrier.data().region);
|
||||
auto layout = reinterpret_cast<storage::DataLayout *>(mem->Ptr());
|
||||
// checks that all the needed memory blocks are populated
|
||||
// DataLayout::MLD_CELL_SOURCE_BOUNDARY and DataLayout::MLD_CELL_DESTINATION_BOUNDARY
|
||||
// "/mld/cellstorage/source_boundary" and "/mld/cellstorage/destination_boundary"
|
||||
// are not checked, because in situations where there are so few nodes in the graph that
|
||||
// they all fit into one cell, they can be empty.
|
||||
bool empty_data = layout->GetBlockSize(storage::DataLayout::MLD_LEVEL_DATA) > 0 &&
|
||||
layout->GetBlockSize(storage::DataLayout::MLD_PARTITION) > 0 &&
|
||||
layout->GetBlockSize(storage::DataLayout::MLD_CELL_TO_CHILDREN) > 0 &&
|
||||
layout->GetBlockSize(storage::DataLayout::MLD_CELLS) > 0 &&
|
||||
layout->GetBlockSize(storage::DataLayout::MLD_CELL_LEVEL_OFFSETS) > 0 &&
|
||||
layout->GetBlockSize(storage::DataLayout::MLD_GRAPH_NODE_LIST) > 0 &&
|
||||
layout->GetBlockSize(storage::DataLayout::MLD_GRAPH_EDGE_LIST) > 0 &&
|
||||
layout->GetBlockSize(storage::DataLayout::MLD_CELL_WEIGHTS_0) > 0 &&
|
||||
layout->GetBlockSize(storage::DataLayout::MLD_CELL_DURATIONS_0) > 0 &&
|
||||
layout->GetBlockSize(storage::DataLayout::MLD_GRAPH_NODE_TO_OFFSET) > 0;
|
||||
bool empty_data = layout->GetBlockSize("/mld/multilevelpartition/level_data") > 0 &&
|
||||
layout->GetBlockSize("/mld/multilevelpartition/partition") > 0 &&
|
||||
layout->GetBlockSize("/mld/multilevelpartition/cell_to_children") > 0 &&
|
||||
layout->GetBlockSize("/mld/cellstorage/cells") > 0 &&
|
||||
layout->GetBlockSize("/mld/cellstorage/level_to_cell_offset") > 0 &&
|
||||
layout->GetBlockSize("/mld/multilevelgraph/node_array") > 0 &&
|
||||
layout->GetBlockSize("/mld/multilevelgraph/edge_array") > 0 &&
|
||||
layout->GetBlockSize("/mld/metrics/0/weights") > 0 &&
|
||||
layout->GetBlockSize("/mld/metrics/0/durations") > 0 &&
|
||||
layout->GetBlockSize("/mld/multilevelgraph/node_to_edge_offset") > 0;
|
||||
return empty_data;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -303,6 +303,10 @@ class BufferReader
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t GetPosition() {
|
||||
return input_stream.tellg();
|
||||
}
|
||||
|
||||
template <typename T> void ReadInto(T *dest, const std::size_t count)
|
||||
{
|
||||
#if !defined(__GNUC__) || (__GNUC__ > 4)
|
||||
|
||||
@@ -7,12 +7,14 @@
|
||||
|
||||
#include "storage/io.hpp"
|
||||
#include "storage/tar.hpp"
|
||||
#include "storage/shared_datatype.hpp"
|
||||
|
||||
#include <boost/function_output_iterator.hpp>
|
||||
#include <boost/iterator/function_input_iterator.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <tuple>
|
||||
|
||||
#if USE_STXXL_LIBRARY
|
||||
#include <stxxl/vector>
|
||||
@@ -81,6 +83,32 @@ template <typename T> void write(io::BufferWriter &writer, const std::vector<T>
|
||||
writer.WriteFrom(data.data(), count);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void write(io::BufferWriter &writer, const T &data)
|
||||
{
|
||||
writer.WriteFrom(data);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void read(io::BufferReader &reader, T &data)
|
||||
{
|
||||
reader.ReadInto(data);
|
||||
}
|
||||
|
||||
inline void write(io::BufferWriter &writer, const std::string &data)
|
||||
{
|
||||
const auto count = data.size();
|
||||
writer.WriteElementCount64(count);
|
||||
writer.WriteFrom(data.data(), count);
|
||||
}
|
||||
|
||||
inline void read(io::BufferReader &reader, std::string &data)
|
||||
{
|
||||
const auto count = reader.ReadElementCount64();
|
||||
data.resize(count);
|
||||
reader.ReadInto(const_cast<char *>(data.data()), count);
|
||||
}
|
||||
|
||||
inline void write(tar::FileWriter &writer, const std::string &name, const std::string &data)
|
||||
{
|
||||
const auto count = data.size();
|
||||
@@ -218,6 +246,42 @@ write<bool>(tar::FileWriter &writer, const std::string &name, const std::vector<
|
||||
{
|
||||
detail::writeBoolVector(writer, name, data);
|
||||
}
|
||||
|
||||
template <typename K, typename V> void read(io::BufferReader &reader, std::map<K, V> &data)
|
||||
{
|
||||
const auto count = reader.ReadElementCount64();
|
||||
std::pair<K, V> pair;
|
||||
for (auto index : util::irange<std::size_t>(0, count))
|
||||
{
|
||||
(void) index;
|
||||
read(reader, pair.first);
|
||||
read(reader, pair.second);
|
||||
data.insert(pair);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename K, typename V> void write(io::BufferWriter &writer, const std::map<K, V> &data)
|
||||
{
|
||||
const auto count = data.size();
|
||||
writer.WriteElementCount64(count);
|
||||
for (const auto &pair : data)
|
||||
{
|
||||
write(writer, pair.first);
|
||||
write(writer, pair.second);
|
||||
}
|
||||
}
|
||||
|
||||
inline void read(io::BufferReader &reader, DataLayout &layout)
|
||||
{
|
||||
read(reader, layout.blocks);
|
||||
}
|
||||
|
||||
inline void write(io::BufferWriter &writer, const DataLayout &layout)
|
||||
{
|
||||
write(writer, layout.blocks);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define SHARED_DATA_TYPE_HPP
|
||||
|
||||
#include "storage/block.hpp"
|
||||
#include "storage/io_fwd.hpp"
|
||||
|
||||
#include "util/exception.hpp"
|
||||
#include "util/exception_utils.hpp"
|
||||
@@ -11,219 +12,91 @@
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace storage
|
||||
{
|
||||
|
||||
class DataLayout;
|
||||
namespace serialization
|
||||
{
|
||||
inline void read(io::BufferReader &reader, DataLayout &layout);
|
||||
|
||||
inline void write(io::BufferWriter &writer, const DataLayout &layout);
|
||||
}
|
||||
|
||||
// Added at the start and end of each block as sanity check
|
||||
const constexpr char CANARY[4] = {'O', 'S', 'R', 'M'};
|
||||
|
||||
const constexpr char *block_id_to_name[] = {"IGNORE_BLOCK",
|
||||
"NAME_BLOCKS",
|
||||
"NAME_VALUES",
|
||||
"EDGE_BASED_NODE_DATA",
|
||||
"ANNOTATION_DATA",
|
||||
"CH_GRAPH_NODE_LIST",
|
||||
"CH_GRAPH_EDGE_LIST",
|
||||
"CH_EDGE_FILTER_0",
|
||||
"CH_EDGE_FILTER_1",
|
||||
"CH_EDGE_FILTER_2",
|
||||
"CH_EDGE_FILTER_3",
|
||||
"CH_EDGE_FILTER_4",
|
||||
"CH_EDGE_FILTER_5",
|
||||
"CH_EDGE_FILTER_6",
|
||||
"CH_EDGE_FILTER_7",
|
||||
"COORDINATE_LIST",
|
||||
"OSM_NODE_ID_LIST",
|
||||
"TURN_INSTRUCTION",
|
||||
"ENTRY_CLASSID",
|
||||
"R_SEARCH_TREE",
|
||||
"R_SEARCH_TREE_LEVEL_STARTS",
|
||||
"GEOMETRIES_INDEX",
|
||||
"GEOMETRIES_NODE_LIST",
|
||||
"GEOMETRIES_FWD_WEIGHT_LIST",
|
||||
"GEOMETRIES_REV_WEIGHT_LIST",
|
||||
"GEOMETRIES_FWD_DURATION_LIST",
|
||||
"GEOMETRIES_REV_DURATION_LIST",
|
||||
"GEOMETRIES_FWD_DATASOURCES_LIST",
|
||||
"GEOMETRIES_REV_DATASOURCES_LIST",
|
||||
"HSGR_CHECKSUM",
|
||||
"FILE_INDEX_PATH",
|
||||
"DATASOURCES_NAMES",
|
||||
"PROPERTIES",
|
||||
"BEARING_CLASSID",
|
||||
"BEARING_OFFSETS",
|
||||
"BEARING_BLOCKS",
|
||||
"BEARING_VALUES",
|
||||
"ENTRY_CLASS",
|
||||
"LANE_DATA_ID",
|
||||
"PRE_TURN_BEARING",
|
||||
"POST_TURN_BEARING",
|
||||
"TURN_LANE_DATA",
|
||||
"LANE_DESCRIPTION_OFFSETS",
|
||||
"LANE_DESCRIPTION_MASKS",
|
||||
"TURN_WEIGHT_PENALTIES",
|
||||
"TURN_DURATION_PENALTIES",
|
||||
"MLD_LEVEL_DATA",
|
||||
"MLD_PARTITION",
|
||||
"MLD_CELL_TO_CHILDREN",
|
||||
"MLD_CELL_WEIGHTS_0",
|
||||
"MLD_CELL_WEIGHTS_1",
|
||||
"MLD_CELL_WEIGHTS_2",
|
||||
"MLD_CELL_WEIGHTS_3",
|
||||
"MLD_CELL_WEIGHTS_4",
|
||||
"MLD_CELL_WEIGHTS_5",
|
||||
"MLD_CELL_WEIGHTS_6",
|
||||
"MLD_CELL_WEIGHTS_7",
|
||||
"MLD_CELL_DURATIONS_0",
|
||||
"MLD_CELL_DURATIONS_1",
|
||||
"MLD_CELL_DURATIONS_2",
|
||||
"MLD_CELL_DURATIONS_3",
|
||||
"MLD_CELL_DURATIONS_4",
|
||||
"MLD_CELL_DURATIONS_5",
|
||||
"MLD_CELL_DURATIONS_6",
|
||||
"MLD_CELL_DURATIONS_7",
|
||||
"MLD_CELL_SOURCE_BOUNDARY",
|
||||
"MLD_CELL_DESTINATION_BOUNDARY",
|
||||
"MLD_CELLS",
|
||||
"MLD_CELL_LEVEL_OFFSETS",
|
||||
"MLD_GRAPH_NODE_LIST",
|
||||
"MLD_GRAPH_EDGE_LIST",
|
||||
"MLD_GRAPH_NODE_TO_OFFSET",
|
||||
"MANEUVER_OVERRIDES",
|
||||
"MANEUVER_OVERRIDE_NODE_SEQUENCES"};
|
||||
|
||||
class DataLayout
|
||||
{
|
||||
public:
|
||||
enum BlockID
|
||||
{
|
||||
IGNORE_BLOCK = 0,
|
||||
NAME_BLOCKS,
|
||||
NAME_VALUES,
|
||||
EDGE_BASED_NODE_DATA_LIST,
|
||||
ANNOTATION_DATA_LIST,
|
||||
CH_GRAPH_NODE_LIST,
|
||||
CH_GRAPH_EDGE_LIST,
|
||||
CH_EDGE_FILTER_0,
|
||||
CH_EDGE_FILTER_1,
|
||||
CH_EDGE_FILTER_2,
|
||||
CH_EDGE_FILTER_3,
|
||||
CH_EDGE_FILTER_4,
|
||||
CH_EDGE_FILTER_5,
|
||||
CH_EDGE_FILTER_6,
|
||||
CH_EDGE_FILTER_7,
|
||||
COORDINATE_LIST,
|
||||
OSM_NODE_ID_LIST,
|
||||
TURN_INSTRUCTION,
|
||||
ENTRY_CLASSID,
|
||||
R_SEARCH_TREE,
|
||||
R_SEARCH_TREE_LEVEL_STARTS,
|
||||
GEOMETRIES_INDEX,
|
||||
GEOMETRIES_NODE_LIST,
|
||||
GEOMETRIES_FWD_WEIGHT_LIST,
|
||||
GEOMETRIES_REV_WEIGHT_LIST,
|
||||
GEOMETRIES_FWD_DURATION_LIST,
|
||||
GEOMETRIES_REV_DURATION_LIST,
|
||||
GEOMETRIES_FWD_DATASOURCES_LIST,
|
||||
GEOMETRIES_REV_DATASOURCES_LIST,
|
||||
HSGR_CHECKSUM,
|
||||
FILE_INDEX_PATH,
|
||||
DATASOURCES_NAMES,
|
||||
PROPERTIES,
|
||||
BEARING_CLASSID,
|
||||
BEARING_OFFSETS,
|
||||
BEARING_BLOCKS,
|
||||
BEARING_VALUES,
|
||||
ENTRY_CLASS,
|
||||
LANE_DATA_ID,
|
||||
PRE_TURN_BEARING,
|
||||
POST_TURN_BEARING,
|
||||
TURN_LANE_DATA,
|
||||
LANE_DESCRIPTION_OFFSETS,
|
||||
LANE_DESCRIPTION_MASKS,
|
||||
TURN_WEIGHT_PENALTIES,
|
||||
TURN_DURATION_PENALTIES,
|
||||
MLD_LEVEL_DATA,
|
||||
MLD_PARTITION,
|
||||
MLD_CELL_TO_CHILDREN,
|
||||
MLD_CELL_WEIGHTS_0,
|
||||
MLD_CELL_WEIGHTS_1,
|
||||
MLD_CELL_WEIGHTS_2,
|
||||
MLD_CELL_WEIGHTS_3,
|
||||
MLD_CELL_WEIGHTS_4,
|
||||
MLD_CELL_WEIGHTS_5,
|
||||
MLD_CELL_WEIGHTS_6,
|
||||
MLD_CELL_WEIGHTS_7,
|
||||
MLD_CELL_DURATIONS_0,
|
||||
MLD_CELL_DURATIONS_1,
|
||||
MLD_CELL_DURATIONS_2,
|
||||
MLD_CELL_DURATIONS_3,
|
||||
MLD_CELL_DURATIONS_4,
|
||||
MLD_CELL_DURATIONS_5,
|
||||
MLD_CELL_DURATIONS_6,
|
||||
MLD_CELL_DURATIONS_7,
|
||||
MLD_CELL_SOURCE_BOUNDARY,
|
||||
MLD_CELL_DESTINATION_BOUNDARY,
|
||||
MLD_CELLS,
|
||||
MLD_CELL_LEVEL_OFFSETS,
|
||||
MLD_GRAPH_NODE_LIST,
|
||||
MLD_GRAPH_EDGE_LIST,
|
||||
MLD_GRAPH_NODE_TO_OFFSET,
|
||||
MANEUVER_OVERRIDES,
|
||||
MANEUVER_OVERRIDE_NODE_SEQUENCES,
|
||||
NUM_BLOCKS
|
||||
};
|
||||
|
||||
DataLayout() : blocks{} {}
|
||||
|
||||
inline void SetBlock(BlockID bid, Block block) { blocks[bid] = std::move(block); }
|
||||
inline void SetBlock(const std::string &name, Block block) { blocks[name] = std::move(block); }
|
||||
|
||||
inline uint64_t GetBlockEntries(BlockID bid) const { return blocks[bid].num_entries; }
|
||||
inline uint64_t GetBlockEntries(const std::string &name) const
|
||||
{
|
||||
auto iter = blocks.find(name);
|
||||
if (iter == blocks.end())
|
||||
{
|
||||
throw util::exception("Could not find block " + name);
|
||||
}
|
||||
|
||||
inline uint64_t GetBlockSize(BlockID bid) const { return blocks[bid].byte_size; }
|
||||
return iter->second.num_entries;
|
||||
}
|
||||
|
||||
inline uint64_t GetBlockSize(const std::string &name) const
|
||||
{
|
||||
auto iter = blocks.find(name);
|
||||
if (iter == blocks.end())
|
||||
{
|
||||
throw util::exception("Could not find block " + name);
|
||||
}
|
||||
|
||||
return iter->second.byte_size;
|
||||
}
|
||||
|
||||
inline uint64_t GetSizeOfLayout() const
|
||||
{
|
||||
uint64_t result = 0;
|
||||
for (auto i = 0; i < NUM_BLOCKS; i++)
|
||||
for (const auto &name_and_block : blocks)
|
||||
{
|
||||
result += 2 * sizeof(CANARY) + GetBlockSize(static_cast<BlockID>(i)) + BLOCK_ALIGNMENT;
|
||||
result += 2 * sizeof(CANARY) + GetBlockSize(name_and_block.first) + BLOCK_ALIGNMENT;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T, bool WRITE_CANARY = false>
|
||||
inline T *GetBlockPtr(char *shared_memory, BlockID bid) const
|
||||
inline T *GetBlockPtr(char *shared_memory, const std::string &name) const
|
||||
{
|
||||
static_assert(BLOCK_ALIGNMENT % std::alignment_of<T>::value == 0,
|
||||
"Datatype does not fit alignment constraints.");
|
||||
|
||||
char *ptr = (char *)GetAlignedBlockPtr(shared_memory, bid);
|
||||
char *ptr = (char *)GetAlignedBlockPtr(shared_memory, name);
|
||||
if (WRITE_CANARY)
|
||||
{
|
||||
char *start_canary_ptr = ptr - sizeof(CANARY);
|
||||
char *end_canary_ptr = ptr + GetBlockSize(bid);
|
||||
char *end_canary_ptr = ptr + GetBlockSize(name);
|
||||
std::copy(CANARY, CANARY + sizeof(CANARY), start_canary_ptr);
|
||||
std::copy(CANARY, CANARY + sizeof(CANARY), end_canary_ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *start_canary_ptr = ptr - sizeof(CANARY);
|
||||
char *end_canary_ptr = ptr + GetBlockSize(bid);
|
||||
char *end_canary_ptr = ptr + GetBlockSize(name);
|
||||
bool start_canary_alive = std::equal(CANARY, CANARY + sizeof(CANARY), start_canary_ptr);
|
||||
bool end_canary_alive = std::equal(CANARY, CANARY + sizeof(CANARY), end_canary_ptr);
|
||||
if (!start_canary_alive)
|
||||
{
|
||||
throw util::exception("Start canary of block corrupted. (" +
|
||||
std::string(block_id_to_name[bid]) + ")" + SOURCE_REF);
|
||||
throw util::exception("Start canary of block corrupted. (" + name + ")" +
|
||||
SOURCE_REF);
|
||||
}
|
||||
if (!end_canary_alive)
|
||||
{
|
||||
throw util::exception("End canary of block corrupted. (" +
|
||||
std::string(block_id_to_name[bid]) + ")" + SOURCE_REF);
|
||||
throw util::exception("End canary of block corrupted. (" + name + ")" + SOURCE_REF);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,6 +104,9 @@ class DataLayout
|
||||
}
|
||||
|
||||
private:
|
||||
friend void serialization::read(io::BufferReader &reader, DataLayout &layout);
|
||||
friend void serialization::write(io::BufferWriter &writer, const DataLayout &layout);
|
||||
|
||||
// Fit aligned storage in buffer to 64 bytes to conform with AVX 512 types
|
||||
inline void *align(void *&ptr) const noexcept
|
||||
{
|
||||
@@ -239,13 +115,13 @@ class DataLayout
|
||||
return ptr = reinterpret_cast<void *>(aligned);
|
||||
}
|
||||
|
||||
inline void *GetAlignedBlockPtr(void *ptr, BlockID bid) const
|
||||
inline void *GetAlignedBlockPtr(void *ptr, const std::string &name) const
|
||||
{
|
||||
for (auto i = 0; i < bid; i++)
|
||||
for (auto iter = blocks.begin(); iter != blocks.end() && iter->first != name; ++iter)
|
||||
{
|
||||
ptr = static_cast<char *>(ptr) + sizeof(CANARY);
|
||||
ptr = align(ptr);
|
||||
ptr = static_cast<char *>(ptr) + GetBlockSize((BlockID)i);
|
||||
ptr = static_cast<char *>(ptr) + GetBlockSize(name);
|
||||
ptr = static_cast<char *>(ptr) + sizeof(CANARY);
|
||||
}
|
||||
|
||||
@@ -254,14 +130,14 @@ class DataLayout
|
||||
return ptr;
|
||||
}
|
||||
|
||||
template <typename T> inline T *GetBlockEnd(char *shared_memory, BlockID bid) const
|
||||
template <typename T> inline T *GetBlockEnd(char *shared_memory, const std::string &name) const
|
||||
{
|
||||
auto begin = GetBlockPtr<T>(shared_memory, bid);
|
||||
return begin + GetBlockEntries(bid);
|
||||
auto begin = GetBlockPtr<T>(shared_memory, name);
|
||||
return begin + GetBlockEntries(name);
|
||||
}
|
||||
|
||||
static constexpr std::size_t BLOCK_ALIGNMENT = 64;
|
||||
std::array<Block, NUM_BLOCKS> blocks;
|
||||
std::map<std::string, Block> blocks;
|
||||
};
|
||||
|
||||
enum SharedDataType
|
||||
@@ -298,9 +174,6 @@ inline std::string regionToString(const SharedDataType region)
|
||||
return "INVALID_REGION";
|
||||
}
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user