Inject offline compressed data facade with OSRM_EXTERNAL_MEMORY option.

This commit is contained in:
vng 2017-07-26 17:47:07 +03:00 committed by Patrick Niklaus
parent a64145b712
commit 40857aae61
3 changed files with 41 additions and 4 deletions

View File

@ -3,8 +3,17 @@
#ifdef OSRM_EXTERNAL_MEMORY #ifdef OSRM_EXTERNAL_MEMORY
// Register your own data backend here #include "routing/compressed_datafacade.hpp"
#error "No external memory implementation found"
namespace osrm
{
namespace engine
{
using DataFacadeBase = datafacade::BaseDataFacade;
template <typename AlgorithmT> using DataFacade = datafacade::CompressedDataFacadeT<AlgorithmT>;
}
}
#else #else

View File

@ -1,7 +1,9 @@
#ifndef SEARCH_ENGINE_DATA_HPP #ifndef SEARCH_ENGINE_DATA_HPP
#define SEARCH_ENGINE_DATA_HPP #define SEARCH_ENGINE_DATA_HPP
#ifndef OSRM_EXTERNAL_MEMORY
#include <boost/thread/tss.hpp> #include <boost/thread/tss.hpp>
#endif
#include "engine/algorithm.hpp" #include "engine/algorithm.hpp"
#include "util/query_heap.hpp" #include "util/query_heap.hpp"
@ -37,7 +39,6 @@ template <> struct SearchEngineData<routing_algorithms::ch::Algorithm>
{ {
using QueryHeap = util:: using QueryHeap = util::
QueryHeap<NodeID, NodeID, EdgeWeight, HeapData, util::UnorderedMapStorage<NodeID, int>>; QueryHeap<NodeID, NodeID, EdgeWeight, HeapData, util::UnorderedMapStorage<NodeID, int>>;
using SearchEngineHeapPtr = boost::thread_specific_ptr<QueryHeap>;
using ManyToManyQueryHeap = util::QueryHeap<NodeID, using ManyToManyQueryHeap = util::QueryHeap<NodeID,
NodeID, NodeID,
@ -45,7 +46,13 @@ template <> struct SearchEngineData<routing_algorithms::ch::Algorithm>
ManyToManyHeapData, ManyToManyHeapData,
util::UnorderedMapStorage<NodeID, int>>; util::UnorderedMapStorage<NodeID, int>>;
#ifdef OSRM_EXTERNAL_MEMORY
using SearchEngineHeapPtr = std::unique_ptr<QueryHeap>;
using ManyToManyHeapPtr = std::unique_ptr<ManyToManyQueryHeap>;
#else
using SearchEngineHeapPtr = boost::thread_specific_ptr<QueryHeap>;
using ManyToManyHeapPtr = boost::thread_specific_ptr<ManyToManyQueryHeap>; using ManyToManyHeapPtr = boost::thread_specific_ptr<ManyToManyQueryHeap>;
#endif
static SearchEngineHeapPtr forward_heap_1; static SearchEngineHeapPtr forward_heap_1;
static SearchEngineHeapPtr reverse_heap_1; static SearchEngineHeapPtr reverse_heap_1;
@ -105,9 +112,13 @@ template <> struct SearchEngineData<routing_algorithms::mld::Algorithm>
ManyToManyMultiLayerDijkstraHeapData, ManyToManyMultiLayerDijkstraHeapData,
util::UnorderedMapStorage<NodeID, int>>; util::UnorderedMapStorage<NodeID, int>>;
#ifdef OSRM_EXTERNAL_MEMORY
using SearchEngineHeapPtr = std::unique_ptr<QueryHeap>;
using ManyToManyHeapPtr = std::unique_ptr<ManyToManyQueryHeap>;
#else
using SearchEngineHeapPtr = boost::thread_specific_ptr<QueryHeap>; using SearchEngineHeapPtr = boost::thread_specific_ptr<QueryHeap>;
using ManyToManyHeapPtr = boost::thread_specific_ptr<ManyToManyQueryHeap>; using ManyToManyHeapPtr = boost::thread_specific_ptr<ManyToManyQueryHeap>;
#endif
static SearchEngineHeapPtr forward_heap_1; static SearchEngineHeapPtr forward_heap_1;
static SearchEngineHeapPtr reverse_heap_1; static SearchEngineHeapPtr reverse_heap_1;

View File

@ -1,6 +1,11 @@
#include "engine/routing_algorithms/shortest_path.hpp" #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_ch.hpp"
#include "engine/routing_algorithms/routing_base_mld.hpp" #include "engine/routing_algorithms/routing_base_mld.hpp"
#endif
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/optional.hpp> #include <boost/optional.hpp>
@ -456,6 +461,16 @@ InternalRouteResult shortestPathSearch(SearchEngineData<Algorithm> &engine_worki
return raw_route_data; return raw_route_data;
} }
#ifdef OSRM_EXTERNAL_MEMORY
template InternalRouteResult
shortestPathSearch(SearchEngineData<offline::Algorithm> &engine_working_data,
const DataFacade<offline::Algorithm> &facade,
const std::vector<PhantomNodes> &phantom_nodes_vector,
const boost::optional<bool> continue_straight_at_waypoint);
#else
template InternalRouteResult template InternalRouteResult
shortestPathSearch(SearchEngineData<ch::Algorithm> &engine_working_data, shortestPathSearch(SearchEngineData<ch::Algorithm> &engine_working_data,
const DataFacade<ch::Algorithm> &facade, const DataFacade<ch::Algorithm> &facade,
@ -474,6 +489,8 @@ shortestPathSearch(SearchEngineData<mld::Algorithm> &engine_working_data,
const std::vector<PhantomNodes> &phantom_nodes_vector, const std::vector<PhantomNodes> &phantom_nodes_vector,
const boost::optional<bool> continue_straight_at_waypoint); const boost::optional<bool> continue_straight_at_waypoint);
#endif
} // namespace routing_algorithms } // namespace routing_algorithms
} // namespace engine } // namespace engine
} // namespace osrm } // namespace osrm