-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
search_engine_data.hpp
149 lines (122 loc) · 5.7 KB
/
search_engine_data.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#ifndef SEARCH_ENGINE_DATA_HPP
#define SEARCH_ENGINE_DATA_HPP
#include "engine/algorithm.hpp"
#include "util/query_heap.hpp"
#include "util/typedefs.hpp"
namespace osrm::engine
{
// Algorithm-dependent heaps
// - CH algorithms use CH heaps
// - MLD algorithms use MLD heaps
template <typename Algorithm> struct SearchEngineData
{
};
struct HeapData
{
NodeID parent;
/* explicit */ HeapData(NodeID p) : parent(p) {}
};
struct ManyToManyHeapData : HeapData
{
EdgeDuration duration;
EdgeDistance distance;
ManyToManyHeapData(NodeID p, EdgeDuration duration, EdgeDistance distance)
: HeapData(p), duration(duration), distance(distance)
{
}
};
template <> struct SearchEngineData<routing_algorithms::ch::Algorithm>
{
using QueryHeap = util::
QueryHeap<NodeID, NodeID, EdgeWeight, HeapData, util::UnorderedMapStorage<NodeID, int>>;
using ManyToManyQueryHeap = util::QueryHeap<NodeID,
NodeID,
EdgeWeight,
ManyToManyHeapData,
util::UnorderedMapStorage<NodeID, int>>;
using SearchEngineHeapPtr = std::unique_ptr<QueryHeap>;
using ManyToManyHeapPtr = std::unique_ptr<ManyToManyQueryHeap>;
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;
void InitializeOrClearMapMatchingThreadLocalStorage(unsigned number_of_nodes);
void InitializeOrClearFirstThreadLocalStorage(unsigned number_of_nodes);
void InitializeOrClearSecondThreadLocalStorage(unsigned number_of_nodes);
void InitializeOrClearThirdThreadLocalStorage(unsigned number_of_nodes);
void InitializeOrClearManyToManyThreadLocalStorage(unsigned number_of_nodes);
};
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) {}
};
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)
{
}
};
struct ManyToManyMultiLayerDijkstraHeapData : MultiLayerDijkstraHeapData
{
EdgeDuration duration;
EdgeDistance distance;
ManyToManyMultiLayerDijkstraHeapData(NodeID p, EdgeDuration duration, EdgeDistance distance)
: MultiLayerDijkstraHeapData(p), duration(duration), distance(distance)
{
}
ManyToManyMultiLayerDijkstraHeapData(NodeID p,
bool from,
EdgeDuration duration,
EdgeDistance distance)
: MultiLayerDijkstraHeapData(p, from), duration(duration), distance(distance)
{
}
};
template <> struct SearchEngineData<routing_algorithms::mld::Algorithm>
{
using QueryHeap = util::QueryHeap<NodeID,
NodeID,
EdgeWeight,
MultiLayerDijkstraHeapData,
util::TwoLevelStorage<NodeID, int>>;
using ManyToManyQueryHeap = util::QueryHeap<NodeID,
NodeID,
EdgeWeight,
ManyToManyMultiLayerDijkstraHeapData,
util::TwoLevelStorage<NodeID, int>>;
using MapMatchingQueryHeap = util::QueryHeap<NodeID,
NodeID,
EdgeWeight,
MapMatchingMultiLayerDijkstraHeapData,
util::TwoLevelStorage<NodeID, int>>;
using SearchEngineHeapPtr = std::unique_ptr<QueryHeap>;
using ManyToManyHeapPtr = std::unique_ptr<ManyToManyQueryHeap>;
using MapMatchingHeapPtr = std::unique_ptr<MapMatchingQueryHeap>;
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;
static thread_local ManyToManyHeapPtr many_to_many_heap;
void InitializeOrClearFirstThreadLocalStorage(unsigned number_of_nodes,
unsigned number_of_boundary_nodes);
void InitializeOrClearMapMatchingThreadLocalStorage(unsigned number_of_nodes,
unsigned number_of_boundary_nodes);
void InitializeOrClearManyToManyThreadLocalStorage(unsigned number_of_nodes,
unsigned number_of_boundary_nodes);
};
} // namespace osrm::engine
#endif // SEARCH_ENGINE_DATA_HPP