Skip to content

Commit

Permalink
set values of missing in the config file statement types to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
hmeriann committed Sep 26, 2024
1 parent 2b9ae4d commit f8aea67
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/include/random_nums_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

};

Expand Down
9 changes: 9 additions & 0 deletions src/random_nums_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ void ParseJsonObj(yyjson_val *obj, unordered_map<RandomPercentagesEnum, idx_t> &
}
}



unordered_map<RandomPercentagesEnum, idx_t> GetConfigFromFile(const char *json_string) {

unordered_map<RandomPercentagesEnum, idx_t> config_from_file;
Expand All @@ -82,6 +84,13 @@ unordered_map<RandomPercentagesEnum, idx_t> 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<int>(RandomPercentagesEnum::COUNT); ++i) {
RandomPercentagesEnum statement_type = static_cast<RandomPercentagesEnum>(i);
if (config_from_file.find(statement_type) == config_from_file.end()) {
config_from_file[statement_type] = 0;
}
}
return config_from_file;
}
} // namespace duckdb

0 comments on commit f8aea67

Please sign in to comment.