2014-11-28 06:13:18 -05:00
|
|
|
#ifndef SEARCH_ENGINE_DATA_HPP
|
|
|
|
#define SEARCH_ENGINE_DATA_HPP
|
2013-09-19 12:52:42 -04:00
|
|
|
|
2017-03-31 15:53:39 -04:00
|
|
|
#include "engine/algorithm.hpp"
|
2017-05-02 07:12:28 -04:00
|
|
|
#include "util/query_heap.hpp"
|
2016-05-27 15:05:04 -04:00
|
|
|
#include "util/typedefs.hpp"
|
2013-06-24 14:11:53 -04:00
|
|
|
|
2022-12-11 04:10:26 -05:00
|
|
|
namespace osrm::engine
|
2016-01-05 10:51:13 -05:00
|
|
|
{
|
|
|
|
|
2017-04-12 02:22:28 -04:00
|
|
|
// Algorithm-dependent heaps
|
|
|
|
// - CH algorithms use CH heaps
|
|
|
|
// - MLD algorithms use MLD heaps
|
|
|
|
|
2017-04-11 15:38:26 -04:00
|
|
|
template <typename Algorithm> struct SearchEngineData
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2014-05-05 11:19:47 -04:00
|
|
|
struct HeapData
|
|
|
|
{
|
2013-06-24 14:11:53 -04:00
|
|
|
NodeID parent;
|
2014-05-05 11:19:47 -04:00
|
|
|
/* explicit */ HeapData(NodeID p) : parent(p) {}
|
2013-06-24 14:11:53 -04:00
|
|
|
};
|
2013-09-19 12:52:42 -04:00
|
|
|
|
2017-01-19 16:52:09 -05:00
|
|
|
struct ManyToManyHeapData : HeapData
|
|
|
|
{
|
2022-10-28 10:16:12 -04:00
|
|
|
EdgeDuration duration;
|
2018-10-30 00:47:49 -04:00
|
|
|
EdgeDistance distance;
|
2022-10-28 10:16:12 -04:00
|
|
|
ManyToManyHeapData(NodeID p, EdgeDuration duration, EdgeDistance distance)
|
2018-10-30 00:47:49 -04:00
|
|
|
: HeapData(p), duration(duration), distance(distance)
|
|
|
|
{
|
|
|
|
}
|
2017-01-19 16:52:09 -05:00
|
|
|
};
|
|
|
|
|
2017-04-11 15:38:26 -04:00
|
|
|
template <> struct SearchEngineData<routing_algorithms::ch::Algorithm>
|
2014-05-05 11:19:47 -04:00
|
|
|
{
|
2016-05-12 12:50:10 -04:00
|
|
|
using QueryHeap = util::
|
2017-05-02 07:12:28 -04:00
|
|
|
QueryHeap<NodeID, NodeID, EdgeWeight, HeapData, util::UnorderedMapStorage<NodeID, int>>;
|
2013-08-20 11:05:36 -04:00
|
|
|
|
2017-05-02 07:12:28 -04:00
|
|
|
using ManyToManyQueryHeap = util::QueryHeap<NodeID,
|
|
|
|
NodeID,
|
|
|
|
EdgeWeight,
|
|
|
|
ManyToManyHeapData,
|
|
|
|
util::UnorderedMapStorage<NodeID, int>>;
|
2017-01-19 16:52:09 -05:00
|
|
|
|
2024-07-11 17:53:22 -04:00
|
|
|
using SearchEngineHeapPtr = std::unique_ptr<QueryHeap>;
|
2024-05-23 14:46:13 -04:00
|
|
|
|
2024-07-11 17:53:22 -04:00
|
|
|
using ManyToManyHeapPtr = std::unique_ptr<ManyToManyQueryHeap>;
|
2017-01-19 16:52:09 -05:00
|
|
|
|
2024-07-11 17:53:22 -04:00
|
|
|
static thread_local SearchEngineHeapPtr forward_heap_1;
|
|
|
|
static thread_local SearchEngineHeapPtr reverse_heap_1;
|
|
|
|
static thread_local SearchEngineHeapPtr forward_heap_2;
|
|
|
|
static thread_local SearchEngineHeapPtr reverse_heap_2;
|
|
|
|
static thread_local SearchEngineHeapPtr forward_heap_3;
|
|
|
|
static thread_local SearchEngineHeapPtr reverse_heap_3;
|
|
|
|
static thread_local ManyToManyHeapPtr many_to_many_heap;
|
|
|
|
static thread_local SearchEngineHeapPtr map_matching_forward_heap_1;
|
|
|
|
static thread_local SearchEngineHeapPtr map_matching_reverse_heap_1;
|
2024-05-23 14:46:13 -04:00
|
|
|
|
|
|
|
void InitializeOrClearMapMatchingThreadLocalStorage(unsigned number_of_nodes);
|
2013-06-24 14:11:53 -04:00
|
|
|
|
2017-04-03 13:15:58 -04:00
|
|
|
void InitializeOrClearFirstThreadLocalStorage(unsigned number_of_nodes);
|
2017-03-31 15:53:39 -04:00
|
|
|
|
2017-04-03 13:15:58 -04:00
|
|
|
void InitializeOrClearSecondThreadLocalStorage(unsigned number_of_nodes);
|
2017-03-31 15:53:39 -04:00
|
|
|
|
2017-04-03 13:15:58 -04:00
|
|
|
void InitializeOrClearThirdThreadLocalStorage(unsigned number_of_nodes);
|
2017-03-31 15:53:39 -04:00
|
|
|
|
2017-04-03 13:15:58 -04:00
|
|
|
void InitializeOrClearManyToManyThreadLocalStorage(unsigned number_of_nodes);
|
|
|
|
};
|
2017-03-31 15:53:39 -04:00
|
|
|
|
2017-04-03 13:15:58 -04:00
|
|
|
struct MultiLayerDijkstraHeapData
|
|
|
|
{
|
|
|
|
NodeID parent;
|
|
|
|
bool from_clique_arc;
|
|
|
|
MultiLayerDijkstraHeapData(NodeID p) : parent(p), from_clique_arc(false) {}
|
|
|
|
MultiLayerDijkstraHeapData(NodeID p, bool from) : parent(p), from_clique_arc(from) {}
|
|
|
|
};
|
2017-03-31 15:53:39 -04:00
|
|
|
|
2024-05-23 14:46:13 -04:00
|
|
|
struct MapMatchingMultiLayerDijkstraHeapData
|
|
|
|
{
|
|
|
|
NodeID parent;
|
|
|
|
bool from_clique_arc;
|
|
|
|
EdgeDistance distance = {0};
|
|
|
|
MapMatchingMultiLayerDijkstraHeapData(NodeID p) : parent(p), from_clique_arc(false) {}
|
|
|
|
MapMatchingMultiLayerDijkstraHeapData(NodeID p, bool from) : parent(p), from_clique_arc(from) {}
|
|
|
|
MapMatchingMultiLayerDijkstraHeapData(NodeID p, bool from, EdgeDistance d)
|
|
|
|
: parent(p), from_clique_arc(from), distance(d)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-06-27 18:48:18 -04:00
|
|
|
struct ManyToManyMultiLayerDijkstraHeapData : MultiLayerDijkstraHeapData
|
|
|
|
{
|
2022-10-28 10:16:12 -04:00
|
|
|
EdgeDuration duration;
|
2018-10-30 00:47:49 -04:00
|
|
|
EdgeDistance distance;
|
2022-10-28 10:16:12 -04:00
|
|
|
ManyToManyMultiLayerDijkstraHeapData(NodeID p, EdgeDuration duration, EdgeDistance distance)
|
2018-10-30 00:47:49 -04:00
|
|
|
: MultiLayerDijkstraHeapData(p), duration(duration), distance(distance)
|
2017-06-27 18:48:18 -04:00
|
|
|
{
|
|
|
|
}
|
2018-10-30 00:47:49 -04:00
|
|
|
ManyToManyMultiLayerDijkstraHeapData(NodeID p,
|
|
|
|
bool from,
|
2022-10-28 10:16:12 -04:00
|
|
|
EdgeDuration duration,
|
2018-10-30 00:47:49 -04:00
|
|
|
EdgeDistance distance)
|
|
|
|
: MultiLayerDijkstraHeapData(p, from), duration(duration), distance(distance)
|
2017-06-27 18:48:18 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-04-03 13:15:58 -04:00
|
|
|
template <> struct SearchEngineData<routing_algorithms::mld::Algorithm>
|
|
|
|
{
|
2017-05-02 07:12:28 -04:00
|
|
|
using QueryHeap = util::QueryHeap<NodeID,
|
|
|
|
NodeID,
|
|
|
|
EdgeWeight,
|
|
|
|
MultiLayerDijkstraHeapData,
|
2018-04-08 12:37:08 -04:00
|
|
|
util::TwoLevelStorage<NodeID, int>>;
|
2013-06-24 14:11:53 -04:00
|
|
|
|
2017-06-27 18:48:18 -04:00
|
|
|
using ManyToManyQueryHeap = util::QueryHeap<NodeID,
|
|
|
|
NodeID,
|
|
|
|
EdgeWeight,
|
|
|
|
ManyToManyMultiLayerDijkstraHeapData,
|
2018-04-08 12:37:08 -04:00
|
|
|
util::TwoLevelStorage<NodeID, int>>;
|
2024-05-23 14:46:13 -04:00
|
|
|
using MapMatchingQueryHeap = util::QueryHeap<NodeID,
|
|
|
|
NodeID,
|
|
|
|
EdgeWeight,
|
|
|
|
MapMatchingMultiLayerDijkstraHeapData,
|
|
|
|
util::TwoLevelStorage<NodeID, int>>;
|
2017-06-27 18:48:18 -04:00
|
|
|
|
2024-07-11 17:53:22 -04:00
|
|
|
using SearchEngineHeapPtr = std::unique_ptr<QueryHeap>;
|
|
|
|
using ManyToManyHeapPtr = std::unique_ptr<ManyToManyQueryHeap>;
|
|
|
|
using MapMatchingHeapPtr = std::unique_ptr<MapMatchingQueryHeap>;
|
2017-06-27 18:48:18 -04:00
|
|
|
|
2024-07-11 17:53:22 -04:00
|
|
|
static thread_local SearchEngineHeapPtr forward_heap_1;
|
|
|
|
static thread_local SearchEngineHeapPtr reverse_heap_1;
|
|
|
|
static thread_local MapMatchingHeapPtr map_matching_forward_heap_1;
|
|
|
|
static thread_local MapMatchingHeapPtr map_matching_reverse_heap_1;
|
2024-05-23 14:46:13 -04:00
|
|
|
|
2024-07-11 17:53:22 -04:00
|
|
|
static thread_local ManyToManyHeapPtr many_to_many_heap;
|
2017-01-19 16:52:09 -05:00
|
|
|
|
2018-04-08 12:37:08 -04:00
|
|
|
void InitializeOrClearFirstThreadLocalStorage(unsigned number_of_nodes,
|
|
|
|
unsigned number_of_boundary_nodes);
|
2024-05-23 14:46:13 -04:00
|
|
|
void InitializeOrClearMapMatchingThreadLocalStorage(unsigned number_of_nodes,
|
|
|
|
unsigned number_of_boundary_nodes);
|
2017-06-27 18:48:18 -04:00
|
|
|
|
2018-04-08 12:37:08 -04:00
|
|
|
void InitializeOrClearManyToManyThreadLocalStorage(unsigned number_of_nodes,
|
|
|
|
unsigned number_of_boundary_nodes);
|
2013-06-24 14:11:53 -04:00
|
|
|
};
|
2022-12-20 12:00:11 -05:00
|
|
|
} // namespace osrm::engine
|
2016-01-05 10:51:13 -05:00
|
|
|
|
2024-07-11 17:53:22 -04:00
|
|
|
#endif // SEARCH_ENGINE_DATA_HPP
|