From 7923fdcaef708562f817bda81cda9a71b9eda228 Mon Sep 17 00:00:00 2001 From: karenzshea Date: Wed, 6 Sep 2017 15:11:51 +0200 Subject: [PATCH] error when mld files or data are missing, compability -> compatibility --- include/engine/engine.hpp | 31 ++++++++++++++++----- src/osrm/osrm.cpp | 6 ++-- third_party/libosmium/test/t/io/data-cr.opl | 1 - 3 files changed, 27 insertions(+), 11 deletions(-) delete mode 100644 third_party/libosmium/test/t/io/data-cr.opl diff --git a/include/engine/engine.hpp b/include/engine/engine.hpp index ec2fee70d..5726c5b46 100644 --- a/include/engine/engine.hpp +++ b/include/engine/engine.hpp @@ -119,7 +119,7 @@ template class Engine final : public EngineInterface return tile_plugin.HandleRequest(GetAlgorithms(params), params, result); } - static bool CheckCompability(const EngineConfig &config); + static bool CheckCompatibility(const EngineConfig &config); private: template auto GetAlgorithms(const ParametersT ¶ms) const @@ -139,7 +139,7 @@ template class Engine final : public EngineInterface }; template <> -bool Engine::CheckCompability(const EngineConfig &config) +bool Engine::CheckCompatibility(const EngineConfig &config) { if (config.use_shared_memory) { @@ -165,9 +165,9 @@ bool Engine::CheckCompability(const EngineCon } template <> -bool Engine::CheckCompability(const EngineConfig &config) +bool Engine::CheckCompatibility(const EngineConfig &config) { - if (!Engine::CheckCompability(config)) + if (!Engine::CheckCompatibility(config)) { return false; } @@ -197,7 +197,7 @@ bool Engine::CheckCompability(const Engin } template <> -bool Engine::CheckCompability(const EngineConfig &config) +bool Engine::CheckCompatibility(const EngineConfig &config) { if (config.use_shared_memory) { @@ -207,11 +207,28 @@ bool Engine::CheckCompability(const EngineCo auto mem = storage::makeSharedMemory(barrier.data().region); auto layout = reinterpret_cast(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 { - 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; storage::io::FileReader in(config.storage_config.GetPath(".osrm.partition"), storage::io::FileReader::VerifyFingerprint); diff --git a/src/osrm/osrm.cpp b/src/osrm/osrm.cpp index 326e4f321..97187873f 100644 --- a/src/osrm/osrm.cpp +++ b/src/osrm/osrm.cpp @@ -47,8 +47,8 @@ OSRM::OSRM(engine::EngineConfig &config) if (config.algorithm == EngineConfig::Algorithm::CoreCH || config.algorithm == EngineConfig::Algorithm::CH) { - bool corech_compatible = engine::Engine::CheckCompability(config); - bool ch_compatible = engine::Engine::CheckCompability(config); + bool corech_compatible = engine::Engine::CheckCompatibility(config); + bool ch_compatible = engine::Engine::CheckCompatibility(config); // Activate CoreCH if we can because it is faster if (config.algorithm == EngineConfig::Algorithm::CH && corech_compatible) @@ -70,7 +70,7 @@ OSRM::OSRM(engine::EngineConfig &config) } else if (config.algorithm == EngineConfig::Algorithm::MLD) { - bool mld_compatible = engine::Engine::CheckCompability(config); + bool mld_compatible = engine::Engine::CheckCompatibility(config); // throw error if dataset is not usable with MLD if (!mld_compatible) { diff --git a/third_party/libosmium/test/t/io/data-cr.opl b/third_party/libosmium/test/t/io/data-cr.opl deleted file mode 100644 index 2c7e2a35f..000000000 --- a/third_party/libosmium/test/t/io/data-cr.opl +++ /dev/null @@ -1 +0,0 @@ -n1 v1 dV c1 t2014-01-01T00:00:00Z i1 utest T x1.02 y1.02