Maintain storage_config exposed API
This commit is contained in:
parent
0b5c7a97a7
commit
8da40419ee
@ -30,7 +30,7 @@ int main(int argc, const char *argv[])
|
|||||||
|
|
||||||
// Configure based on a .osrm base path, and no datasets in shared mem from osrm-datastore
|
// Configure based on a .osrm base path, and no datasets in shared mem from osrm-datastore
|
||||||
EngineConfig config;
|
EngineConfig config;
|
||||||
config.storage_config.UseDefaultOutputNames(argv[1]);
|
config.storage_config = {argv[1]};
|
||||||
config.use_shared_memory = false;
|
config.use_shared_memory = false;
|
||||||
|
|
||||||
// Routing machine with several services (such as Route, Table, Nearest, Trip, Match)
|
// Routing machine with several services (such as Route, Table, Nearest, Trip, Match)
|
||||||
|
@ -72,6 +72,11 @@ struct ExtractorConfig final : storage::IOConfig
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UseDefaultOutputNames(const boost::filesystem::path &base)
|
||||||
|
{
|
||||||
|
IOConfig::UseDefaultOutputNames(base);
|
||||||
|
}
|
||||||
|
|
||||||
boost::filesystem::path input_path;
|
boost::filesystem::path input_path;
|
||||||
boost::filesystem::path profile_path;
|
boost::filesystem::path profile_path;
|
||||||
|
|
||||||
|
@ -97,9 +97,8 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
|
|||||||
|
|
||||||
if (args[0]->IsString())
|
if (args[0]->IsString())
|
||||||
{
|
{
|
||||||
std::string base_path(*v8::String::Utf8Value(args[0]->ToString()));
|
engine_config->storage_config = osrm::StorageConfig(
|
||||||
engine_config->storage_config = osrm::StorageConfig();
|
*v8::String::Utf8Value(Nan::To<v8::String>(args[0]).ToLocalChecked()));
|
||||||
engine_config->storage_config.UseDefaultOutputNames(base_path);
|
|
||||||
engine_config->use_shared_memory = false;
|
engine_config->use_shared_memory = false;
|
||||||
return engine_config;
|
return engine_config;
|
||||||
}
|
}
|
||||||
@ -122,9 +121,8 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
|
|||||||
|
|
||||||
if (!path->IsUndefined())
|
if (!path->IsUndefined())
|
||||||
{
|
{
|
||||||
std::string base_path(*v8::String::Utf8Value(path->ToString()));
|
engine_config->storage_config =
|
||||||
engine_config->storage_config = osrm::StorageConfig();
|
osrm::StorageConfig(*v8::String::Utf8Value(Nan::To<v8::String>(path).ToLocalChecked()));
|
||||||
engine_config->storage_config.UseDefaultOutputNames(base_path);
|
|
||||||
engine_config->use_shared_memory = false;
|
engine_config->use_shared_memory = false;
|
||||||
}
|
}
|
||||||
if (!shared_memory->IsUndefined())
|
if (!shared_memory->IsUndefined())
|
||||||
|
@ -26,6 +26,11 @@ struct PartitionConfig final : storage::IOConfig
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UseDefaultOutputNames(const boost::filesystem::path &base)
|
||||||
|
{
|
||||||
|
IOConfig::UseDefaultOutputNames(base);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned requested_num_threads;
|
unsigned requested_num_threads;
|
||||||
|
|
||||||
double balance;
|
double balance;
|
||||||
|
@ -23,6 +23,21 @@ struct IOConfig
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsValid() const;
|
||||||
|
boost::filesystem::path GetPath(const std::string &fileName) const
|
||||||
|
{
|
||||||
|
if (!IsConfigured(fileName, required_input_files) &&
|
||||||
|
!IsConfigured(fileName, optional_input_files) && !IsConfigured(fileName, output_files))
|
||||||
|
{
|
||||||
|
throw util::exception("Tried to access file which is not configured: " + fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {base_path.string() + fileName};
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::filesystem::path base_path;
|
||||||
|
|
||||||
|
protected:
|
||||||
// Infer the base path from the path of the .osrm file
|
// Infer the base path from the path of the .osrm file
|
||||||
void UseDefaultOutputNames(const boost::filesystem::path &base)
|
void UseDefaultOutputNames(const boost::filesystem::path &base)
|
||||||
{
|
{
|
||||||
@ -45,20 +60,6 @@ struct IOConfig
|
|||||||
base_path = {path};
|
base_path = {path};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsValid() const;
|
|
||||||
boost::filesystem::path GetPath(const std::string &fileName) const
|
|
||||||
{
|
|
||||||
if (!IsConfigured(fileName, required_input_files) &&
|
|
||||||
!IsConfigured(fileName, optional_input_files) && !IsConfigured(fileName, output_files))
|
|
||||||
{
|
|
||||||
throw util::exception("Tried to access file which is not configured: " + fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {base_path.string() + fileName};
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::filesystem::path base_path;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool IsConfigured(const std::string &fileName,
|
static bool IsConfigured(const std::string &fileName,
|
||||||
const std::vector<boost::filesystem::path> &paths)
|
const std::vector<boost::filesystem::path> &paths)
|
||||||
|
@ -44,6 +44,11 @@ namespace storage
|
|||||||
*/
|
*/
|
||||||
struct StorageConfig final : IOConfig
|
struct StorageConfig final : IOConfig
|
||||||
{
|
{
|
||||||
|
StorageConfig(const boost::filesystem::path &base) : StorageConfig()
|
||||||
|
{
|
||||||
|
IOConfig::UseDefaultOutputNames(base);
|
||||||
|
}
|
||||||
|
|
||||||
StorageConfig()
|
StorageConfig()
|
||||||
: IOConfig({".osrm.ramIndex",
|
: IOConfig({".osrm.ramIndex",
|
||||||
".osrm.fileIndex",
|
".osrm.fileIndex",
|
||||||
|
@ -64,6 +64,11 @@ struct UpdaterConfig final : storage::IOConfig
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UseDefaultOutputNames(const boost::filesystem::path &base)
|
||||||
|
{
|
||||||
|
IOConfig::UseDefaultOutputNames(base);
|
||||||
|
}
|
||||||
|
|
||||||
double log_edge_updates_factor;
|
double log_edge_updates_factor;
|
||||||
std::time_t valid_now;
|
std::time_t valid_now;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ int main(int argc, const char *argv[]) try
|
|||||||
|
|
||||||
// Configure based on a .osrm base path, and no datasets in shared mem from osrm-datastore
|
// Configure based on a .osrm base path, and no datasets in shared mem from osrm-datastore
|
||||||
EngineConfig config;
|
EngineConfig config;
|
||||||
config.storage_config.UseDefaultOutputNames(argv[1]);
|
config.storage_config = {argv[1]};
|
||||||
config.use_shared_memory = false;
|
config.use_shared_memory = false;
|
||||||
|
|
||||||
// Routing machine with several services (such as Route, Table, Nearest, Trip, Match)
|
// Routing machine with several services (such as Route, Table, Nearest, Trip, Match)
|
||||||
|
@ -229,7 +229,7 @@ int main(int argc, const char *argv[]) try
|
|||||||
}
|
}
|
||||||
if (!base_path.empty())
|
if (!base_path.empty())
|
||||||
{
|
{
|
||||||
config.storage_config.UseDefaultOutputNames(base_path);
|
config.storage_config = storage::StorageConfig(base_path);
|
||||||
}
|
}
|
||||||
if (!config.use_shared_memory && !config.storage_config.IsValid())
|
if (!config.use_shared_memory && !config.storage_config.IsValid())
|
||||||
{
|
{
|
||||||
|
@ -163,8 +163,7 @@ int main(const int argc, const char *argv[]) try
|
|||||||
{
|
{
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
storage::StorageConfig config;
|
storage::StorageConfig config(base_path);
|
||||||
config.UseDefaultOutputNames(base_path);
|
|
||||||
if (!config.IsValid())
|
if (!config.IsValid())
|
||||||
{
|
{
|
||||||
util::Log(logERROR) << "Config contains invalid file paths. Exiting!";
|
util::Log(logERROR) << "Config contains invalid file paths. Exiting!";
|
||||||
|
@ -14,7 +14,7 @@ getOSRM(const std::string &base_path,
|
|||||||
osrm::EngineConfig::Algorithm algorithm = osrm::EngineConfig::Algorithm::CH)
|
osrm::EngineConfig::Algorithm algorithm = osrm::EngineConfig::Algorithm::CH)
|
||||||
{
|
{
|
||||||
osrm::EngineConfig config;
|
osrm::EngineConfig config;
|
||||||
config.storage_config.UseDefaultOutputNames(base_path);
|
config.storage_config = {base_path};
|
||||||
config.use_shared_memory = false;
|
config.use_shared_memory = false;
|
||||||
config.algorithm = algorithm;
|
config.algorithm = algorithm;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ BOOST_AUTO_TEST_CASE(test_trip_limits)
|
|||||||
using namespace osrm;
|
using namespace osrm;
|
||||||
|
|
||||||
EngineConfig config;
|
EngineConfig config;
|
||||||
config.storage_config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
config.storage_config = {OSRM_TEST_DATA_DIR "/ch/monaco.osrm"};
|
||||||
config.use_shared_memory = false;
|
config.use_shared_memory = false;
|
||||||
config.max_locations_trip = 2;
|
config.max_locations_trip = 2;
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(test_route_limits)
|
|||||||
using namespace osrm;
|
using namespace osrm;
|
||||||
|
|
||||||
EngineConfig config;
|
EngineConfig config;
|
||||||
config.storage_config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
config.storage_config = {OSRM_TEST_DATA_DIR "/ch/monaco.osrm"};
|
||||||
config.use_shared_memory = false;
|
config.use_shared_memory = false;
|
||||||
config.max_locations_viaroute = 2;
|
config.max_locations_viaroute = 2;
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE(test_table_limits)
|
|||||||
using namespace osrm;
|
using namespace osrm;
|
||||||
|
|
||||||
EngineConfig config;
|
EngineConfig config;
|
||||||
config.storage_config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
config.storage_config = {OSRM_TEST_DATA_DIR "/ch/monaco.osrm"};
|
||||||
config.use_shared_memory = false;
|
config.use_shared_memory = false;
|
||||||
config.max_locations_distance_table = 2;
|
config.max_locations_distance_table = 2;
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE(test_match_limits)
|
|||||||
using namespace osrm;
|
using namespace osrm;
|
||||||
|
|
||||||
EngineConfig config;
|
EngineConfig config;
|
||||||
config.storage_config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
config.storage_config = {OSRM_TEST_DATA_DIR "/ch/monaco.osrm"};
|
||||||
config.use_shared_memory = false;
|
config.use_shared_memory = false;
|
||||||
config.max_locations_map_matching = 2;
|
config.max_locations_map_matching = 2;
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(test_nearest_limits)
|
|||||||
using namespace osrm;
|
using namespace osrm;
|
||||||
|
|
||||||
EngineConfig config;
|
EngineConfig config;
|
||||||
config.storage_config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
config.storage_config = {OSRM_TEST_DATA_DIR "/ch/monaco.osrm"};
|
||||||
config.use_shared_memory = false;
|
config.use_shared_memory = false;
|
||||||
config.max_results_nearest = 2;
|
config.max_results_nearest = 2;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ BOOST_AUTO_TEST_CASE(test_ch)
|
|||||||
using namespace osrm;
|
using namespace osrm;
|
||||||
EngineConfig config;
|
EngineConfig config;
|
||||||
config.use_shared_memory = false;
|
config.use_shared_memory = false;
|
||||||
config.storage_config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
config.storage_config = storage::StorageConfig(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
||||||
config.algorithm = EngineConfig::Algorithm::CH;
|
config.algorithm = EngineConfig::Algorithm::CH;
|
||||||
OSRM osrm{config};
|
OSRM osrm{config};
|
||||||
}
|
}
|
||||||
@ -24,7 +24,7 @@ BOOST_AUTO_TEST_CASE(test_corech)
|
|||||||
using namespace osrm;
|
using namespace osrm;
|
||||||
EngineConfig config;
|
EngineConfig config;
|
||||||
config.use_shared_memory = false;
|
config.use_shared_memory = false;
|
||||||
config.storage_config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/corech/monaco.osrm");
|
config.storage_config = storage::StorageConfig(OSRM_TEST_DATA_DIR "/corech/monaco.osrm");
|
||||||
config.algorithm = EngineConfig::Algorithm::CoreCH;
|
config.algorithm = EngineConfig::Algorithm::CoreCH;
|
||||||
OSRM osrm{config};
|
OSRM osrm{config};
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(test_mld)
|
|||||||
using namespace osrm;
|
using namespace osrm;
|
||||||
EngineConfig config;
|
EngineConfig config;
|
||||||
config.use_shared_memory = false;
|
config.use_shared_memory = false;
|
||||||
config.storage_config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/mld/monaco.osrm");
|
config.storage_config = storage::StorageConfig(OSRM_TEST_DATA_DIR "/mld/monaco.osrm");
|
||||||
config.algorithm = EngineConfig::Algorithm::MLD;
|
config.algorithm = EngineConfig::Algorithm::MLD;
|
||||||
OSRM osrm{config};
|
OSRM osrm{config};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user