diff --git a/include/engine/datafacade/algorithm_datafacade.hpp b/include/engine/datafacade/algorithm_datafacade.hpp index 5608e925152..7a78779b4b7 100644 --- a/include/engine/datafacade/algorithm_datafacade.hpp +++ b/include/engine/datafacade/algorithm_datafacade.hpp @@ -89,6 +89,9 @@ template <> class AlgorithmDataFacade virtual const partition::MultiLevelPartitionView &GetMultiLevelPartition() const = 0; virtual const partition::CellStorageView &GetCellStorage() const = 0; + + // searches for a specific edge + virtual EdgeID FindEdge(const NodeID from, const NodeID to) const = 0; }; } } diff --git a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp index 8d8b87df47b..27e45837739 100644 --- a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp +++ b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp @@ -1076,6 +1076,12 @@ class ContiguousInternalMemoryDataFacade { return m_query_graph->GetAdjacentEdgeRange(node); } + + // searches for a specific edge + EdgeID FindEdge(const NodeID from, const NodeID to) const override final + { + return m_query_graph->FindEdge(from, to); + } }; } } diff --git a/include/engine/routing_algorithms/routing_base_mld.hpp b/include/engine/routing_algorithms/routing_base_mld.hpp index 1b3533b3cc5..dd01ef8a51a 100644 --- a/include/engine/routing_algorithms/routing_base_mld.hpp +++ b/include/engine/routing_algorithms/routing_base_mld.hpp @@ -21,8 +21,8 @@ namespace mld template void routingStep(const datafacade::ContiguousInternalMemoryDataFacade &facade, - SearchEngineData::MultiLayerDijkstraHeap &forward_heap, - SearchEngineData::MultiLayerDijkstraHeap &reverse_heap, + SearchEngineData::QueryHeap &forward_heap, + SearchEngineData::QueryHeap &reverse_heap, const std::pair &parent_cell, const std::function &get_query_level, NodeID &middle_node, @@ -56,14 +56,9 @@ void routingStep(const datafacade::ContiguousInternalMemoryDataFacade= 1) && // only if at least the first level and - (node_data.parent == node || // is the first point of the path - node_data.edge_id != SPECIAL_EDGEID); // or an overlay entreƩ point - if (check_overlay_edges) + if (level >= 1) { if (DIRECTION == FORWARD_DIRECTION) { @@ -138,11 +133,11 @@ void routingStep(const datafacade::ContiguousInternalMemoryDataFacade &facade, - SearchEngineData::MultiLayerDijkstraHeap &forward_heap, - SearchEngineData::MultiLayerDijkstraHeap &reverse_heap, + SearchEngineData::QueryHeap &forward_heap, + SearchEngineData::QueryHeap &reverse_heap, const std::pair &parent_cell, const std::function &get_query_level) { @@ -187,13 +182,12 @@ auto search(const datafacade::ContiguousInternalMemoryDataFacade INVALID_EDGE_WEIGHT, SPECIAL_NODEID, SPECIAL_NODEID, std::vector()); } - // Get packed path as edges {from node ID, to node ID, edge ID} - std::vector> packed_path; + // Get packed path as edges {from node ID, to node ID} + std::vector> packed_path; NodeID current_node = middle, parent_node = forward_heap.GetData(middle).parent; while (parent_node != current_node) { - const auto &data = forward_heap.GetData(current_node); - packed_path.push_back(std::make_tuple(parent_node, current_node, data.edge_id)); + packed_path.push_back(std::make_tuple(parent_node, current_node)); current_node = parent_node; parent_node = forward_heap.GetData(parent_node).parent; } @@ -203,8 +197,7 @@ auto search(const datafacade::ContiguousInternalMemoryDataFacade current_node = middle, parent_node = reverse_heap.GetData(middle).parent; while (parent_node != current_node) { - const auto &data = reverse_heap.GetData(current_node); - packed_path.push_back(std::make_tuple(current_node, parent_node, data.edge_id)); + packed_path.push_back(std::make_tuple(current_node, parent_node)); current_node = parent_node; parent_node = reverse_heap.GetData(parent_node).parent; } @@ -216,8 +209,9 @@ auto search(const datafacade::ContiguousInternalMemoryDataFacade for (auto &packed_edge : packed_path) { NodeID source, target; - EdgeID edge_id; - std::tie(source, target, edge_id) = packed_edge; + std::tie(source, target) = packed_edge; + EdgeID edge_id = facade.FindEdge(source, target); + if (edge_id != SPECIAL_EDGEID) { // a base graph edge unpacked_path.push_back(edge_id); diff --git a/include/engine/search_engine_data.hpp b/include/engine/search_engine_data.hpp index f84b921919b..b9f5dba3e5d 100644 --- a/include/engine/search_engine_data.hpp +++ b/include/engine/search_engine_data.hpp @@ -24,13 +24,6 @@ struct ManyToManyHeapData : HeapData ManyToManyHeapData(NodeID p, EdgeWeight duration) : HeapData(p), duration(duration) {} }; -struct MultiLayerDijkstraHeapData : HeapData -{ - EdgeID edge_id; // edge id if parent -> node is a boundary edge - MultiLayerDijkstraHeapData(NodeID p) : HeapData(p), edge_id(SPECIAL_EDGEID) {} - MultiLayerDijkstraHeapData(NodeID p, EdgeID edge_id) : HeapData(p), edge_id(edge_id) {} -}; - struct SearchEngineData { using QueryHeap = util:: @@ -45,14 +38,6 @@ struct SearchEngineData using ManyToManyHeapPtr = boost::thread_specific_ptr; - using MultiLayerDijkstraHeap = util::BinaryHeap>; - - using MultiLayerDijkstraHeapPtr = boost::thread_specific_ptr; - static SearchEngineHeapPtr forward_heap_1; static SearchEngineHeapPtr reverse_heap_1; static SearchEngineHeapPtr forward_heap_2; @@ -60,8 +45,6 @@ struct SearchEngineData static SearchEngineHeapPtr forward_heap_3; static SearchEngineHeapPtr reverse_heap_3; static ManyToManyHeapPtr many_to_many_heap; - static MultiLayerDijkstraHeapPtr mld_forward_heap; - static MultiLayerDijkstraHeapPtr mld_reverse_heap; void InitializeOrClearFirstThreadLocalStorage(const unsigned number_of_nodes); @@ -70,8 +53,6 @@ struct SearchEngineData void InitializeOrClearThirdThreadLocalStorage(const unsigned number_of_nodes); void InitializeOrClearManyToManyThreadLocalStorage(const unsigned number_of_nodes); - - void InitializeOrClearMultiLayerDijkstraThreadLocalStorage(const unsigned number_of_nodes); }; } } diff --git a/src/engine/routing_algorithms/direct_shortest_path.cpp b/src/engine/routing_algorithms/direct_shortest_path.cpp index b307903ee6e..23bfa1c3b20 100644 --- a/src/engine/routing_algorithms/direct_shortest_path.cpp +++ b/src/engine/routing_algorithms/direct_shortest_path.cpp @@ -130,10 +130,9 @@ InternalRouteResult directShortestPathSearch( const datafacade::ContiguousInternalMemoryDataFacade &facade, const PhantomNodes &phantom_nodes) { - engine_working_data.InitializeOrClearMultiLayerDijkstraThreadLocalStorage( - facade.GetNumberOfNodes()); - auto &forward_heap = *(engine_working_data.mld_forward_heap); - auto &reverse_heap = *(engine_working_data.mld_reverse_heap); + engine_working_data.InitializeOrClearFirstThreadLocalStorage(facade.GetNumberOfNodes()); + auto &forward_heap = *(engine_working_data.forward_heap_1); + auto &reverse_heap = *(engine_working_data.reverse_heap_1); forward_heap.Clear(); reverse_heap.Clear(); insertNodesInHeaps(forward_heap, reverse_heap, phantom_nodes); diff --git a/src/engine/search_engine_data.cpp b/src/engine/search_engine_data.cpp index 9e299fc997d..644e5ba68ad 100644 --- a/src/engine/search_engine_data.cpp +++ b/src/engine/search_engine_data.cpp @@ -15,9 +15,6 @@ SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_3; SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_3; SearchEngineData::ManyToManyHeapPtr SearchEngineData::many_to_many_heap; -SearchEngineData::MultiLayerDijkstraHeapPtr SearchEngineData::mld_forward_heap; -SearchEngineData::MultiLayerDijkstraHeapPtr SearchEngineData::mld_reverse_heap; - void SearchEngineData::InitializeOrClearFirstThreadLocalStorage(const unsigned number_of_nodes) { if (forward_heap_1.get()) @@ -92,27 +89,5 @@ void SearchEngineData::InitializeOrClearManyToManyThreadLocalStorage(const unsig many_to_many_heap.reset(new ManyToManyQueryHeap(number_of_nodes)); } } - -void SearchEngineData::InitializeOrClearMultiLayerDijkstraThreadLocalStorage( - const unsigned number_of_nodes) -{ - if (mld_forward_heap.get()) - { - mld_forward_heap->Clear(); - } - else - { - mld_forward_heap.reset(new MultiLayerDijkstraHeap(number_of_nodes)); - } - - if (mld_reverse_heap.get()) - { - mld_reverse_heap->Clear(); - } - else - { - mld_reverse_heap.reset(new MultiLayerDijkstraHeap(number_of_nodes)); - } -} } }