diff --git a/tiledb/sm/config/config.cc b/tiledb/sm/config/config.cc index 6afe3ad5c4ce..7da94958a302 100644 --- a/tiledb/sm/config/config.cc +++ b/tiledb/sm/config/config.cc @@ -918,6 +918,17 @@ const char* Config::get_from_config_or_env( return *found ? value_config : ""; } +const std::map +Config::get_all_params_from_config_or_env() const { + std::map values; + bool found = false; + for (const auto& [key, value] : param_values_) { + std::string val = get_from_config_or_env(key, &found); + values.emplace(key, val); + } + return values; +} + template optional Config::get_internal(const std::string& key) const { auto value = get_internal_string(key); diff --git a/tiledb/sm/config/config.h b/tiledb/sm/config/config.h index 5754effc26cf..c6d9926bfe86 100644 --- a/tiledb/sm/config/config.h +++ b/tiledb/sm/config/config.h @@ -67,6 +67,8 @@ namespace tiledb::sm { * Parsing to appropriate types happens on demand. */ class Config { + friend class ConfigIter; + public: /* ****************************** */ /* CONFIG DEFAULTS */ @@ -689,9 +691,6 @@ class Config { Status get_vector( const std::string& param, std::vector* value, bool* found) const; - /** Returns the param -> value map. */ - const std::map& param_values() const; - /** Gets the set parameters. */ const std::set& set_params() const; @@ -706,6 +705,10 @@ class Config { /** Compares configs for equality. */ bool operator==(const Config& rhs) const; + /** Get all config params taking into account environment variables */ + const std::map get_all_params_from_config_or_env() + const; + private: /* ********************************* */ /* PRIVATE ATTRIBUTES */ @@ -782,6 +785,9 @@ class Config { template optional get_internal_string(const std::string& key) const; + + /** Returns the param -> value map. */ + const std::map& param_values() const; }; /** diff --git a/tiledb/sm/serialization/config.cc b/tiledb/sm/serialization/config.cc index 9b1ff7102875..c911a082b095 100644 --- a/tiledb/sm/serialization/config.cc +++ b/tiledb/sm/serialization/config.cc @@ -61,9 +61,10 @@ namespace serialization { Status config_to_capnp( const Config& config, capnp::Config::Builder* config_builder) { - auto entries = config_builder->initEntries(config.param_values().size()); + auto config_params = config.get_all_params_from_config_or_env(); + auto entries = config_builder->initEntries(config_params.size()); uint64_t i = 0; - for (const auto& kv : config.param_values()) { + for (const auto& kv : config_params) { entries[i].setKey(kv.first); entries[i].setValue(kv.second); ++i;