Add option to only update the metric dependent data
This commit is contained in:
committed by
Patrick Niklaus
parent
fea07f343b
commit
a915542916
+26
-18
@@ -186,7 +186,7 @@ bool swapData(Monitor &monitor,
|
||||
|
||||
Storage::Storage(StorageConfig config_) : config(std::move(config_)) {}
|
||||
|
||||
int Storage::Run(int max_wait, const std::string &dataset_name)
|
||||
int Storage::Run(int max_wait, const std::string &dataset_name, bool only_metric)
|
||||
{
|
||||
BOOST_ASSERT_MSG(config.IsValid(), "Invalid storage config");
|
||||
|
||||
@@ -225,24 +225,32 @@ int Storage::Run(int max_wait, const std::string &dataset_name)
|
||||
auto &shared_register = monitor.data();
|
||||
|
||||
// Populate a memory layout into stack memory
|
||||
DataLayout static_layout;
|
||||
PopulateStaticLayout(static_layout);
|
||||
std::vector<SharedDataIndex::AllocatedRegion> regions;
|
||||
std::map<std::string, RegionHandle> handles;
|
||||
|
||||
if (!only_metric)
|
||||
{
|
||||
DataLayout static_layout;
|
||||
PopulateStaticLayout(static_layout);
|
||||
auto static_handle = setupRegion(shared_register, static_layout);
|
||||
regions.push_back({static_handle.data_ptr, static_layout});
|
||||
handles[dataset_name + "/static"] = std::move(static_handle);
|
||||
}
|
||||
|
||||
DataLayout updatable_layout;
|
||||
PopulateUpdatableLayout(updatable_layout);
|
||||
|
||||
auto static_handle = setupRegion(shared_register, static_layout);
|
||||
auto updatable_handle = setupRegion(shared_register, updatable_layout);
|
||||
|
||||
SharedDataIndex index{
|
||||
{{static_handle.data_ptr, static_layout}, {updatable_handle.data_ptr, updatable_layout}}};
|
||||
|
||||
PopulateStaticData(index);
|
||||
PopulateUpdatableData(index);
|
||||
|
||||
std::map<std::string, RegionHandle> handles;
|
||||
handles[dataset_name + "/static"] = std::move(static_handle);
|
||||
regions.push_back({updatable_handle.data_ptr, updatable_layout});
|
||||
handles[dataset_name + "/updatable"] = std::move(updatable_handle);
|
||||
|
||||
SharedDataIndex index{std::move(regions)};
|
||||
|
||||
if (!only_metric)
|
||||
{
|
||||
PopulateStaticData(index);
|
||||
}
|
||||
PopulateUpdatableData(index);
|
||||
|
||||
swapData(monitor, shared_register, handles, max_wait);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
@@ -400,8 +408,8 @@ void Storage::PopulateStaticData(const SharedDataIndex &index)
|
||||
std::string metric_name;
|
||||
// load profile properties
|
||||
{
|
||||
const auto profile_properties_ptr = index.GetBlockPtr<extractor::ProfileProperties>(
|
||||
"/common/properties");
|
||||
const auto profile_properties_ptr =
|
||||
index.GetBlockPtr<extractor::ProfileProperties>("/common/properties");
|
||||
extractor::files::readProfileProperties(config.GetPath(".osrm.properties"),
|
||||
*profile_properties_ptr);
|
||||
|
||||
@@ -455,8 +463,8 @@ void Storage::PopulateUpdatableData(const SharedDataIndex &index)
|
||||
}
|
||||
|
||||
{
|
||||
const auto datasources_names_ptr = index.GetBlockPtr<extractor::Datasources>(
|
||||
"/common/data_sources_names");
|
||||
const auto datasources_names_ptr =
|
||||
index.GetBlockPtr<extractor::Datasources>("/common/data_sources_names");
|
||||
extractor::files::readDatasources(config.GetPath(".osrm.datasource_names"),
|
||||
*datasources_names_ptr);
|
||||
}
|
||||
|
||||
+12
-4
@@ -75,7 +75,8 @@ bool generateDataStoreOptions(const int argc,
|
||||
boost::filesystem::path &base_path,
|
||||
int &max_wait,
|
||||
std::string &dataset_name,
|
||||
bool &list_datasets)
|
||||
bool &list_datasets,
|
||||
bool &only_metric)
|
||||
{
|
||||
// declare a group of options that will be allowed only on command line
|
||||
boost::program_options::options_description generic_options("Options");
|
||||
@@ -105,7 +106,13 @@ bool generateDataStoreOptions(const int argc,
|
||||
->default_value(false)
|
||||
->implicit_value(true),
|
||||
"Name of the dataset to load into memory. This allows having multiple datasets in memory "
|
||||
"at the same time.");
|
||||
"at the same time.") //
|
||||
("only-metric",
|
||||
boost::program_options::value<bool>(&only_metric)
|
||||
->default_value(false)
|
||||
->implicit_value(true),
|
||||
"Only reload the metric data without updating the full dataset. This is an optimization "
|
||||
"for traffic updates.");
|
||||
|
||||
// hidden options, will be allowed on command line but will not be shown to the user
|
||||
boost::program_options::options_description hidden_options("Hidden options");
|
||||
@@ -200,8 +207,9 @@ int main(const int argc, const char *argv[]) try
|
||||
int max_wait = -1;
|
||||
std::string dataset_name;
|
||||
bool list_datasets = false;
|
||||
bool only_metric = false;
|
||||
if (!generateDataStoreOptions(
|
||||
argc, argv, verbosity, base_path, max_wait, dataset_name, list_datasets))
|
||||
argc, argv, verbosity, base_path, max_wait, dataset_name, list_datasets, only_metric))
|
||||
{
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -222,7 +230,7 @@ int main(const int argc, const char *argv[]) try
|
||||
}
|
||||
storage::Storage storage(std::move(config));
|
||||
|
||||
return storage.Run(max_wait, dataset_name);
|
||||
return storage.Run(max_wait, dataset_name, only_metric);
|
||||
}
|
||||
catch (const osrm::RuntimeError &e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user