From 40857aae616839d902596d6869d9121952929ef7 Mon Sep 17 00:00:00 2001 From: vng Date: Wed, 26 Jul 2017 17:47:07 +0300 Subject: [PATCH] Inject offline compressed data facade with OSRM_EXTERNAL_MEMORY option. --- include/engine/datafacade.hpp | 13 +++++++++++-- include/engine/search_engine_data.hpp | 15 +++++++++++++-- src/engine/routing_algorithms/shortest_path.cpp | 17 +++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/include/engine/datafacade.hpp b/include/engine/datafacade.hpp index 5da6210a0..60fc8cb5f 100644 --- a/include/engine/datafacade.hpp +++ b/include/engine/datafacade.hpp @@ -3,8 +3,17 @@ #ifdef OSRM_EXTERNAL_MEMORY -// Register your own data backend here -#error "No external memory implementation found" +#include "routing/compressed_datafacade.hpp" + +namespace osrm +{ +namespace engine +{ + +using DataFacadeBase = datafacade::BaseDataFacade; +template using DataFacade = datafacade::CompressedDataFacadeT; +} +} #else diff --git a/include/engine/search_engine_data.hpp b/include/engine/search_engine_data.hpp index acb632ed5..847981a7a 100644 --- a/include/engine/search_engine_data.hpp +++ b/include/engine/search_engine_data.hpp @@ -1,7 +1,9 @@ #ifndef SEARCH_ENGINE_DATA_HPP #define SEARCH_ENGINE_DATA_HPP +#ifndef OSRM_EXTERNAL_MEMORY #include +#endif #include "engine/algorithm.hpp" #include "util/query_heap.hpp" @@ -37,7 +39,6 @@ template <> struct SearchEngineData { using QueryHeap = util:: QueryHeap>; - using SearchEngineHeapPtr = boost::thread_specific_ptr; using ManyToManyQueryHeap = util::QueryHeap struct SearchEngineData ManyToManyHeapData, util::UnorderedMapStorage>; +#ifdef OSRM_EXTERNAL_MEMORY + using SearchEngineHeapPtr = std::unique_ptr; + using ManyToManyHeapPtr = std::unique_ptr; +#else + using SearchEngineHeapPtr = boost::thread_specific_ptr; using ManyToManyHeapPtr = boost::thread_specific_ptr; +#endif static SearchEngineHeapPtr forward_heap_1; static SearchEngineHeapPtr reverse_heap_1; @@ -105,9 +112,13 @@ template <> struct SearchEngineData ManyToManyMultiLayerDijkstraHeapData, util::UnorderedMapStorage>; +#ifdef OSRM_EXTERNAL_MEMORY + using SearchEngineHeapPtr = std::unique_ptr; + using ManyToManyHeapPtr = std::unique_ptr; +#else using SearchEngineHeapPtr = boost::thread_specific_ptr; - using ManyToManyHeapPtr = boost::thread_specific_ptr; +#endif static SearchEngineHeapPtr forward_heap_1; static SearchEngineHeapPtr reverse_heap_1; diff --git a/src/engine/routing_algorithms/shortest_path.cpp b/src/engine/routing_algorithms/shortest_path.cpp index 87cd75b63..a7b009437 100644 --- a/src/engine/routing_algorithms/shortest_path.cpp +++ b/src/engine/routing_algorithms/shortest_path.cpp @@ -1,6 +1,11 @@ #include "engine/routing_algorithms/shortest_path.hpp" + +#ifdef OSRM_EXTERNAL_MEMORY +#include "routing/routing_base_offline.hpp" +#else #include "engine/routing_algorithms/routing_base_ch.hpp" #include "engine/routing_algorithms/routing_base_mld.hpp" +#endif #include #include @@ -456,6 +461,16 @@ InternalRouteResult shortestPathSearch(SearchEngineData &engine_worki return raw_route_data; } +#ifdef OSRM_EXTERNAL_MEMORY + +template InternalRouteResult +shortestPathSearch(SearchEngineData &engine_working_data, + const DataFacade &facade, + const std::vector &phantom_nodes_vector, + const boost::optional continue_straight_at_waypoint); + +#else + template InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, const DataFacade &facade, @@ -474,6 +489,8 @@ shortestPathSearch(SearchEngineData &engine_working_data, const std::vector &phantom_nodes_vector, const boost::optional continue_straight_at_waypoint); +#endif + } // namespace routing_algorithms } // namespace engine } // namespace osrm