From 48a098a9c7dabc3bbdd972fbcec7ff0420d0068b Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Mon, 3 Apr 2017 12:50:37 +0200 Subject: [PATCH] implement MLD shortest path plugin --- include/engine/algorithm.hpp | 3 + include/engine/routing_algorithms.hpp | 11 +- .../routing_algorithms/map_matching.hpp | 3 +- .../routing_algorithms/routing_base.hpp | 4 + .../routing_algorithms/routing_base_ch.hpp | 19 ++- .../routing_algorithms/routing_base_mld.hpp | 61 ++++++++- .../routing_algorithms/shortest_path.hpp | 2 +- include/engine/search_engine_data.hpp | 4 + .../direct_shortest_path.cpp | 7 +- .../routing_algorithms/map_matching.cpp | 34 ++--- .../routing_algorithms/routing_base.cpp | 28 +++++ .../routing_algorithms/routing_base_ch.cpp | 18 +-- .../routing_algorithms/shortest_path.cpp | 116 ++++++++++-------- src/engine/search_engine_data.cpp | 84 +++++++++---- 14 files changed, 266 insertions(+), 128 deletions(-) create mode 100644 src/engine/routing_algorithms/routing_base.cpp diff --git a/include/engine/algorithm.hpp b/include/engine/algorithm.hpp index ee6d0e22e..0ea02663a 100644 --- a/include/engine/algorithm.hpp +++ b/include/engine/algorithm.hpp @@ -96,6 +96,9 @@ template <> struct HasGetTileTurns final : std::true_type template <> struct HasDirectShortestPathSearch final : std::true_type { }; +template <> struct HasShortestPathSearch final : std::true_type +{ +}; } } } diff --git a/include/engine/routing_algorithms.hpp b/include/engine/routing_algorithms.hpp index bd8af9f8c..fccfaebff 100644 --- a/include/engine/routing_algorithms.hpp +++ b/include/engine/routing_algorithms.hpp @@ -187,7 +187,8 @@ inline std::vector RoutingAlgorithms::G // CoreCH overrides template <> -InternalRouteResult inline RoutingAlgorithms::AlternativePathSearch(const PhantomNodes &) const +InternalRouteResult inline RoutingAlgorithms< + routing_algorithms::corech::Algorithm>::AlternativePathSearch(const PhantomNodes &) const { throw util::exception("AlternativePathSearch is disabled due to performance reasons"); } @@ -210,14 +211,6 @@ InternalRouteResult inline RoutingAlgorithms< throw util::exception("AlternativePathSearch is not implemented"); } -template <> -inline InternalRouteResult -RoutingAlgorithms::ShortestPathSearch( - const std::vector &, const boost::optional) const -{ - throw util::exception("ShortestPathSearch is not implemented"); -} - template <> inline std::vector RoutingAlgorithms::ManyToManySearch( diff --git a/include/engine/routing_algorithms/map_matching.hpp b/include/engine/routing_algorithms/map_matching.hpp index 00984dc8a..ec43c0755 100644 --- a/include/engine/routing_algorithms/map_matching.hpp +++ b/include/engine/routing_algorithms/map_matching.hpp @@ -22,7 +22,7 @@ static const constexpr double DEFAULT_GPS_PRECISION = 5; //[1] "Hidden Markov Map Matching Through Noise and Sparseness"; // P. Newson and J. Krumm; 2009; ACM GIS -template +template SubMatchingList mapMatching(SearchEngineData &engine_working_data, const datafacade::ContiguousInternalMemoryDataFacade &facade, const CandidateLists &candidates_list, @@ -30,7 +30,6 @@ SubMatchingList mapMatching(SearchEngineData &engine_working_data, const std::vector &trace_timestamps, const std::vector> &trace_gps_precision, const bool allow_splitting); - } } } diff --git a/include/engine/routing_algorithms/routing_base.hpp b/include/engine/routing_algorithms/routing_base.hpp index c1952b1ed..c509204f2 100644 --- a/include/engine/routing_algorithms/routing_base.hpp +++ b/include/engine/routing_algorithms/routing_base.hpp @@ -37,6 +37,10 @@ static constexpr bool FORWARD_DIRECTION = true; static constexpr bool REVERSE_DIRECTION = false; static constexpr bool DO_NOT_FORCE_LOOPS = false; +bool needsLoopForward(const PhantomNode &source_phantom, const PhantomNode &target_phantom); + +bool needsLoopBackwards(const PhantomNode &source_phantom, const PhantomNode &target_phantom); + template void insertNodesInHeap(Heap &heap, const PhantomNode &phantom_node) { diff --git a/include/engine/routing_algorithms/routing_base_ch.hpp b/include/engine/routing_algorithms/routing_base_ch.hpp index 0f89e512c..ae5993f5a 100644 --- a/include/engine/routing_algorithms/routing_base_ch.hpp +++ b/include/engine/routing_algorithms/routing_base_ch.hpp @@ -365,10 +365,11 @@ inline void search(const datafacade::ContiguousInternalMemoryDataFacade::QueryHeap &reverse_heap, SearchEngineData::QueryHeap &, SearchEngineData::QueryHeap &, - std::int32_t &weight, + EdgeWeight &weight, std::vector &packed_leg, const bool force_loop_forward, const bool force_loop_reverse, + const PhantomNodes & /*phantom_nodes*/, const int duration_upper_bound = INVALID_EDGE_WEIGHT) { search(facade, @@ -381,10 +382,6 @@ inline void search(const datafacade::ContiguousInternalMemoryDataFacade &facade, const std::vector &packed_path, const PhantomNode &source_phantom, @@ -437,6 +434,7 @@ void search(const datafacade::ContiguousInternalMemoryDataFacade &packed_leg, const bool force_loop_forward, const bool force_loop_reverse, + const PhantomNodes &phantom_nodes, int duration_upper_bound = INVALID_EDGE_WEIGHT); // Requires the heaps for be empty @@ -451,6 +449,17 @@ getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade +void unpackPath(const FacadeT &facade, + RandomIter packed_path_begin, + RandomIter packed_path_end, + const PhantomNodes &phantom_nodes, + std::vector &unpacked_path) +{ + return ch::unpackPath(facade, packed_path_begin, packed_path_end, phantom_nodes, unpacked_path); +} + } // namespace corech } // namespace routing_algorithms diff --git a/include/engine/routing_algorithms/routing_base_mld.hpp b/include/engine/routing_algorithms/routing_base_mld.hpp index dcf5b21e0..506df53bf 100644 --- a/include/engine/routing_algorithms/routing_base_mld.hpp +++ b/include/engine/routing_algorithms/routing_base_mld.hpp @@ -174,6 +174,8 @@ std::tuple> search(const datafacade::ContiguousInternalMemoryDataFacade &facade, SearchEngineData::QueryHeap &forward_heap, SearchEngineData::QueryHeap &reverse_heap, + const bool force_loop_forward, + const bool force_loop_reverse, Args... args) { @@ -268,7 +270,7 @@ search(const datafacade::ContiguousInternalMemoryDataFacade &facade, NodeID subpath_source, subpath_target; std::vector subpath; std::tie(subpath_weight, subpath_source, subpath_target, subpath) = - search(facade, forward_heap, reverse_heap, sublevel, parent_cell_id); + search(facade, forward_heap, reverse_heap, force_loop_forward, force_loop_reverse, sublevel, parent_cell_id); BOOST_ASSERT(!subpath.empty()); BOOST_ASSERT(subpath_source == source); BOOST_ASSERT(subpath_target == target); @@ -279,6 +281,63 @@ search(const datafacade::ContiguousInternalMemoryDataFacade &facade, return std::make_tuple(weight, source_node, target_node, std::move(unpacked_path)); } +// Alias to be compatible with the overload for CoreCH that needs 4 heaps +inline void search(const datafacade::ContiguousInternalMemoryDataFacade &facade, + SearchEngineData::QueryHeap &forward_heap, + SearchEngineData::QueryHeap &reverse_heap, + SearchEngineData::QueryHeap &, + SearchEngineData::QueryHeap &, + EdgeWeight &weight, + std::vector &packed_leg, + const bool force_loop_forward, + const bool force_loop_reverse, + const PhantomNodes &phantom_nodes, + const int duration_upper_bound = INVALID_EDGE_WEIGHT) +{ + (void)duration_upper_bound; + + NodeID source_node, target_node; + std::vector unpacked_edges; + std::tie(weight, source_node, target_node, unpacked_edges) = + mld::search(facade, forward_heap, reverse_heap, force_loop_forward, force_loop_reverse, phantom_nodes); + + if (weight != INVALID_EDGE_WEIGHT) + { + packed_leg.push_back(source_node); + std::transform(unpacked_edges.begin(), + unpacked_edges.end(), + std::back_inserter(packed_leg), + [&facade](const auto edge) { return facade.GetTarget(edge); }); + } +} + +template +void unpackPath(const FacadeT &facade, + RandomIter packed_path_begin, + RandomIter packed_path_end, + const PhantomNodes &phantom_nodes, + std::vector &unpacked_path) +{ + const auto nodes_number = std::distance(packed_path_begin, packed_path_end); + BOOST_ASSERT(nodes_number > 0); + + std::vector unpacked_edges; + + auto source_node = *packed_path_begin, target_node = *packed_path_begin; + + if (nodes_number > 1) + { + target_node = *std::prev(packed_path_end); + util::for_each_pair(packed_path_begin, + packed_path_end, + [&facade, &unpacked_edges](const auto from, const auto to) { + unpacked_edges.push_back(facade.FindEdge(from, to)); + }); + } + + annotatePath(facade, source_node, target_node, unpacked_edges, phantom_nodes, unpacked_path); +} + } // namespace mld } // namespace routing_algorithms } // namespace engine diff --git a/include/engine/routing_algorithms/shortest_path.hpp b/include/engine/routing_algorithms/shortest_path.hpp index 2273192fb..ca0c6d21d 100644 --- a/include/engine/routing_algorithms/shortest_path.hpp +++ b/include/engine/routing_algorithms/shortest_path.hpp @@ -13,7 +13,7 @@ namespace engine namespace routing_algorithms { -template +template InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, const datafacade::ContiguousInternalMemoryDataFacade &facade, diff --git a/include/engine/search_engine_data.hpp b/include/engine/search_engine_data.hpp index ed3fac0ce..353c816d1 100644 --- a/include/engine/search_engine_data.hpp +++ b/include/engine/search_engine_data.hpp @@ -75,8 +75,12 @@ template <> struct SearchEngineData static SearchEngineHeapPtr forward_heap_1; static SearchEngineHeapPtr reverse_heap_1; + static SearchEngineHeapPtr forward_heap_2; + static SearchEngineHeapPtr reverse_heap_2; void InitializeOrClearFirstThreadLocalStorage(unsigned number_of_nodes); + + void InitializeOrClearSecondThreadLocalStorage(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 916db8532..e3e1d3f3c 100644 --- a/src/engine/routing_algorithms/direct_shortest_path.cpp +++ b/src/engine/routing_algorithms/direct_shortest_path.cpp @@ -84,7 +84,8 @@ InternalRouteResult directShortestPathSearchImpl( weight, packed_leg, DO_NOT_FORCE_LOOPS, - DO_NOT_FORCE_LOOPS); + DO_NOT_FORCE_LOOPS, + phantom_nodes); std::vector unpacked_edges; auto source_node = SPECIAL_NODEID, target_node = SPECIAL_NODEID; @@ -139,8 +140,8 @@ InternalRouteResult directShortestPathSearch( EdgeWeight weight; NodeID source_node, target_node; std::vector unpacked_edges; - std::tie(weight, source_node, target_node, unpacked_edges) = - mld::search(facade, forward_heap, reverse_heap, phantom_nodes); + std::tie(weight, source_node, target_node, unpacked_edges) = mld::search( + facade, forward_heap, reverse_heap, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS, phantom_nodes); return extractRoute(facade, weight, source_node, target_node, unpacked_edges, phantom_nodes); } diff --git a/src/engine/routing_algorithms/map_matching.cpp b/src/engine/routing_algorithms/map_matching.cpp index 18c7a6b3b..b70fbb61a 100644 --- a/src/engine/routing_algorithms/map_matching.cpp +++ b/src/engine/routing_algorithms/map_matching.cpp @@ -420,14 +420,15 @@ mapMatchingImpl(SearchEngineData &engine_working_data, return sub_matchings; } -template<> -SubMatchingList mapMatching(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const CandidateLists &candidates_list, - const std::vector &trace_coordinates, - const std::vector &trace_timestamps, - const std::vector> &trace_gps_precision, - const bool use_tidying) +template <> +SubMatchingList +mapMatching(SearchEngineData &engine_working_data, + const datafacade::ContiguousInternalMemoryDataFacade &facade, + const CandidateLists &candidates_list, + const std::vector &trace_coordinates, + const std::vector &trace_timestamps, + const std::vector> &trace_gps_precision, + const bool use_tidying) { return mapMatchingImpl(engine_working_data, facade, @@ -438,14 +439,15 @@ SubMatchingList mapMatching(SearchEngineData &engine_working_data use_tidying); } -template<> -SubMatchingList mapMatching(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const CandidateLists &candidates_list, - const std::vector &trace_coordinates, - const std::vector &trace_timestamps, - const std::vector> &trace_gps_precision, - const bool use_tidying) +template <> +SubMatchingList +mapMatching(SearchEngineData &engine_working_data, + const datafacade::ContiguousInternalMemoryDataFacade &facade, + const CandidateLists &candidates_list, + const std::vector &trace_coordinates, + const std::vector &trace_timestamps, + const std::vector> &trace_gps_precision, + const bool use_tidying) { return mapMatchingImpl(engine_working_data, diff --git a/src/engine/routing_algorithms/routing_base.cpp b/src/engine/routing_algorithms/routing_base.cpp new file mode 100644 index 000000000..08cda29fe --- /dev/null +++ b/src/engine/routing_algorithms/routing_base.cpp @@ -0,0 +1,28 @@ +#include "engine/routing_algorithms/routing_base.hpp" + +namespace osrm +{ +namespace engine +{ +namespace routing_algorithms +{ + +bool needsLoopForward(const PhantomNode &source_phantom, const PhantomNode &target_phantom) +{ + return source_phantom.forward_segment_id.enabled && target_phantom.forward_segment_id.enabled && + source_phantom.forward_segment_id.id == target_phantom.forward_segment_id.id && + source_phantom.GetForwardWeightPlusOffset() > + target_phantom.GetForwardWeightPlusOffset(); +} + +bool needsLoopBackwards(const PhantomNode &source_phantom, const PhantomNode &target_phantom) +{ + return source_phantom.reverse_segment_id.enabled && target_phantom.reverse_segment_id.enabled && + source_phantom.reverse_segment_id.id == target_phantom.reverse_segment_id.id && + source_phantom.GetReverseWeightPlusOffset() > + target_phantom.GetReverseWeightPlusOffset(); +} + +} // namespace routing_algorithms +} // namespace engine +} // namespace osrm diff --git a/src/engine/routing_algorithms/routing_base_ch.cpp b/src/engine/routing_algorithms/routing_base_ch.cpp index b2d593031..df30c2528 100644 --- a/src/engine/routing_algorithms/routing_base_ch.cpp +++ b/src/engine/routing_algorithms/routing_base_ch.cpp @@ -139,22 +139,6 @@ void search(const datafacade::ContiguousInternalMemoryDataFacade &fac } } -bool needsLoopForward(const PhantomNode &source_phantom, const PhantomNode &target_phantom) -{ - return source_phantom.forward_segment_id.enabled && target_phantom.forward_segment_id.enabled && - source_phantom.forward_segment_id.id == target_phantom.forward_segment_id.id && - source_phantom.GetForwardWeightPlusOffset() > - target_phantom.GetForwardWeightPlusOffset(); -} - -bool needsLoopBackwards(const PhantomNode &source_phantom, const PhantomNode &target_phantom) -{ - return source_phantom.reverse_segment_id.enabled && target_phantom.reverse_segment_id.enabled && - source_phantom.reverse_segment_id.id == target_phantom.reverse_segment_id.id && - source_phantom.GetReverseWeightPlusOffset() > - target_phantom.GetReverseWeightPlusOffset(); -} - double getPathDistance(const datafacade::ContiguousInternalMemoryDataFacade &facade, const std::vector &packed_path, const PhantomNode &source_phantom, @@ -290,6 +274,7 @@ void search(const datafacade::ContiguousInternalMemoryDataFacade &fac std::vector &packed_leg, const bool force_loop_forward, const bool force_loop_reverse, + const PhantomNodes & /*phantom_nodes*/, EdgeWeight weight_upper_bound) { NodeID middle = SPECIAL_NODEID; @@ -486,6 +471,7 @@ double getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade::max(); diff --git a/src/engine/routing_algorithms/shortest_path.cpp b/src/engine/routing_algorithms/shortest_path.cpp index 373777ee7..43cba7d44 100644 --- a/src/engine/routing_algorithms/shortest_path.cpp +++ b/src/engine/routing_algorithms/shortest_path.cpp @@ -1,5 +1,6 @@ #include "engine/routing_algorithms/shortest_path.hpp" #include "engine/routing_algorithms/routing_base_ch.hpp" +#include "engine/routing_algorithms/routing_base_mld.hpp" #include #include @@ -16,16 +17,15 @@ namespace { const static constexpr bool DO_NOT_FORCE_LOOP = false; -using QueryHeap = SearchEngineData::QueryHeap; // allows a uturn at the target_phantom // searches source forward/reverse -> target forward/reverse -template -void searchWithUTurn(const datafacade::ContiguousInternalMemoryDataFacade &facade, - QueryHeap &forward_heap, - QueryHeap &reverse_heap, - QueryHeap &forward_core_heap, - QueryHeap &reverse_core_heap, +template +void searchWithUTurn(const datafacade::ContiguousInternalMemoryDataFacade &facade, + typename SearchEngineData::QueryHeap &forward_heap, + typename SearchEngineData::QueryHeap &reverse_heap, + typename SearchEngineData::QueryHeap &forward_core_heap, + typename SearchEngineData::QueryHeap &reverse_core_heap, const bool search_from_forward_node, const bool search_from_reverse_node, const bool search_to_forward_node, @@ -71,24 +71,24 @@ void searchWithUTurn(const datafacade::ContiguousInternalMemoryDataFacade target forward // source forward/reverse -> target reverse -template -void search(const datafacade::ContiguousInternalMemoryDataFacade &facade, - QueryHeap &forward_heap, - QueryHeap &reverse_heap, - QueryHeap &forward_core_heap, - QueryHeap &reverse_core_heap, +template +void search(const datafacade::ContiguousInternalMemoryDataFacade &facade, + typename SearchEngineData::QueryHeap &forward_heap, + typename SearchEngineData::QueryHeap &reverse_heap, + typename SearchEngineData::QueryHeap &forward_core_heap, + typename SearchEngineData::QueryHeap &reverse_core_heap, const bool search_from_forward_node, const bool search_from_reverse_node, const bool search_to_forward_node, @@ -148,15 +148,16 @@ void search(const datafacade::ContiguousInternalMemoryDataFacade &fa reverse_core_heap.Clear(); BOOST_ASSERT(forward_core_heap.Size() == 0); BOOST_ASSERT(reverse_core_heap.Size() == 0); - ch::search(facade, - forward_heap, - reverse_heap, - forward_core_heap, - reverse_core_heap, - new_total_weight_to_forward, - leg_packed_path_forward, - ch::needsLoopForward(source_phantom, target_phantom), - DO_NOT_FORCE_LOOP); + search(facade, + forward_heap, + reverse_heap, + forward_core_heap, + reverse_core_heap, + new_total_weight_to_forward, + leg_packed_path_forward, + needsLoopForward(source_phantom, target_phantom), + routing_algorithms::DO_NOT_FORCE_LOOP, + {source_phantom, target_phantom}); } if (search_to_reverse_node) @@ -186,19 +187,21 @@ void search(const datafacade::ContiguousInternalMemoryDataFacade &fa reverse_core_heap.Clear(); BOOST_ASSERT(forward_core_heap.Size() == 0); BOOST_ASSERT(reverse_core_heap.Size() == 0); - ch::search(facade, - forward_heap, - reverse_heap, - forward_core_heap, - reverse_core_heap, - new_total_weight_to_reverse, - leg_packed_path_reverse, - DO_NOT_FORCE_LOOP, - ch::needsLoopBackwards(source_phantom, target_phantom)); + search(facade, + forward_heap, + reverse_heap, + forward_core_heap, + reverse_core_heap, + new_total_weight_to_reverse, + leg_packed_path_reverse, + routing_algorithms::DO_NOT_FORCE_LOOP, + needsLoopBackwards(source_phantom, target_phantom), + {source_phantom, target_phantom}); } } -void unpackLegs(const datafacade::ContiguousInternalMemoryDataFacade &facade, +template +void unpackLegs(const datafacade::ContiguousInternalMemoryDataFacade &facade, const std::vector &phantom_nodes_vector, const std::vector &total_packed_path, const std::vector &packed_leg_begin, @@ -214,11 +217,11 @@ void unpackLegs(const datafacade::ContiguousInternalMemoryDataFacade &engine_working_data, } } -template<> +template <> InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, const datafacade::ContiguousInternalMemoryDataFacade &facade, @@ -495,7 +498,7 @@ shortestPathSearch(SearchEngineData &engine_working_data, engine_working_data, facade, phantom_nodes_vector, continue_straight_at_waypoint); } -template<> +template <> InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, const datafacade::ContiguousInternalMemoryDataFacade &facade, @@ -506,6 +509,17 @@ shortestPathSearch(SearchEngineData &engine_working_data, engine_working_data, facade, phantom_nodes_vector, continue_straight_at_waypoint); } +template <> +InternalRouteResult +shortestPathSearch(SearchEngineData &engine_working_data, + const datafacade::ContiguousInternalMemoryDataFacade &facade, + const std::vector &phantom_nodes_vector, + const boost::optional continue_straight_at_waypoint) +{ + return shortestPathSearchImpl( + engine_working_data, facade, phantom_nodes_vector, continue_straight_at_waypoint); +} + } // namespace routing_algorithms } // namespace engine } // namespace osrm diff --git a/src/engine/search_engine_data.cpp b/src/engine/search_engine_data.cpp index d6877cbda..a3d9d0a6e 100644 --- a/src/engine/search_engine_data.cpp +++ b/src/engine/search_engine_data.cpp @@ -7,13 +7,27 @@ namespace osrm namespace engine { -template typename SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_1; -template typename SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_1; -template typename SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_2; -template typename SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_2; -template typename SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_3; -template typename SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_3; -template typename SearchEngineData::ManyToManyHeapPtr SearchEngineData::many_to_many_heap; +template +typename SearchEngineData::SearchEngineHeapPtr + SearchEngineData::forward_heap_1; +template +typename SearchEngineData::SearchEngineHeapPtr + SearchEngineData::reverse_heap_1; +template +typename SearchEngineData::SearchEngineHeapPtr + SearchEngineData::forward_heap_2; +template +typename SearchEngineData::SearchEngineHeapPtr + SearchEngineData::reverse_heap_2; +template +typename SearchEngineData::SearchEngineHeapPtr + SearchEngineData::forward_heap_3; +template +typename SearchEngineData::SearchEngineHeapPtr + SearchEngineData::reverse_heap_3; +template +typename SearchEngineData::ManyToManyHeapPtr + SearchEngineData::many_to_many_heap; template void SearchEngineData::InitializeOrClearFirstThreadLocalStorage(unsigned number_of_nodes) @@ -106,17 +120,18 @@ template SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward template SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_3; template SearchEngineData::ManyToManyHeapPtr SearchEngineData::many_to_many_heap; -template -void SearchEngineData::InitializeOrClearFirstThreadLocalStorage(unsigned number_of_nodes); +template void +SearchEngineData::InitializeOrClearFirstThreadLocalStorage( + unsigned number_of_nodes); -template -void SearchEngineData::InitializeOrClearSecondThreadLocalStorage(unsigned number_of_nodes); +template void +SearchEngineData::InitializeOrClearSecondThreadLocalStorage(unsigned number_of_nodes); -template -void SearchEngineData::InitializeOrClearThirdThreadLocalStorage(unsigned number_of_nodes); +template void +SearchEngineData::InitializeOrClearThirdThreadLocalStorage(unsigned number_of_nodes); -template -void SearchEngineData::InitializeOrClearManyToManyThreadLocalStorage(unsigned number_of_nodes); +template void +SearchEngineData::InitializeOrClearManyToManyThreadLocalStorage(unsigned number_of_nodes); // CoreCH using CoreCH = routing_algorithms::corech::Algorithm; @@ -128,23 +143,24 @@ template SearchEngineData::SearchEngineHeapPtr SearchEngineData: template SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_3; template SearchEngineData::ManyToManyHeapPtr SearchEngineData::many_to_many_heap; -template -void SearchEngineData::InitializeOrClearFirstThreadLocalStorage(unsigned number_of_nodes); +template void +SearchEngineData::InitializeOrClearFirstThreadLocalStorage(unsigned number_of_nodes); -template -void SearchEngineData::InitializeOrClearSecondThreadLocalStorage(unsigned number_of_nodes); +template void +SearchEngineData::InitializeOrClearSecondThreadLocalStorage(unsigned number_of_nodes); -template -void SearchEngineData::InitializeOrClearThirdThreadLocalStorage(unsigned number_of_nodes); +template void +SearchEngineData::InitializeOrClearThirdThreadLocalStorage(unsigned number_of_nodes); -template -void SearchEngineData::InitializeOrClearManyToManyThreadLocalStorage( - unsigned number_of_nodes); +template void +SearchEngineData::InitializeOrClearManyToManyThreadLocalStorage(unsigned number_of_nodes); // MLD using MLD = routing_algorithms::mld::Algorithm; SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_1; SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_1; +SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_2; +SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_2; void SearchEngineData::InitializeOrClearFirstThreadLocalStorage(unsigned number_of_nodes) { @@ -167,5 +183,25 @@ void SearchEngineData::InitializeOrClearFirstThreadLocalStorage(unsigned nu } } +void SearchEngineData::InitializeOrClearSecondThreadLocalStorage(unsigned) +{ + if (forward_heap_2.get()) + { + forward_heap_2->Clear(); + } + else + { + forward_heap_2.reset(new QueryHeap(1)); + } + + if (reverse_heap_2.get()) + { + reverse_heap_2->Clear(); + } + else + { + reverse_heap_2.reset(new QueryHeap(1)); + } +} } }