error when mld files or data are missing, compability -> compatibility

This commit is contained in:
karenzshea 2017-09-06 15:11:51 +02:00 committed by Karen Shea
parent 837dba2191
commit 7923fdcaef
3 changed files with 27 additions and 11 deletions

View File

@ -119,7 +119,7 @@ template <typename Algorithm> class Engine final : public EngineInterface
return tile_plugin.HandleRequest(GetAlgorithms(params), params, result); return tile_plugin.HandleRequest(GetAlgorithms(params), params, result);
} }
static bool CheckCompability(const EngineConfig &config); static bool CheckCompatibility(const EngineConfig &config);
private: private:
template <typename ParametersT> auto GetAlgorithms(const ParametersT &params) const template <typename ParametersT> auto GetAlgorithms(const ParametersT &params) const
@ -139,7 +139,7 @@ template <typename Algorithm> class Engine final : public EngineInterface
}; };
template <> template <>
bool Engine<routing_algorithms::ch::Algorithm>::CheckCompability(const EngineConfig &config) bool Engine<routing_algorithms::ch::Algorithm>::CheckCompatibility(const EngineConfig &config)
{ {
if (config.use_shared_memory) if (config.use_shared_memory)
{ {
@ -165,9 +165,9 @@ bool Engine<routing_algorithms::ch::Algorithm>::CheckCompability(const EngineCon
} }
template <> template <>
bool Engine<routing_algorithms::corech::Algorithm>::CheckCompability(const EngineConfig &config) bool Engine<routing_algorithms::corech::Algorithm>::CheckCompatibility(const EngineConfig &config)
{ {
if (!Engine<routing_algorithms::ch::Algorithm>::CheckCompability(config)) if (!Engine<routing_algorithms::ch::Algorithm>::CheckCompatibility(config))
{ {
return false; return false;
} }
@ -197,7 +197,7 @@ bool Engine<routing_algorithms::corech::Algorithm>::CheckCompability(const Engin
} }
template <> template <>
bool Engine<routing_algorithms::mld::Algorithm>::CheckCompability(const EngineConfig &config) bool Engine<routing_algorithms::mld::Algorithm>::CheckCompatibility(const EngineConfig &config)
{ {
if (config.use_shared_memory) if (config.use_shared_memory)
{ {
@ -207,11 +207,28 @@ bool Engine<routing_algorithms::mld::Algorithm>::CheckCompability(const EngineCo
auto mem = storage::makeSharedMemory(barrier.data().region); auto mem = storage::makeSharedMemory(barrier.data().region);
auto layout = reinterpret_cast<storage::DataLayout *>(mem->Ptr()); auto layout = reinterpret_cast<storage::DataLayout *>(mem->Ptr());
return layout->GetBlockSize(storage::DataLayout::MLD_PARTITION) > 0; // checks that all the needed memory blocks are populated
// DataLayout::MLD_CELL_SOURCE_BOUNDARY and DataLayout::MLD_CELL_DESTINATION_BOUNDARY
// are not checked, because in situations where there are so few nodes in the graph that
// they all fit into one cell, they can be empty.
bool empty_data = layout->GetBlockSize(storage::DataLayout::MLD_LEVEL_DATA) > 0 &&
layout->GetBlockSize(storage::DataLayout::MLD_PARTITION) > 0 &&
layout->GetBlockSize(storage::DataLayout::MLD_CELL_TO_CHILDREN) > 0 &&
layout->GetBlockSize(storage::DataLayout::MLD_CELLS) > 0 &&
layout->GetBlockSize(storage::DataLayout::MLD_CELL_LEVEL_OFFSETS) > 0 &&
layout->GetBlockSize(storage::DataLayout::MLD_GRAPH_NODE_LIST) > 0 &&
layout->GetBlockSize(storage::DataLayout::MLD_GRAPH_EDGE_LIST) > 0 &&
layout->GetBlockSize(storage::DataLayout::MLD_CELL_WEIGHTS_0) > 0 &&
layout->GetBlockSize(storage::DataLayout::MLD_CELL_DURATIONS_0) > 0 &&
layout->GetBlockSize(storage::DataLayout::MLD_GRAPH_NODE_TO_OFFSET) > 0;
return empty_data;
} }
else else
{ {
if (!boost::filesystem::exists(config.storage_config.GetPath(".osrm.partition"))) if (!boost::filesystem::exists(config.storage_config.GetPath(".osrm.partition")) ||
!boost::filesystem::exists(config.storage_config.GetPath(".osrm.cells")) ||
!boost::filesystem::exists(config.storage_config.GetPath(".osrm.mldgr")) ||
!boost::filesystem::exists(config.storage_config.GetPath(".osrm.cell_metrics")))
return false; return false;
storage::io::FileReader in(config.storage_config.GetPath(".osrm.partition"), storage::io::FileReader in(config.storage_config.GetPath(".osrm.partition"),
storage::io::FileReader::VerifyFingerprint); storage::io::FileReader::VerifyFingerprint);

View File

@ -47,8 +47,8 @@ OSRM::OSRM(engine::EngineConfig &config)
if (config.algorithm == EngineConfig::Algorithm::CoreCH || if (config.algorithm == EngineConfig::Algorithm::CoreCH ||
config.algorithm == EngineConfig::Algorithm::CH) config.algorithm == EngineConfig::Algorithm::CH)
{ {
bool corech_compatible = engine::Engine<CoreCH>::CheckCompability(config); bool corech_compatible = engine::Engine<CoreCH>::CheckCompatibility(config);
bool ch_compatible = engine::Engine<CH>::CheckCompability(config); bool ch_compatible = engine::Engine<CH>::CheckCompatibility(config);
// Activate CoreCH if we can because it is faster // Activate CoreCH if we can because it is faster
if (config.algorithm == EngineConfig::Algorithm::CH && corech_compatible) if (config.algorithm == EngineConfig::Algorithm::CH && corech_compatible)
@ -70,7 +70,7 @@ OSRM::OSRM(engine::EngineConfig &config)
} }
else if (config.algorithm == EngineConfig::Algorithm::MLD) else if (config.algorithm == EngineConfig::Algorithm::MLD)
{ {
bool mld_compatible = engine::Engine<MLD>::CheckCompability(config); bool mld_compatible = engine::Engine<MLD>::CheckCompatibility(config);
// throw error if dataset is not usable with MLD // throw error if dataset is not usable with MLD
if (!mld_compatible) if (!mld_compatible)
{ {

View File

@ -1 +0,0 @@
n1 v1 dV c1 t2014-01-01T00:00:00Z i1 utest T x1.02 y1.02