Pull everthing in the facades
This commit is contained in:
committed by
Patrick Niklaus
parent
ff0a98196f
commit
108fce896b
@@ -23,10 +23,10 @@ struct MLD final
|
||||
{
|
||||
};
|
||||
|
||||
template<typename AlgorithmT> const char* name();
|
||||
template<> inline const char* name<CH>() { return "CH"; }
|
||||
template<> inline const char* name<CoreCH>() { return "CoreCH"; }
|
||||
template<> inline const char* name<MLD>() { return "MLD"; }
|
||||
template <typename AlgorithmT> const char *name();
|
||||
template <> inline const char *name<CH>() { return "CH"; }
|
||||
template <> inline const char *name<CoreCH>() { return "CoreCH"; }
|
||||
template <> inline const char *name<MLD>() { return "MLD"; }
|
||||
}
|
||||
|
||||
namespace algorithm_trais
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
#include "contractor/query_edge.hpp"
|
||||
#include "engine/algorithm.hpp"
|
||||
#include "util/cell_storage.hpp"
|
||||
#include "util/integer_range.hpp"
|
||||
#include "util/multi_level_partition.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -58,6 +60,14 @@ template <> class AlgorithmDataFacade<algorithm::CoreCH>
|
||||
|
||||
virtual bool IsCoreNode(const NodeID id) const = 0;
|
||||
};
|
||||
|
||||
template <> class AlgorithmDataFacade<algorithm::MLD>
|
||||
{
|
||||
public:
|
||||
virtual const util::MultiLevelPartitionView &GetMultiLevelPartition() const = 0;
|
||||
|
||||
virtual const util::CellStorage<true> &GetCellStorage() const = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,10 +251,6 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
std::shared_ptr<util::RangeTable<16, true>> m_bearing_ranges_table;
|
||||
util::ShM<DiscreteBearing, true>::vector m_bearing_values_table;
|
||||
|
||||
// MLD data
|
||||
util::PackedMultiLevelPartition<true> mld_partition;
|
||||
util::CellStorage<true> mld_cell_storage;
|
||||
|
||||
// allocator that keeps the allocation data
|
||||
std::shared_ptr<ContiguousBlockAllocator> allocator;
|
||||
|
||||
@@ -540,27 +536,6 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
m_entry_class_table = std::move(entry_class_table);
|
||||
}
|
||||
|
||||
void InitializeMLDDataPointers(storage::DataLayout &data_layout, char *memory_block)
|
||||
{
|
||||
if (data_layout.GetBlockSize(storage::DataLayout::MLD_CELL_PARTITION) > 0)
|
||||
{
|
||||
auto mld_partition_ptr =
|
||||
data_layout.GetBlockPtr<char>(memory_block, storage::DataLayout::MLD_CELL_PARTITION);
|
||||
mld_partition.InitializePointers(
|
||||
mld_partition_ptr,
|
||||
mld_partition_ptr + data_layout.num_entries[storage::DataLayout::MLD_CELL_PARTITION]);
|
||||
}
|
||||
|
||||
if (data_layout.GetBlockSize(storage::DataLayout::MLD_CELL_STORAGE) > 0)
|
||||
{
|
||||
auto mld_cell_storage_ptr =
|
||||
data_layout.GetBlockPtr<char>(memory_block, storage::DataLayout::MLD_CELL_STORAGE);
|
||||
mld_cell_storage.InitializePointers(
|
||||
mld_cell_storage_ptr,
|
||||
mld_cell_storage_ptr + data_layout.num_entries[storage::DataLayout::MLD_CELL_STORAGE]);
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeInternalPointers(storage::DataLayout &data_layout, char *memory_block)
|
||||
{
|
||||
InitializeChecksumPointer(data_layout, memory_block);
|
||||
@@ -574,7 +549,6 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
InitializeProfilePropertiesPointer(data_layout, memory_block);
|
||||
InitializeRTreePointers(data_layout, memory_block);
|
||||
InitializeIntersectionClassPointers(data_layout, memory_block);
|
||||
InitializeMLDDataPointers(data_layout, memory_block);
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -1077,13 +1051,6 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
m_lane_description_masks.begin() +
|
||||
m_lane_description_offsets[lane_description_id + 1]);
|
||||
}
|
||||
|
||||
const util::PackedMultiLevelPartition<true> &GetMultiLevelPartition() const
|
||||
{
|
||||
return mld_partition;
|
||||
}
|
||||
|
||||
const util::CellStorage<true> &GetCellStorage() const { return mld_cell_storage; }
|
||||
};
|
||||
|
||||
template <typename AlgorithmT> class ContiguousInternalMemoryDataFacade;
|
||||
@@ -1115,6 +1082,83 @@ class ContiguousInternalMemoryDataFacade<algorithm::CoreCH> final
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD>
|
||||
: public datafacade::AlgorithmDataFacade<algorithm::MLD>
|
||||
{
|
||||
// MLD data
|
||||
util::MultiLevelPartitionView mld_partition;
|
||||
util::CellStorage<true> mld_cell_storage;
|
||||
|
||||
void InitializeInternalPointers(storage::DataLayout &data_layout, char *memory_block)
|
||||
{
|
||||
InitializeMLDDataPointers(data_layout, memory_block);
|
||||
}
|
||||
|
||||
void InitializeMLDDataPointers(storage::DataLayout &data_layout, char *memory_block)
|
||||
{
|
||||
if (data_layout.GetBlockSize(storage::DataLayout::MLD_PARTITION) > 0)
|
||||
{
|
||||
BOOST_ASSERT(data_layout.GetBlockSize(storage::DataLayout::MLD_LEVEL_DATA) > 0);
|
||||
BOOST_ASSERT(data_layout.GetBlockSize(storage::DataLayout::MLD_CELL_TO_CHILDREN) > 0);
|
||||
|
||||
auto level_data = *data_layout.GetBlockPtr<util::MultiLevelPartitionView::LevelData>(memory_block, storage::DataLayout::MLD_PARTITION);
|
||||
|
||||
auto mld_partition_ptr = data_layout.GetBlockPtr<util::PartitionID>(memory_block, storage::DataLayout::MLD_PARTITION);
|
||||
auto partition_entries_count = data_layout.GetBlockEntries(storage::DataLayout::MLD_PARTITION);
|
||||
util::ShM<util::PartitionID, true>::vector partition(mld_partition_ptr, partition_entries_count);
|
||||
|
||||
auto mld_chilren_ptr = data_layout.GetBlockPtr<util::CellID>(memory_block, storage::DataLayout::MLD_CELL_TO_CHILDREN);
|
||||
auto children_entries_count = data_layout.GetBlockEntries(storage::DataLayout::MLD_CELL_TO_CHILDREN);
|
||||
util::ShM<util::CellID, true>::vector cell_to_children(mld_chilren_ptr, children_entries_count);
|
||||
|
||||
mld_partition = util::MultiLevelPartitionView{level_data, partition, cell_to_children};
|
||||
}
|
||||
|
||||
if (data_layout.GetBlockSize(storage::DataLayout::MLD_CELL_STORAGE) > 0)
|
||||
{
|
||||
auto mld_cell_storage_ptr =
|
||||
data_layout.GetBlockPtr<char>(memory_block, storage::DataLayout::MLD_CELL_STORAGE);
|
||||
mld_cell_storage.InitializePointers(
|
||||
mld_cell_storage_ptr,
|
||||
mld_cell_storage_ptr +
|
||||
data_layout.num_entries[storage::DataLayout::MLD_CELL_STORAGE]);
|
||||
}
|
||||
}
|
||||
|
||||
// allocator that keeps the allocation data
|
||||
std::shared_ptr<ContiguousBlockAllocator> allocator;
|
||||
|
||||
public:
|
||||
ContiguousInternalMemoryAlgorithmDataFacade(
|
||||
std::shared_ptr<ContiguousBlockAllocator> allocator_)
|
||||
: allocator(std::move(allocator_))
|
||||
{
|
||||
InitializeInternalPointers(allocator->GetLayout(), allocator->GetMemory());
|
||||
}
|
||||
|
||||
const util::MultiLevelPartitionView &GetMultiLevelPartition() const
|
||||
{
|
||||
return mld_partition;
|
||||
}
|
||||
|
||||
const util::CellStorage<true> &GetCellStorage() const { return mld_cell_storage; }
|
||||
};
|
||||
|
||||
template <>
|
||||
class ContiguousInternalMemoryDataFacade<algorithm::MLD>
|
||||
: public ContiguousInternalMemoryDataFacadeBase,
|
||||
public ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD>
|
||||
{
|
||||
public:
|
||||
ContiguousInternalMemoryDataFacade(std::shared_ptr<ContiguousBlockAllocator> allocator)
|
||||
: ContiguousInternalMemoryDataFacadeBase(allocator),
|
||||
ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD>(allocator)
|
||||
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,9 @@ namespace engine
|
||||
* now.
|
||||
* - Algorithm::CoreCH
|
||||
* Contractoin Hierachies with partial contraction for faster pre-processing but slower queries.
|
||||
* - Algorithm::MLD
|
||||
* Multi Level Dijkstra which is experimental and moderately fast in both pre-processing and
|
||||
* query.
|
||||
*
|
||||
* Algorithm::CH is specified we will automatically upgrade to CoreCH if we find the data for it.
|
||||
* If Algorithm::CoreCH is specified and we don't find the speedup data, we fail hard.
|
||||
@@ -73,8 +76,9 @@ struct EngineConfig final
|
||||
|
||||
enum class Algorithm
|
||||
{
|
||||
CH, // will upgrade to CoreCH if it finds core data
|
||||
CoreCH // will fail hard if there is no core data
|
||||
CH, // will upgrade to CoreCH if it finds core data
|
||||
CoreCH, // will fail hard if there is no core data
|
||||
MLD
|
||||
};
|
||||
|
||||
storage::StorageConfig storage_config;
|
||||
|
||||
@@ -65,54 +65,29 @@ template <typename AlgorithmT> class RoutingAlgorithms final : public RoutingAlg
|
||||
virtual ~RoutingAlgorithms() = default;
|
||||
|
||||
InternalRouteResult
|
||||
AlternativePathSearch(const PhantomNodes &phantom_node_pair) const final override
|
||||
{
|
||||
return routing_algorithms::alternativePathSearch(heaps, facade, phantom_node_pair);
|
||||
}
|
||||
AlternativePathSearch(const PhantomNodes &phantom_node_pair) const final override;
|
||||
|
||||
InternalRouteResult ShortestPathSearch(
|
||||
const std::vector<PhantomNodes> &phantom_node_pair,
|
||||
const boost::optional<bool> continue_straight_at_waypoint) const final override
|
||||
{
|
||||
return routing_algorithms::shortestPathSearch(
|
||||
heaps, facade, phantom_node_pair, continue_straight_at_waypoint);
|
||||
}
|
||||
const boost::optional<bool> continue_straight_at_waypoint) const final override;
|
||||
|
||||
InternalRouteResult
|
||||
DirectShortestPathSearch(const PhantomNodes &phantom_nodes) const final override
|
||||
{
|
||||
return routing_algorithms::directShortestPathSearch(heaps, facade, phantom_nodes);
|
||||
}
|
||||
DirectShortestPathSearch(const PhantomNodes &phantom_nodes) const final override;
|
||||
|
||||
std::vector<EdgeWeight>
|
||||
ManyToManySearch(const std::vector<PhantomNode> &phantom_nodes,
|
||||
const std::vector<std::size_t> &source_indices,
|
||||
const std::vector<std::size_t> &target_indices) const final override
|
||||
{
|
||||
return routing_algorithms::manyToManySearch(
|
||||
heaps, facade, phantom_nodes, source_indices, target_indices);
|
||||
}
|
||||
const std::vector<std::size_t> &target_indices) const final override;
|
||||
|
||||
routing_algorithms::SubMatchingList MapMatching(
|
||||
const routing_algorithms::CandidateLists &candidates_list,
|
||||
const std::vector<util::Coordinate> &trace_coordinates,
|
||||
const std::vector<unsigned> &trace_timestamps,
|
||||
const std::vector<boost::optional<double>> &trace_gps_precision) const final override
|
||||
{
|
||||
return routing_algorithms::mapMatching(heaps,
|
||||
facade,
|
||||
candidates_list,
|
||||
trace_coordinates,
|
||||
trace_timestamps,
|
||||
trace_gps_precision);
|
||||
}
|
||||
const std::vector<boost::optional<double>> &trace_gps_precision) const final override;
|
||||
|
||||
std::vector<routing_algorithms::TurnData>
|
||||
GetTileTurns(const std::vector<datafacade::BaseDataFacade::RTreeLeaf> &edges,
|
||||
const std::vector<std::size_t> &sorted_edge_indexes) const final override
|
||||
{
|
||||
return routing_algorithms::getTileTurns(facade, edges, sorted_edge_indexes);
|
||||
}
|
||||
const std::vector<std::size_t> &sorted_edge_indexes) const final override;
|
||||
|
||||
bool HasAlternativePathSearch() const final override
|
||||
{
|
||||
@@ -149,6 +124,108 @@ template <typename AlgorithmT> class RoutingAlgorithms final : public RoutingAlg
|
||||
// Owned by shared-ptr passed to the query
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<AlgorithmT> &facade;
|
||||
};
|
||||
|
||||
template <typename AlgorithmT>
|
||||
InternalRouteResult
|
||||
RoutingAlgorithms<AlgorithmT>::AlternativePathSearch(const PhantomNodes &phantom_node_pair) const
|
||||
{
|
||||
return routing_algorithms::alternativePathSearch(heaps, facade, phantom_node_pair);
|
||||
}
|
||||
|
||||
template <typename AlgorithmT>
|
||||
InternalRouteResult RoutingAlgorithms<AlgorithmT>::ShortestPathSearch(
|
||||
const std::vector<PhantomNodes> &phantom_node_pair,
|
||||
const boost::optional<bool> continue_straight_at_waypoint) const
|
||||
{
|
||||
return routing_algorithms::shortestPathSearch(
|
||||
heaps, facade, phantom_node_pair, continue_straight_at_waypoint);
|
||||
}
|
||||
|
||||
template <typename AlgorithmT>
|
||||
InternalRouteResult
|
||||
RoutingAlgorithms<AlgorithmT>::DirectShortestPathSearch(const PhantomNodes &phantom_nodes) const
|
||||
{
|
||||
return routing_algorithms::directShortestPathSearch(heaps, facade, phantom_nodes);
|
||||
}
|
||||
|
||||
template <typename AlgorithmT>
|
||||
std::vector<EdgeWeight> RoutingAlgorithms<AlgorithmT>::ManyToManySearch(
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
const std::vector<std::size_t> &source_indices,
|
||||
const std::vector<std::size_t> &target_indices) const
|
||||
{
|
||||
return routing_algorithms::manyToManySearch(
|
||||
heaps, facade, phantom_nodes, source_indices, target_indices);
|
||||
}
|
||||
|
||||
template <typename AlgorithmT>
|
||||
inline routing_algorithms::SubMatchingList RoutingAlgorithms<AlgorithmT>::MapMatching(
|
||||
const routing_algorithms::CandidateLists &candidates_list,
|
||||
const std::vector<util::Coordinate> &trace_coordinates,
|
||||
const std::vector<unsigned> &trace_timestamps,
|
||||
const std::vector<boost::optional<double>> &trace_gps_precision) const
|
||||
{
|
||||
return routing_algorithms::mapMatching(
|
||||
heaps, facade, candidates_list, trace_coordinates, trace_timestamps, trace_gps_precision);
|
||||
}
|
||||
|
||||
template <typename AlgorithmT>
|
||||
inline std::vector<routing_algorithms::TurnData> RoutingAlgorithms<AlgorithmT>::GetTileTurns(
|
||||
const std::vector<datafacade::BaseDataFacade::RTreeLeaf> &edges,
|
||||
const std::vector<std::size_t> &sorted_edge_indexes) const
|
||||
{
|
||||
return routing_algorithms::getTileTurns(facade, edges, sorted_edge_indexes);
|
||||
}
|
||||
|
||||
// MLD overrides for not implemented
|
||||
template <>
|
||||
InternalRouteResult inline RoutingAlgorithms<algorithm::MLD>::AlternativePathSearch(
|
||||
const PhantomNodes &) const
|
||||
{
|
||||
throw util::exception("AlternativePathSearch is not implemented");
|
||||
}
|
||||
|
||||
template <>
|
||||
inline InternalRouteResult
|
||||
RoutingAlgorithms<algorithm::MLD>::ShortestPathSearch(const std::vector<PhantomNodes> &,
|
||||
const boost::optional<bool>) const
|
||||
{
|
||||
throw util::exception("ShortestPathSearch is not implemented");
|
||||
}
|
||||
|
||||
template <>
|
||||
InternalRouteResult inline RoutingAlgorithms<algorithm::MLD>::DirectShortestPathSearch(
|
||||
const PhantomNodes &) const
|
||||
{
|
||||
throw util::exception("DirectShortestPathSearch is not implemented");
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::vector<EdgeWeight>
|
||||
RoutingAlgorithms<algorithm::MLD>::ManyToManySearch(const std::vector<PhantomNode> &,
|
||||
const std::vector<std::size_t> &,
|
||||
const std::vector<std::size_t> &) const
|
||||
{
|
||||
throw util::exception("ManyToManySearch is not implemented");
|
||||
}
|
||||
|
||||
template <>
|
||||
inline routing_algorithms::SubMatchingList
|
||||
RoutingAlgorithms<algorithm::MLD>::MapMatching(const routing_algorithms::CandidateLists &,
|
||||
const std::vector<util::Coordinate> &,
|
||||
const std::vector<unsigned> &,
|
||||
const std::vector<boost::optional<double>> &) const
|
||||
{
|
||||
throw util::exception("MapMatching is not implemented");
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::vector<routing_algorithms::TurnData> RoutingAlgorithms<algorithm::MLD>::GetTileTurns(
|
||||
const std::vector<datafacade::BaseDataFacade::RTreeLeaf> &,
|
||||
const std::vector<std::size_t> &) const
|
||||
{
|
||||
throw util::exception("GetTileTurns is not implemented");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user