From f8aea673e97c4ef2c95a0c67914bfb0d0b0e6c6d Mon Sep 17 00:00:00 2001 From: Zuleykha Pavlichenkova Date: Thu, 26 Sep 2024 17:36:48 +0200 Subject: [PATCH] set values of missing in the config file statement types to 0 --- src/include/random_nums_config.hpp | 4 +++- src/random_nums_config.cpp | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/include/random_nums_config.hpp b/src/include/random_nums_config.hpp index e1504d8..9678fc6 100644 --- a/src/include/random_nums_config.hpp +++ b/src/include/random_nums_config.hpp @@ -41,7 +41,9 @@ enum class RandomPercentagesEnum : idx_t { LIMIT_PERCENT_MODIFIER_LIMIT = 20, LIMIT_PERCENT_MODIFIER_OFFSET = 21, LIMIT_MODIFIER_LIMIT = 22, - LIMIT_MODIFIER_OFFSET = 23 + LIMIT_MODIFIER_OFFSET = 23, + + COUNT }; diff --git a/src/random_nums_config.cpp b/src/random_nums_config.cpp index a11a26f..c6c217a 100644 --- a/src/random_nums_config.cpp +++ b/src/random_nums_config.cpp @@ -67,6 +67,8 @@ void ParseJsonObj(yyjson_val *obj, unordered_map & } } + + unordered_map GetConfigFromFile(const char *json_string) { unordered_map config_from_file; @@ -82,6 +84,13 @@ unordered_map GetConfigFromFile(const char *json_s yyjson_doc_free(doc); return GetDefaultConfig(); } + // set values of missing statement types to 0 + for (idx_t i = 0; i < static_cast(RandomPercentagesEnum::COUNT); ++i) { + RandomPercentagesEnum statement_type = static_cast(i); + if (config_from_file.find(statement_type) == config_from_file.end()) { + config_from_file[statement_type] = 0; + } + } return config_from_file; } } // namespace duckdb \ No newline at end of file