From 49f0b1eb59398ca275bc76b25d19ac876f994371 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Thu, 13 Jul 2017 13:05:08 +0000 Subject: [PATCH] Add abstraction to change the data facade at compile time --- include/engine/datafacade.hpp | 26 ++++++++++ include/engine/datafacade_provider.hpp | 45 +++++++++------- include/engine/engine.hpp | 30 +++++------ include/engine/plugins/match.hpp | 3 +- include/engine/plugins/nearest.hpp | 3 +- include/engine/plugins/table.hpp | 3 +- include/engine/plugins/tile.hpp | 3 +- include/engine/plugins/trip.hpp | 3 +- include/engine/plugins/viaroute.hpp | 3 +- include/engine/routing_algorithms.hpp | 22 ++++---- .../routing_algorithms/alternative_path.hpp | 20 ++++---- .../direct_shortest_path.hpp | 9 ++-- .../routing_algorithms/many_to_many.hpp | 13 +++-- .../routing_algorithms/map_matching.hpp | 4 +- .../routing_algorithms/routing_base.hpp | 15 +++--- .../routing_algorithms/routing_base_ch.hpp | 49 +++++++++--------- .../routing_algorithms/routing_base_mld.hpp | 23 ++++----- .../routing_algorithms/shortest_path.hpp | 9 ++-- .../engine/routing_algorithms/tile_turns.hpp | 17 +++---- src/engine/plugins/match.cpp | 5 +- src/engine/plugins/nearest.cpp | 10 ++-- src/engine/plugins/table.cpp | 4 +- src/engine/plugins/tile.cpp | 11 ++-- src/engine/plugins/trip.cpp | 4 +- src/engine/plugins/viaroute.cpp | 9 ++-- .../alternative_path_ch.cpp | 51 +++++++++---------- .../alternative_path_mld.cpp | 2 +- .../direct_shortest_path.cpp | 30 +++++------ .../routing_algorithms/many_to_many.cpp | 49 ++++++++---------- .../routing_algorithms/map_matching.cpp | 8 +-- .../routing_algorithms/routing_base_ch.cpp | 10 ++-- .../routing_algorithms/shortest_path.cpp | 21 ++++---- src/engine/routing_algorithms/tile_turns.cpp | 28 ++++------ 33 files changed, 267 insertions(+), 275 deletions(-) create mode 100644 include/engine/datafacade.hpp diff --git a/include/engine/datafacade.hpp b/include/engine/datafacade.hpp new file mode 100644 index 000000000..5da6210a0 --- /dev/null +++ b/include/engine/datafacade.hpp @@ -0,0 +1,26 @@ +#ifndef OSRM_ENGINE_DATAFACADE_DATAFACADE_HPP +#define OSRM_ENGINE_DATAFACADE_DATAFACADE_HPP + +#ifdef OSRM_EXTERNAL_MEMORY + +// Register your own data backend here +#error "No external memory implementation found" + +#else + +#include "engine/datafacade/contiguous_internalmem_datafacade.hpp" + +namespace osrm +{ +namespace engine +{ + +using DataFacadeBase = datafacade::ContiguousInternalMemoryDataFacadeBase; +template +using DataFacade = datafacade::ContiguousInternalMemoryDataFacade; +} +} + +#endif + +#endif diff --git a/include/engine/datafacade_provider.hpp b/include/engine/datafacade_provider.hpp index 25b3a4edf..4b46bb942 100644 --- a/include/engine/datafacade_provider.hpp +++ b/include/engine/datafacade_provider.hpp @@ -2,6 +2,7 @@ #define OSRM_ENGINE_DATAFACADE_PROVIDER_HPP #include "engine/data_watchdog.hpp" +#include "engine/datafacade.hpp" #include "engine/datafacade/contiguous_internalmem_datafacade.hpp" #include "engine/datafacade/process_memory_allocator.hpp" @@ -9,48 +10,56 @@ namespace osrm { namespace engine { - -template class DataFacadeProvider +namespace detail { - using FacadeT = datafacade::ContiguousInternalMemoryDataFacade; +template class FacadeT> class DataFacadeProvider +{ public: + using Facade = FacadeT; + virtual ~DataFacadeProvider() = default; - virtual std::shared_ptr Get() const = 0; + virtual std::shared_ptr Get() const = 0; }; -template class ImmutableProvider final : public DataFacadeProvider +template class FacadeT> +class ImmutableProvider final : public DataFacadeProvider { - using FacadeT = datafacade::ContiguousInternalMemoryDataFacade; - public: + using Facade = typename DataFacadeProvider::Facade; + ImmutableProvider(const storage::StorageConfig &config) - : immutable_data_facade(std::make_shared( + : immutable_data_facade(std::make_shared( std::make_shared(config))) { } - std::shared_ptr Get() const override final { return immutable_data_facade; } + std::shared_ptr Get() const override final { return immutable_data_facade; } private: - std::shared_ptr immutable_data_facade; + std::shared_ptr immutable_data_facade; }; -template class WatchingProvider final : public DataFacadeProvider +template class FacadeT> +class WatchingProvider : public DataFacadeProvider { - using FacadeT = datafacade::ContiguousInternalMemoryDataFacade; DataWatchdog watchdog; public: - std::shared_ptr Get() const override final - { - // We need a singleton here because multiple instances of DataWatchdog - // conflict on shared memory mappings - return watchdog.Get(); - } + using Facade = typename DataFacadeProvider::Facade; + + std::shared_ptr Get() const override final { return watchdog.Get(); } }; } + +template +using DataFacadeProvider = detail::DataFacadeProvider; +template +using WatchingProvider = detail::WatchingProvider; +template +using ImmutableProvider = detail::ImmutableProvider; +} } #endif diff --git a/include/engine/engine.hpp b/include/engine/engine.hpp index cdb4b598e..bd7137131 100644 --- a/include/engine/engine.hpp +++ b/include/engine/engine.hpp @@ -85,47 +85,41 @@ template class Engine final : public EngineInterface Status Route(const api::RouteParameters ¶ms, util::json::Object &result) const override final { - auto facade = facade_provider->Get(); - auto algorithms = RoutingAlgorithms{heaps, *facade}; - return route_plugin.HandleRequest(*facade, algorithms, params, result); + auto algorithms = RoutingAlgorithms{heaps, facade_provider->Get()}; + return route_plugin.HandleRequest(algorithms, params, result); } Status Table(const api::TableParameters ¶ms, util::json::Object &result) const override final { - auto facade = facade_provider->Get(); - auto algorithms = RoutingAlgorithms{heaps, *facade}; - return table_plugin.HandleRequest(*facade, algorithms, params, result); + auto algorithms = RoutingAlgorithms{heaps, facade_provider->Get()}; + return table_plugin.HandleRequest(algorithms, params, result); } Status Nearest(const api::NearestParameters ¶ms, util::json::Object &result) const override final { - auto facade = facade_provider->Get(); - auto algorithms = RoutingAlgorithms{heaps, *facade}; - return nearest_plugin.HandleRequest(*facade, algorithms, params, result); + auto algorithms = RoutingAlgorithms{heaps, facade_provider->Get()}; + return nearest_plugin.HandleRequest(algorithms, params, result); } Status Trip(const api::TripParameters ¶ms, util::json::Object &result) const override final { - auto facade = facade_provider->Get(); - auto algorithms = RoutingAlgorithms{heaps, *facade}; - return trip_plugin.HandleRequest(*facade, algorithms, params, result); + auto algorithms = RoutingAlgorithms{heaps, facade_provider->Get()}; + return trip_plugin.HandleRequest(algorithms, params, result); } Status Match(const api::MatchParameters ¶ms, util::json::Object &result) const override final { - auto facade = facade_provider->Get(); - auto algorithms = RoutingAlgorithms{heaps, *facade}; - return match_plugin.HandleRequest(*facade, algorithms, params, result); + auto algorithms = RoutingAlgorithms{heaps, facade_provider->Get()}; + return match_plugin.HandleRequest(algorithms, params, result); } Status Tile(const api::TileParameters ¶ms, std::string &result) const override final { - auto facade = facade_provider->Get(); - auto algorithms = RoutingAlgorithms{heaps, *facade}; - return tile_plugin.HandleRequest(*facade, algorithms, params, result); + auto algorithms = RoutingAlgorithms{heaps, facade_provider->Get()}; + return tile_plugin.HandleRequest(algorithms, params, result); } static bool CheckCompability(const EngineConfig &config); diff --git a/include/engine/plugins/match.hpp b/include/engine/plugins/match.hpp index 6459dffab..fd8dedf18 100644 --- a/include/engine/plugins/match.hpp +++ b/include/engine/plugins/match.hpp @@ -32,8 +32,7 @@ class MatchPlugin : public BasePlugin { } - Status HandleRequest(const datafacade::ContiguousInternalMemoryDataFacadeBase &facade, - const RoutingAlgorithmsInterface &algorithms, + Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, const api::MatchParameters ¶meters, util::json::Object &json_result) const; diff --git a/include/engine/plugins/nearest.hpp b/include/engine/plugins/nearest.hpp index 95a2021d4..ccc0a4cdd 100644 --- a/include/engine/plugins/nearest.hpp +++ b/include/engine/plugins/nearest.hpp @@ -19,8 +19,7 @@ class NearestPlugin final : public BasePlugin public: explicit NearestPlugin(const int max_results); - Status HandleRequest(const datafacade::ContiguousInternalMemoryDataFacadeBase &facade, - const RoutingAlgorithmsInterface &algorithms, + Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, const api::NearestParameters ¶ms, util::json::Object &result) const; diff --git a/include/engine/plugins/table.hpp b/include/engine/plugins/table.hpp index c2aca80a7..d31877c3c 100644 --- a/include/engine/plugins/table.hpp +++ b/include/engine/plugins/table.hpp @@ -21,8 +21,7 @@ class TablePlugin final : public BasePlugin public: explicit TablePlugin(const int max_locations_distance_table); - Status HandleRequest(const datafacade::ContiguousInternalMemoryDataFacadeBase &facade, - const RoutingAlgorithmsInterface &algorithms, + Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, const api::TableParameters ¶ms, util::json::Object &result) const; diff --git a/include/engine/plugins/tile.hpp b/include/engine/plugins/tile.hpp index f35ef98ea..24d141e35 100644 --- a/include/engine/plugins/tile.hpp +++ b/include/engine/plugins/tile.hpp @@ -26,8 +26,7 @@ namespace plugins class TilePlugin final : public BasePlugin { public: - Status HandleRequest(const datafacade::ContiguousInternalMemoryDataFacadeBase &facade, - const RoutingAlgorithmsInterface &algorithms, + Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, const api::TileParameters ¶meters, std::string &pbf_buffer) const; }; diff --git a/include/engine/plugins/trip.hpp b/include/engine/plugins/trip.hpp index 15702ac59..d49126e19 100644 --- a/include/engine/plugins/trip.hpp +++ b/include/engine/plugins/trip.hpp @@ -38,8 +38,7 @@ class TripPlugin final : public BasePlugin public: explicit TripPlugin(const int max_locations_trip_) : max_locations_trip(max_locations_trip_) {} - Status HandleRequest(const datafacade::ContiguousInternalMemoryDataFacadeBase &facade, - const RoutingAlgorithmsInterface &algorithms, + Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, const api::TripParameters ¶meters, util::json::Object &json_result) const; }; diff --git a/include/engine/plugins/viaroute.hpp b/include/engine/plugins/viaroute.hpp index 1e1234dea..1e64ec962 100644 --- a/include/engine/plugins/viaroute.hpp +++ b/include/engine/plugins/viaroute.hpp @@ -32,8 +32,7 @@ class ViaRoutePlugin final : public BasePlugin public: explicit ViaRoutePlugin(int max_locations_viaroute, int max_alternatives); - Status HandleRequest(const datafacade::ContiguousInternalMemoryDataFacadeBase &facade, - const RoutingAlgorithmsInterface &algorithms, + Status HandleRequest(const RoutingAlgorithmsInterface &algorithms, const api::RouteParameters &route_parameters, util::json::Object &json_result) const; }; diff --git a/include/engine/routing_algorithms.hpp b/include/engine/routing_algorithms.hpp index bd1a44546..f503cb898 100644 --- a/include/engine/routing_algorithms.hpp +++ b/include/engine/routing_algorithms.hpp @@ -46,6 +46,8 @@ class RoutingAlgorithmsInterface GetTileTurns(const std::vector &edges, const std::vector &sorted_edge_indexes) const = 0; + virtual const DataFacadeBase &GetFacade() const = 0; + virtual bool HasAlternativePathSearch() const = 0; virtual bool HasShortestPathSearch() const = 0; virtual bool HasDirectShortestPathSearch() const = 0; @@ -59,7 +61,7 @@ template class RoutingAlgorithms final : public RoutingAlgo { public: RoutingAlgorithms(SearchEngineData &heaps, - const datafacade::ContiguousInternalMemoryDataFacade &facade) + std::shared_ptr> facade) : heaps(heaps), facade(facade) { } @@ -93,6 +95,8 @@ template class RoutingAlgorithms final : public RoutingAlgo GetTileTurns(const std::vector &edges, const std::vector &sorted_edge_indexes) const final override; + const DataFacadeBase &GetFacade() const final override { return *facade; } + bool HasAlternativePathSearch() const final override { return routing_algorithms::HasAlternativePathSearch::value; @@ -125,9 +129,7 @@ template class RoutingAlgorithms final : public RoutingAlgo private: SearchEngineData &heaps; - - // Owned by shared-ptr passed to the query - const datafacade::ContiguousInternalMemoryDataFacade &facade; + std::shared_ptr> facade; }; template @@ -136,7 +138,7 @@ RoutingAlgorithms::AlternativePathSearch(const PhantomNodes &phantom_ unsigned number_of_alternatives) const { return routing_algorithms::alternativePathSearch( - heaps, facade, phantom_node_pair, number_of_alternatives); + heaps, *facade, phantom_node_pair, number_of_alternatives); } template @@ -145,14 +147,14 @@ InternalRouteResult RoutingAlgorithms::ShortestPathSearch( const boost::optional continue_straight_at_waypoint) const { return routing_algorithms::shortestPathSearch( - heaps, facade, phantom_node_pair, continue_straight_at_waypoint); + heaps, *facade, phantom_node_pair, continue_straight_at_waypoint); } template InternalRouteResult RoutingAlgorithms::DirectShortestPathSearch(const PhantomNodes &phantom_nodes) const { - return routing_algorithms::directShortestPathSearch(heaps, facade, phantom_nodes); + return routing_algorithms::directShortestPathSearch(heaps, *facade, phantom_nodes); } template @@ -162,7 +164,7 @@ RoutingAlgorithms::ManyToManySearch(const std::vector &p const std::vector &target_indices) const { return routing_algorithms::manyToManySearch( - heaps, facade, phantom_nodes, source_indices, target_indices); + heaps, *facade, phantom_nodes, source_indices, target_indices); } template @@ -174,7 +176,7 @@ inline routing_algorithms::SubMatchingList RoutingAlgorithms::MapMatc const bool allow_splitting) const { return routing_algorithms::mapMatching(heaps, - facade, + *facade, candidates_list, trace_coordinates, trace_timestamps, @@ -187,7 +189,7 @@ inline std::vector RoutingAlgorithms::G const std::vector &edges, const std::vector &sorted_edge_indexes) const { - return routing_algorithms::getTileTurns(facade, edges, sorted_edge_indexes); + return routing_algorithms::getTileTurns(*facade, edges, sorted_edge_indexes); } // CoreCH overrides diff --git a/include/engine/routing_algorithms/alternative_path.hpp b/include/engine/routing_algorithms/alternative_path.hpp index dff8d25c7..a7801349b 100644 --- a/include/engine/routing_algorithms/alternative_path.hpp +++ b/include/engine/routing_algorithms/alternative_path.hpp @@ -1,7 +1,7 @@ #ifndef ALTERNATIVE_PATH_ROUTING_HPP #define ALTERNATIVE_PATH_ROUTING_HPP -#include "engine/datafacade/contiguous_internalmem_datafacade.hpp" +#include "engine/datafacade.hpp" #include "engine/internal_route_result.hpp" #include "engine/algorithm.hpp" @@ -16,17 +16,15 @@ namespace engine namespace routing_algorithms { -InternalManyRoutesResult -alternativePathSearch(SearchEngineData &search_engine_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const PhantomNodes &phantom_node_pair, - unsigned number_of_alternatives); +InternalManyRoutesResult alternativePathSearch(SearchEngineData &search_engine_data, + const DataFacade &facade, + const PhantomNodes &phantom_node_pair, + unsigned number_of_alternatives); -InternalManyRoutesResult -alternativePathSearch(SearchEngineData &search_engine_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const PhantomNodes &phantom_node_pair, - unsigned number_of_alternatives); +InternalManyRoutesResult alternativePathSearch(SearchEngineData &search_engine_data, + const DataFacade &facade, + const PhantomNodes &phantom_node_pair, + unsigned number_of_alternatives); } // namespace routing_algorithms } // namespace engine diff --git a/include/engine/routing_algorithms/direct_shortest_path.hpp b/include/engine/routing_algorithms/direct_shortest_path.hpp index 6cc5cc488..476ee2e2d 100644 --- a/include/engine/routing_algorithms/direct_shortest_path.hpp +++ b/include/engine/routing_algorithms/direct_shortest_path.hpp @@ -2,7 +2,7 @@ #define DIRECT_SHORTEST_PATH_HPP #include "engine/algorithm.hpp" -#include "engine/datafacade/contiguous_internalmem_datafacade.hpp" +#include "engine/datafacade.hpp" #include "engine/internal_route_result.hpp" #include "engine/search_engine_data.hpp" @@ -22,10 +22,9 @@ namespace routing_algorithms /// This variation is only an optimazation for graphs with slow queries, for example /// not fully contracted graphs. template -InternalRouteResult -directShortestPathSearch(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const PhantomNodes &phantom_nodes); +InternalRouteResult directShortestPathSearch(SearchEngineData &engine_working_data, + const DataFacade &facade, + const PhantomNodes &phantom_nodes); } // namespace routing_algorithms } // namespace engine diff --git a/include/engine/routing_algorithms/many_to_many.hpp b/include/engine/routing_algorithms/many_to_many.hpp index a043aee33..abaddce19 100644 --- a/include/engine/routing_algorithms/many_to_many.hpp +++ b/include/engine/routing_algorithms/many_to_many.hpp @@ -2,7 +2,7 @@ #define MANY_TO_MANY_ROUTING_HPP #include "engine/algorithm.hpp" -#include "engine/datafacade/contiguous_internalmem_datafacade.hpp" +#include "engine/datafacade.hpp" #include "engine/search_engine_data.hpp" #include "util/typedefs.hpp" @@ -17,12 +17,11 @@ namespace routing_algorithms { template -std::vector -manyToManySearch(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const std::vector &phantom_nodes, - const std::vector &source_indices, - const std::vector &target_indices); +std::vector manyToManySearch(SearchEngineData &engine_working_data, + const DataFacade &facade, + const std::vector &phantom_nodes, + const std::vector &source_indices, + const std::vector &target_indices); } // namespace routing_algorithms } // namespace engine diff --git a/include/engine/routing_algorithms/map_matching.hpp b/include/engine/routing_algorithms/map_matching.hpp index 98946337d..359a06340 100644 --- a/include/engine/routing_algorithms/map_matching.hpp +++ b/include/engine/routing_algorithms/map_matching.hpp @@ -2,7 +2,7 @@ #define MAP_MATCHING_HPP #include "engine/algorithm.hpp" -#include "engine/datafacade/contiguous_internalmem_datafacade.hpp" +#include "engine/datafacade.hpp" #include "engine/map_matching/sub_matching.hpp" #include "engine/search_engine_data.hpp" @@ -24,7 +24,7 @@ static const constexpr double DEFAULT_GPS_PRECISION = 5; // P. Newson and J. Krumm; 2009; ACM GIS template SubMatchingList mapMatching(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, const CandidateLists &candidates_list, const std::vector &trace_coordinates, const std::vector &trace_timestamps, diff --git a/include/engine/routing_algorithms/routing_base.hpp b/include/engine/routing_algorithms/routing_base.hpp index 17fde0205..3524adc8e 100644 --- a/include/engine/routing_algorithms/routing_base.hpp +++ b/include/engine/routing_algorithms/routing_base.hpp @@ -4,7 +4,7 @@ #include "extractor/guidance/turn_instruction.hpp" #include "engine/algorithm.hpp" -#include "engine/datafacade/contiguous_internalmem_datafacade.hpp" +#include "engine/datafacade.hpp" #include "engine/internal_route_result.hpp" #include "engine/phantom_node.hpp" #include "engine/search_engine_data.hpp" @@ -320,7 +320,7 @@ void annotatePath(const FacadeT &facade, } template -double getPathDistance(const datafacade::ContiguousInternalMemoryDataFacade &facade, +double getPathDistance(const DataFacade &facade, const std::vector unpacked_path, const PhantomNode &source_phantom, const PhantomNode &target_phantom) @@ -373,12 +373,11 @@ double getPathDistance(const datafacade::ContiguousInternalMemoryDataFacade -InternalRouteResult -extractRoute(const datafacade::ContiguousInternalMemoryDataFacade &facade, - const EdgeWeight weight, - const PhantomNodes &phantom_nodes, - const std::vector &unpacked_nodes, - const std::vector &unpacked_edges) +InternalRouteResult extractRoute(const DataFacade &facade, + const EdgeWeight weight, + const PhantomNodes &phantom_nodes, + const std::vector &unpacked_nodes, + const std::vector &unpacked_edges) { InternalRouteResult raw_route_data; raw_route_data.segment_end_coordinates = {phantom_nodes}; diff --git a/include/engine/routing_algorithms/routing_base_ch.hpp b/include/engine/routing_algorithms/routing_base_ch.hpp index 0ac059b84..99e38a7f3 100644 --- a/include/engine/routing_algorithms/routing_base_ch.hpp +++ b/include/engine/routing_algorithms/routing_base_ch.hpp @@ -2,7 +2,7 @@ #define OSRM_ENGINE_ROUTING_BASE_CH_HPP #include "engine/algorithm.hpp" -#include "engine/datafacade/contiguous_internalmem_datafacade.hpp" +#include "engine/datafacade.hpp" #include "engine/routing_algorithms/routing_base.hpp" #include "engine/search_engine_data.hpp" @@ -23,7 +23,7 @@ namespace ch // Stalling template -bool stallAtNode(const datafacade::ContiguousInternalMemoryDataFacade &facade, +bool stallAtNode(const DataFacade &facade, const NodeID node, const EdgeWeight weight, const HeapT &query_heap) @@ -49,7 +49,7 @@ bool stallAtNode(const datafacade::ContiguousInternalMemoryDataFacade } template -void relaxOutgoingEdges(const datafacade::ContiguousInternalMemoryDataFacade &facade, +void relaxOutgoingEdges(const DataFacade &facade, const NodeID node, const EdgeWeight weight, SearchEngineData::QueryHeap &heap) @@ -113,7 +113,7 @@ we need to add an offset to the termination criterion. static constexpr bool ENABLE_STALLING = true; static constexpr bool DISABLE_STALLING = false; template -void routingStep(const datafacade::ContiguousInternalMemoryDataFacade &facade, +void routingStep(const DataFacade &facade, SearchEngineData::QueryHeap &forward_heap, SearchEngineData::QueryHeap &reverse_heap, NodeID &middle_node_id, @@ -186,8 +186,7 @@ void routingStep(const datafacade::ContiguousInternalMemoryDataFacade } template -EdgeWeight getLoopWeight(const datafacade::ContiguousInternalMemoryDataFacade &facade, - NodeID node) +EdgeWeight getLoopWeight(const DataFacade &facade, NodeID node) { EdgeWeight loop_weight = UseDuration ? MAXIMAL_EDGE_DURATION : INVALID_EDGE_WEIGHT; for (auto edge : facade.GetAdjacentEdgeRange(node)) @@ -227,7 +226,7 @@ EdgeWeight getLoopWeight(const datafacade::ContiguousInternalMemoryDataFacade -void unpackPath(const datafacade::ContiguousInternalMemoryDataFacade &facade, +void unpackPath(const DataFacade &facade, BidirectionalIterator packed_path_begin, BidirectionalIterator packed_path_end, Callback &&callback) @@ -327,7 +326,7 @@ void unpackPath(const FacadeT &facade, * @param to the node the CH edge finishes at * @param unpacked_path the sequence of original NodeIDs that make up the expanded CH edge */ -void unpackEdge(const datafacade::ContiguousInternalMemoryDataFacade &facade, +void unpackEdge(const DataFacade &facade, const NodeID from, const NodeID to, std::vector &unpacked_path); @@ -354,7 +353,7 @@ void retrievePackedPathFromSingleHeap(const SearchEngineData::QueryHe // requires // a force loop, if the heaps have been initialized with positive offsets. void search(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, SearchEngineData::QueryHeap &forward_heap, SearchEngineData::QueryHeap &reverse_heap, std::int32_t &weight, @@ -367,14 +366,13 @@ void search(SearchEngineData &engine_working_data, // Requires the heaps for be empty // If heaps should be adjusted to be initialized outside of this function, // the addition of force_loop parameters might be required -double -getNetworkDistance(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - SearchEngineData::QueryHeap &forward_heap, - SearchEngineData::QueryHeap &reverse_heap, - const PhantomNode &source_phantom, - const PhantomNode &target_phantom, - int duration_upper_bound = INVALID_EDGE_WEIGHT); +double getNetworkDistance(SearchEngineData &engine_working_data, + const DataFacade &facade, + SearchEngineData::QueryHeap &forward_heap, + SearchEngineData::QueryHeap &reverse_heap, + const PhantomNode &source_phantom, + const PhantomNode &target_phantom, + int duration_upper_bound = INVALID_EDGE_WEIGHT); } // namespace ch @@ -390,7 +388,7 @@ namespace corech // requires // a force loop, if the heaps have been initialized with positive offsets. void search(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, SearchEngineData::QueryHeap &forward_heap, SearchEngineData::QueryHeap &reverse_heap, int &weight, @@ -403,14 +401,13 @@ void search(SearchEngineData &engine_working_data, // Requires the heaps for be empty // If heaps should be adjusted to be initialized outside of this function, // the addition of force_loop parameters might be required -double -getNetworkDistance(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - SearchEngineData::QueryHeap &forward_heap, - SearchEngineData::QueryHeap &reverse_heap, - const PhantomNode &source_phantom, - const PhantomNode &target_phantom, - int duration_upper_bound = INVALID_EDGE_WEIGHT); +double getNetworkDistance(SearchEngineData &engine_working_data, + const DataFacade &facade, + SearchEngineData::QueryHeap &forward_heap, + SearchEngineData::QueryHeap &reverse_heap, + const PhantomNode &source_phantom, + const PhantomNode &target_phantom, + int duration_upper_bound = INVALID_EDGE_WEIGHT); template void unpackPath(const FacadeT &facade, diff --git a/include/engine/routing_algorithms/routing_base_mld.hpp b/include/engine/routing_algorithms/routing_base_mld.hpp index 22192f0a7..102a8f8ed 100644 --- a/include/engine/routing_algorithms/routing_base_mld.hpp +++ b/include/engine/routing_algorithms/routing_base_mld.hpp @@ -2,7 +2,7 @@ #define OSRM_ENGINE_ROUTING_BASE_MLD_HPP #include "engine/algorithm.hpp" -#include "engine/datafacade/contiguous_internalmem_datafacade.hpp" +#include "engine/datafacade.hpp" #include "engine/routing_algorithms/routing_base.hpp" #include "engine/search_engine_data.hpp" @@ -131,7 +131,7 @@ retrievePackedPathFromHeap(const SearchEngineData::QueryHeap &forward } template -void routingStep(const datafacade::ContiguousInternalMemoryDataFacade &facade, +void routingStep(const DataFacade &facade, SearchEngineData::QueryHeap &forward_heap, SearchEngineData::QueryHeap &reverse_heap, NodeID &middle_node, @@ -262,7 +262,7 @@ using UnpackedPath = std::tuple; template UnpackedPath search(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, SearchEngineData::QueryHeap &forward_heap, SearchEngineData::QueryHeap &reverse_heap, const bool force_loop_forward, @@ -390,7 +390,7 @@ UnpackedPath search(SearchEngineData &engine_working_data, // Alias to be compatible with the CH-based search inline void search(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, SearchEngineData::QueryHeap &forward_heap, SearchEngineData::QueryHeap &reverse_heap, EdgeWeight &weight, @@ -442,14 +442,13 @@ void unpackPath(const FacadeT &facade, annotatePath(facade, phantom_nodes, unpacked_nodes, unpacked_edges, unpacked_path); } -inline double -getNetworkDistance(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - SearchEngineData::QueryHeap &forward_heap, - SearchEngineData::QueryHeap &reverse_heap, - const PhantomNode &source_phantom, - const PhantomNode &target_phantom, - EdgeWeight weight_upper_bound = INVALID_EDGE_WEIGHT) +inline double getNetworkDistance(SearchEngineData &engine_working_data, + const DataFacade &facade, + SearchEngineData::QueryHeap &forward_heap, + SearchEngineData::QueryHeap &reverse_heap, + const PhantomNode &source_phantom, + const PhantomNode &target_phantom, + EdgeWeight weight_upper_bound = INVALID_EDGE_WEIGHT) { forward_heap.Clear(); reverse_heap.Clear(); diff --git a/include/engine/routing_algorithms/shortest_path.hpp b/include/engine/routing_algorithms/shortest_path.hpp index ca0c6d21d..8c9e0159d 100644 --- a/include/engine/routing_algorithms/shortest_path.hpp +++ b/include/engine/routing_algorithms/shortest_path.hpp @@ -14,11 +14,10 @@ namespace routing_algorithms { template -InternalRouteResult -shortestPathSearch(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const std::vector &phantom_nodes_vector, - const boost::optional continue_straight_at_waypoint); +InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, + const DataFacade &facade, + const std::vector &phantom_nodes_vector, + const boost::optional continue_straight_at_waypoint); } // namespace routing_algorithms } // namespace engine diff --git a/include/engine/routing_algorithms/tile_turns.hpp b/include/engine/routing_algorithms/tile_turns.hpp index 676ebdf3a..0464f9279 100644 --- a/include/engine/routing_algorithms/tile_turns.hpp +++ b/include/engine/routing_algorithms/tile_turns.hpp @@ -2,7 +2,8 @@ #define OSRM_ENGINE_ROUTING_ALGORITHMS_TILE_TURNS_HPP #include "engine/algorithm.hpp" -#include "engine/datafacade/contiguous_internalmem_datafacade.hpp" +#include "engine/datafacade.hpp" +#include "engine/datafacade/datafacade_base.hpp" #include "util/coordinate.hpp" #include "util/typedefs.hpp" @@ -28,15 +29,13 @@ struct TurnData final using RTreeLeaf = datafacade::BaseDataFacade::RTreeLeaf; -std::vector -getTileTurns(const datafacade::ContiguousInternalMemoryDataFacade &facade, - const std::vector &edges, - const std::vector &sorted_edge_indexes); +std::vector getTileTurns(const DataFacade &facade, + const std::vector &edges, + const std::vector &sorted_edge_indexes); -std::vector -getTileTurns(const datafacade::ContiguousInternalMemoryDataFacade &facade, - const std::vector &edges, - const std::vector &sorted_edge_indexes); +std::vector getTileTurns(const DataFacade &facade, + const std::vector &edges, + const std::vector &sorted_edge_indexes); } // namespace routing_algorithms } // namespace engine diff --git a/src/engine/plugins/match.cpp b/src/engine/plugins/match.cpp index 5cd2b3736..fd1e4c775 100644 --- a/src/engine/plugins/match.cpp +++ b/src/engine/plugins/match.cpp @@ -109,8 +109,7 @@ void filterCandidates(const std::vector &coordinates, } } -Status MatchPlugin::HandleRequest(const datafacade::ContiguousInternalMemoryDataFacadeBase &facade, - const RoutingAlgorithmsInterface &algorithms, +Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, const api::MatchParameters ¶meters, util::json::Object &json_result) const { @@ -121,6 +120,8 @@ Status MatchPlugin::HandleRequest(const datafacade::ContiguousInternalMemoryData json_result); } + const auto &facade = algorithms.GetFacade(); + BOOST_ASSERT(parameters.IsValid()); // enforce maximum number of locations for performance reasons diff --git a/src/engine/plugins/nearest.cpp b/src/engine/plugins/nearest.cpp index ad2142a45..f8ede3b33 100644 --- a/src/engine/plugins/nearest.cpp +++ b/src/engine/plugins/nearest.cpp @@ -19,14 +19,14 @@ namespace plugins NearestPlugin::NearestPlugin(const int max_results_) : max_results{max_results_} {} -Status -NearestPlugin::HandleRequest(const datafacade::ContiguousInternalMemoryDataFacadeBase &facade, - const RoutingAlgorithmsInterface & /*algorithms*/, - const api::NearestParameters ¶ms, - util::json::Object &json_result) const +Status NearestPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, + const api::NearestParameters ¶ms, + util::json::Object &json_result) const { BOOST_ASSERT(params.IsValid()); + const auto &facade = algorithms.GetFacade(); + if (max_results > 0 && (boost::numeric_cast(params.number_of_results) > max_results)) { diff --git a/src/engine/plugins/table.cpp b/src/engine/plugins/table.cpp index 4448b98df..5f524499e 100644 --- a/src/engine/plugins/table.cpp +++ b/src/engine/plugins/table.cpp @@ -28,8 +28,7 @@ TablePlugin::TablePlugin(const int max_locations_distance_table) { } -Status TablePlugin::HandleRequest(const datafacade::ContiguousInternalMemoryDataFacadeBase &facade, - const RoutingAlgorithmsInterface &algorithms, +Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, const api::TableParameters ¶ms, util::json::Object &result) const { @@ -67,6 +66,7 @@ Status TablePlugin::HandleRequest(const datafacade::ContiguousInternalMemoryData return Error("TooBig", "Too many table coordinates", result); } + const auto &facade = algorithms.GetFacade(); auto phantom_nodes = GetPhantomNodes(facade, params); if (phantom_nodes.size() != params.coordinates.size()) diff --git a/src/engine/plugins/tile.cpp b/src/engine/plugins/tile.cpp index 80e027971..fc38f592b 100644 --- a/src/engine/plugins/tile.cpp +++ b/src/engine/plugins/tile.cpp @@ -230,10 +230,7 @@ FixedPoint coordinatesToTilePoint(const util::Coordinate point, const BBox &tile return FixedPoint{px, py}; } -std::vector getEdges(const datafacade::ContiguousInternalMemoryDataFacadeBase &facade, - unsigned x, - unsigned y, - unsigned z) +std::vector getEdges(const DataFacadeBase &facade, unsigned x, unsigned y, unsigned z) { double min_lon, min_lat, max_lon, max_lat; @@ -274,7 +271,7 @@ std::vector getEdgeIndex(const std::vector &edges) return sorted_edge_indexes; } -void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase &facade, +void encodeVectorTile(const DataFacadeBase &facade, unsigned x, unsigned y, unsigned z, @@ -882,13 +879,13 @@ void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase & } } -Status TilePlugin::HandleRequest(const datafacade::ContiguousInternalMemoryDataFacadeBase &facade, - const RoutingAlgorithmsInterface &algorithms, +Status TilePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, const api::TileParameters ¶meters, std::string &pbf_buffer) const { BOOST_ASSERT(parameters.IsValid()); + const auto &facade = algorithms.GetFacade(); auto edges = getEdges(facade, parameters.x, parameters.y, parameters.z); auto edge_index = getEdgeIndex(edges); diff --git a/src/engine/plugins/trip.cpp b/src/engine/plugins/trip.cpp index 2346a765e..5d5f6a487 100644 --- a/src/engine/plugins/trip.cpp +++ b/src/engine/plugins/trip.cpp @@ -142,8 +142,7 @@ void ManipulateTableForFSE(const std::size_t source_id, //********* End of changes to table ************************************* } -Status TripPlugin::HandleRequest(const datafacade::ContiguousInternalMemoryDataFacadeBase &facade, - const RoutingAlgorithmsInterface &algorithms, +Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, const api::TripParameters ¶meters, util::json::Object &json_result) const { @@ -192,6 +191,7 @@ Status TripPlugin::HandleRequest(const datafacade::ContiguousInternalMemoryDataF return Error("InvalidValue", "Invalid coordinate value.", json_result); } + const auto &facade = algorithms.GetFacade(); auto phantom_node_pairs = GetPhantomNodes(facade, parameters); if (phantom_node_pairs.size() != number_of_locations) { diff --git a/src/engine/plugins/viaroute.cpp b/src/engine/plugins/viaroute.cpp index c80c0411b..0740d70aa 100644 --- a/src/engine/plugins/viaroute.cpp +++ b/src/engine/plugins/viaroute.cpp @@ -26,11 +26,9 @@ ViaRoutePlugin::ViaRoutePlugin(int max_locations_viaroute, int max_alternatives) { } -Status -ViaRoutePlugin::HandleRequest(const datafacade::ContiguousInternalMemoryDataFacadeBase &facade, - const RoutingAlgorithmsInterface &algorithms, - const api::RouteParameters &route_parameters, - util::json::Object &json_result) const +Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, + const api::RouteParameters &route_parameters, + util::json::Object &json_result) const { BOOST_ASSERT(route_parameters.IsValid()); @@ -75,6 +73,7 @@ ViaRoutePlugin::HandleRequest(const datafacade::ContiguousInternalMemoryDataFaca return Error("InvalidValue", "Invalid coordinate value.", json_result); } + const auto &facade = algorithms.GetFacade(); auto phantom_node_pairs = GetPhantomNodes(facade, route_parameters); if (phantom_node_pairs.size() != route_parameters.coordinates.size()) { diff --git a/src/engine/routing_algorithms/alternative_path_ch.cpp b/src/engine/routing_algorithms/alternative_path_ch.cpp index a738aa415..0fafa2447 100644 --- a/src/engine/routing_algorithms/alternative_path_ch.cpp +++ b/src/engine/routing_algorithms/alternative_path_ch.cpp @@ -50,7 +50,7 @@ struct RankedCandidateNode // todo: reorder parameters template -void alternativeRoutingStep(const datafacade::ContiguousInternalMemoryDataFacade &facade, +void alternativeRoutingStep(const DataFacade &facade, QueryHeap &heap1, QueryHeap &heap2, NodeID *middle_node, @@ -153,14 +153,13 @@ void retrievePackedAlternatePath(const QueryHeap &forward_heap1, // compute and unpack and by exploring search spaces // from v and intersecting against queues. only half-searches have to be // done at this stage -void computeWeightAndSharingOfViaPath( - SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const NodeID via_node, - EdgeWeight *real_weight_of_via_path, - EdgeWeight *sharing_of_via_path, - const std::vector &packed_shortest_path, - const EdgeWeight min_edge_offset) +void computeWeightAndSharingOfViaPath(SearchEngineData &engine_working_data, + const DataFacade &facade, + const NodeID via_node, + EdgeWeight *real_weight_of_via_path, + EdgeWeight *sharing_of_via_path, + const std::vector &packed_shortest_path, + const EdgeWeight min_edge_offset) { engine_working_data.InitializeOrClearSecondThreadLocalStorage(facade.GetNumberOfNodes()); @@ -318,19 +317,18 @@ void computeWeightAndSharingOfViaPath( } // conduct T-Test -bool viaNodeCandidatePassesTTest( - SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - QueryHeap &existing_forward_heap, - QueryHeap &existing_reverse_heap, - QueryHeap &new_forward_heap, - QueryHeap &new_reverse_heap, - const RankedCandidateNode &candidate, - const EdgeWeight weight_of_shortest_path, - EdgeWeight *weight_of_via_path, - NodeID *s_v_middle, - NodeID *v_t_middle, - const EdgeWeight min_edge_offset) +bool viaNodeCandidatePassesTTest(SearchEngineData &engine_working_data, + const DataFacade &facade, + QueryHeap &existing_forward_heap, + QueryHeap &existing_reverse_heap, + QueryHeap &new_forward_heap, + QueryHeap &new_reverse_heap, + const RankedCandidateNode &candidate, + const EdgeWeight weight_of_shortest_path, + EdgeWeight *weight_of_via_path, + NodeID *s_v_middle, + NodeID *v_t_middle, + const EdgeWeight min_edge_offset) { new_forward_heap.Clear(); new_reverse_heap.Clear(); @@ -562,11 +560,10 @@ bool viaNodeCandidatePassesTTest( } } // anon. namespace -InternalManyRoutesResult -alternativePathSearch(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const PhantomNodes &phantom_node_pair, - unsigned /*number_of_alternatives*/) +InternalManyRoutesResult alternativePathSearch(SearchEngineData &engine_working_data, + const DataFacade &facade, + const PhantomNodes &phantom_node_pair, + unsigned /*number_of_alternatives*/) { InternalRouteResult primary_route; InternalRouteResult secondary_route; diff --git a/src/engine/routing_algorithms/alternative_path_mld.cpp b/src/engine/routing_algorithms/alternative_path_mld.cpp index 83f4a8e9b..5d87f2cad 100644 --- a/src/engine/routing_algorithms/alternative_path_mld.cpp +++ b/src/engine/routing_algorithms/alternative_path_mld.cpp @@ -28,7 +28,7 @@ using namespace mld; using Heap = SearchEngineData::QueryHeap; using Partition = partition::MultiLevelPartitionView; -using Facade = datafacade::ContiguousInternalMemoryDataFacade; +using Facade = DataFacade; // Implementation details namespace diff --git a/src/engine/routing_algorithms/direct_shortest_path.cpp b/src/engine/routing_algorithms/direct_shortest_path.cpp index 9927cffec..d5a07a8a0 100644 --- a/src/engine/routing_algorithms/direct_shortest_path.cpp +++ b/src/engine/routing_algorithms/direct_shortest_path.cpp @@ -18,10 +18,9 @@ namespace routing_algorithms /// This variation is only an optimazation for graphs with slow queries, for example /// not fully contracted graphs. template -InternalRouteResult -directShortestPathSearch(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const PhantomNodes &phantom_nodes) +InternalRouteResult directShortestPathSearch(SearchEngineData &engine_working_data, + const DataFacade &facade, + const PhantomNodes &phantom_nodes) { engine_working_data.InitializeOrClearFirstThreadLocalStorage(facade.GetNumberOfNodes()); auto &forward_heap = *engine_working_data.forward_heap_1; @@ -65,21 +64,20 @@ directShortestPathSearch(SearchEngineData &engine_working_data, return extractRoute(facade, weight, phantom_nodes, unpacked_nodes, unpacked_edges); } -template InternalRouteResult directShortestPathSearch( - SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const PhantomNodes &phantom_nodes); +template InternalRouteResult +directShortestPathSearch(SearchEngineData &engine_working_data, + const DataFacade &facade, + const PhantomNodes &phantom_nodes); -template InternalRouteResult directShortestPathSearch( - SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const PhantomNodes &phantom_nodes); +template InternalRouteResult +directShortestPathSearch(SearchEngineData &engine_working_data, + const DataFacade &facade, + const PhantomNodes &phantom_nodes); template <> -InternalRouteResult directShortestPathSearch( - SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const PhantomNodes &phantom_nodes) +InternalRouteResult directShortestPathSearch(SearchEngineData &engine_working_data, + const DataFacade &facade, + const PhantomNodes &phantom_nodes) { engine_working_data.InitializeOrClearFirstThreadLocalStorage(facade.GetNumberOfNodes()); auto &forward_heap = *engine_working_data.forward_heap_1; diff --git a/src/engine/routing_algorithms/many_to_many.cpp b/src/engine/routing_algorithms/many_to_many.cpp index f7619757d..f272ca6f2 100644 --- a/src/engine/routing_algorithms/many_to_many.cpp +++ b/src/engine/routing_algorithms/many_to_many.cpp @@ -31,11 +31,10 @@ struct NodeBucket // FIXME This should be replaced by an std::unordered_multimap, though this needs benchmarking using SearchSpaceWithBuckets = std::unordered_map>; -inline bool -addLoopWeight(const datafacade::ContiguousInternalMemoryDataFacade &facade, - const NodeID node, - EdgeWeight &weight, - EdgeDuration &duration) +inline bool addLoopWeight(const DataFacade &facade, + const NodeID node, + EdgeWeight &weight, + EdgeDuration &duration) { // Special case for CH when contractor creates a loop edge node->node BOOST_ASSERT(weight < 0); @@ -56,7 +55,7 @@ addLoopWeight(const datafacade::ContiguousInternalMemoryDataFacade -void relaxOutgoingEdges(const datafacade::ContiguousInternalMemoryDataFacade &facade, +void relaxOutgoingEdges(const DataFacade &facade, const NodeID node, const EdgeWeight weight, const EdgeDuration duration, @@ -97,22 +96,19 @@ void relaxOutgoingEdges(const datafacade::ContiguousInternalMemoryDataFacade &, - const NodeID, - EdgeWeight &, - EdgeDuration &) +inline bool +addLoopWeight(const DataFacade &, const NodeID, EdgeWeight &, EdgeDuration &) { // MLD overlay does not introduce loop edges return false; } template -void relaxOutgoingEdges( - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const NodeID node, - const EdgeWeight weight, - const EdgeDuration duration, - typename SearchEngineData::ManyToManyQueryHeap &query_heap, - const PhantomNode &phantom_node) +void relaxOutgoingEdges(const DataFacade &facade, + const NodeID node, + const EdgeWeight weight, + const EdgeDuration duration, + typename SearchEngineData::ManyToManyQueryHeap &query_heap, + const PhantomNode &phantom_node) { const auto &partition = facade.GetMultiLevelPartition(); const auto &cells = facade.GetCellStorage(); @@ -218,7 +214,7 @@ void relaxOutgoingEdges( } template -void forwardRoutingStep(const datafacade::ContiguousInternalMemoryDataFacade &facade, +void forwardRoutingStep(const DataFacade &facade, const unsigned row_idx, const unsigned number_of_targets, typename SearchEngineData::ManyToManyQueryHeap &query_heap, @@ -272,7 +268,7 @@ void forwardRoutingStep(const datafacade::ContiguousInternalMemoryDataFacade -void backwardRoutingStep(const datafacade::ContiguousInternalMemoryDataFacade &facade, +void backwardRoutingStep(const DataFacade &facade, const unsigned column_idx, typename SearchEngineData::ManyToManyQueryHeap &query_heap, SearchSpaceWithBuckets &search_space_with_buckets, @@ -291,12 +287,11 @@ void backwardRoutingStep(const datafacade::ContiguousInternalMemoryDataFacade -std::vector -manyToManySearch(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const std::vector &phantom_nodes, - const std::vector &source_indices, - const std::vector &target_indices) +std::vector manyToManySearch(SearchEngineData &engine_working_data, + const DataFacade &facade, + const std::vector &phantom_nodes, + const std::vector &source_indices, + const std::vector &target_indices) { const auto number_of_sources = source_indices.empty() ? phantom_nodes.size() : source_indices.size(); @@ -386,14 +381,14 @@ manyToManySearch(SearchEngineData &engine_working_data, template std::vector manyToManySearch(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, const std::vector &phantom_nodes, const std::vector &source_indices, const std::vector &target_indices); template std::vector manyToManySearch(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, const std::vector &phantom_nodes, const std::vector &source_indices, const std::vector &target_indices); diff --git a/src/engine/routing_algorithms/map_matching.cpp b/src/engine/routing_algorithms/map_matching.cpp index c06a2ff44..d1d5bb00d 100644 --- a/src/engine/routing_algorithms/map_matching.cpp +++ b/src/engine/routing_algorithms/map_matching.cpp @@ -50,7 +50,7 @@ unsigned getMedianSampleTime(const std::vector ×tamps) template SubMatchingList mapMatching(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, const CandidateLists &candidates_list, const std::vector &trace_coordinates, const std::vector &trace_timestamps, @@ -422,7 +422,7 @@ SubMatchingList mapMatching(SearchEngineData &engine_working_data, template SubMatchingList mapMatching(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, const CandidateLists &candidates_list, const std::vector &trace_coordinates, const std::vector &trace_timestamps, @@ -431,7 +431,7 @@ mapMatching(SearchEngineData &engine_working_data, template SubMatchingList mapMatching(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, const CandidateLists &candidates_list, const std::vector &trace_coordinates, const std::vector &trace_timestamps, @@ -440,7 +440,7 @@ mapMatching(SearchEngineData &engine_working_data, template SubMatchingList mapMatching(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, const CandidateLists &candidates_list, const std::vector &trace_coordinates, const std::vector &trace_timestamps, diff --git a/src/engine/routing_algorithms/routing_base_ch.cpp b/src/engine/routing_algorithms/routing_base_ch.cpp index b693f4330..5f228a111 100644 --- a/src/engine/routing_algorithms/routing_base_ch.cpp +++ b/src/engine/routing_algorithms/routing_base_ch.cpp @@ -16,7 +16,7 @@ namespace ch * @param to the node the CH edge finishes at * @param unpacked_path the sequence of original NodeIDs that make up the expanded CH edge */ -void unpackEdge(const datafacade::ContiguousInternalMemoryDataFacade &facade, +void unpackEdge(const DataFacade &facade, const NodeID from, const NodeID to, std::vector &unpacked_path) @@ -72,7 +72,7 @@ void retrievePackedPathFromSingleHeap(const SearchEngineData::QueryHe // requires // a force loop, if the heaps have been initialized with positive offsets. void search(SearchEngineData & /*engine_working_data*/, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, SearchEngineData::QueryHeap &forward_heap, SearchEngineData::QueryHeap &reverse_heap, EdgeWeight &weight, @@ -151,7 +151,7 @@ void search(SearchEngineData & /*engine_working_data*/, // If heaps should be adjusted to be initialized outside of this function, // the addition of force_loop parameters might be required double getNetworkDistance(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, SearchEngineData::QueryHeap &forward_heap, SearchEngineData::QueryHeap &reverse_heap, const PhantomNode &source_phantom, @@ -204,7 +204,7 @@ namespace corech // requires // a force loop, if the heaps have been initialized with positive offsets. void search(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, SearchEngineData::QueryHeap &forward_heap, SearchEngineData::QueryHeap &reverse_heap, EdgeWeight &weight, @@ -384,7 +384,7 @@ void search(SearchEngineData &engine_working_data, // If heaps should be adjusted to be initialized outside of this function, // the addition of force_loop parameters might be required double getNetworkDistance(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, SearchEngineData::QueryHeap &forward_heap, SearchEngineData::QueryHeap &reverse_heap, const PhantomNode &source_phantom, diff --git a/src/engine/routing_algorithms/shortest_path.cpp b/src/engine/routing_algorithms/shortest_path.cpp index a7a37e567..87cd75b63 100644 --- a/src/engine/routing_algorithms/shortest_path.cpp +++ b/src/engine/routing_algorithms/shortest_path.cpp @@ -22,7 +22,7 @@ const static constexpr bool DO_NOT_FORCE_LOOP = false; // searches source forward/reverse -> target forward/reverse template void searchWithUTurn(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, typename SearchEngineData::QueryHeap &forward_heap, typename SearchEngineData::QueryHeap &reverse_heap, const bool search_from_forward_node, @@ -93,7 +93,7 @@ void searchWithUTurn(SearchEngineData &engine_working_data, // source forward/reverse -> target reverse template void search(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, typename SearchEngineData::QueryHeap &forward_heap, typename SearchEngineData::QueryHeap &reverse_heap, const bool search_from_forward_node, @@ -178,7 +178,7 @@ void search(SearchEngineData &engine_working_data, } template -void unpackLegs(const datafacade::ContiguousInternalMemoryDataFacade &facade, +void unpackLegs(const DataFacade &facade, const std::vector &phantom_nodes_vector, const std::vector &total_packed_path, const std::vector &packed_leg_begin, @@ -210,11 +210,10 @@ void unpackLegs(const datafacade::ContiguousInternalMemoryDataFacade } template -InternalRouteResult -shortestPathSearch(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, - const std::vector &phantom_nodes_vector, - const boost::optional continue_straight_at_waypoint) +InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, + const DataFacade &facade, + const std::vector &phantom_nodes_vector, + const boost::optional continue_straight_at_waypoint) { InternalRouteResult raw_route_data; raw_route_data.segment_end_coordinates = phantom_nodes_vector; @@ -459,19 +458,19 @@ shortestPathSearch(SearchEngineData &engine_working_data, template InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, const std::vector &phantom_nodes_vector, const boost::optional continue_straight_at_waypoint); template InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, const std::vector &phantom_nodes_vector, const boost::optional continue_straight_at_waypoint); template InternalRouteResult shortestPathSearch(SearchEngineData &engine_working_data, - const datafacade::ContiguousInternalMemoryDataFacade &facade, + const DataFacade &facade, const std::vector &phantom_nodes_vector, const boost::optional continue_straight_at_waypoint); diff --git a/src/engine/routing_algorithms/tile_turns.cpp b/src/engine/routing_algorithms/tile_turns.cpp index d49a9dad2..2af802be4 100644 --- a/src/engine/routing_algorithms/tile_turns.cpp +++ b/src/engine/routing_algorithms/tile_turns.cpp @@ -227,19 +227,15 @@ std::vector generateTurns(const datafacade &facade, } // namespace // CH Version of finding all turn penalties. Here is where the actual work is happening -std::vector -getTileTurns(const datafacade::ContiguousInternalMemoryDataFacade &facade, - const std::vector &edges, - const std::vector &sorted_edge_indexes) +std::vector getTileTurns(const DataFacade &facade, + const std::vector &edges, + const std::vector &sorted_edge_indexes) { // Define how to find the representative edge between two edge based nodes for a CH struct EdgeFinderCH { - EdgeFinderCH(const datafacade::ContiguousInternalMemoryDataFacade &facade) - : facade(facade) - { - } - const datafacade::ContiguousInternalMemoryDataFacade &facade; + EdgeFinderCH(const DataFacade &facade) : facade(facade) {} + const DataFacade &facade; EdgeID operator()(const NodeID approach_node, const NodeID exit_node) const { @@ -283,19 +279,15 @@ getTileTurns(const datafacade::ContiguousInternalMemoryDataFacade } // MLD version to find all turns -std::vector -getTileTurns(const datafacade::ContiguousInternalMemoryDataFacade &facade, - const std::vector &edges, - const std::vector &sorted_edge_indexes) +std::vector getTileTurns(const DataFacade &facade, + const std::vector &edges, + const std::vector &sorted_edge_indexes) { // Define how to find the representative edge between two edge-based-nodes for a MLD struct EdgeFinderMLD { - EdgeFinderMLD(const datafacade::ContiguousInternalMemoryDataFacade &facade) - : facade(facade) - { - } - const datafacade::ContiguousInternalMemoryDataFacade &facade; + EdgeFinderMLD(const DataFacade &facade) : facade(facade) {} + const DataFacade &facade; EdgeID operator()(const NodeID approach_node, const NodeID exit_node) const {