generated from duckdb/extension-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Replace hardcoded percentages with values from a file #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hmeriann
wants to merge
41
commits into
duckdb:main
Choose a base branch
from
hmeriann:random-values-from-file
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 28 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
922b9af
add RandomConfigs class with default values and applied to the Genera…
hmeriann 88949bc
add a class for random numbers configuraion
hmeriann 1632858
change statement generator to work with the RandomsConfig
hmeriann aaac78c
rename randoms config
hmeriann c1506c5
mention random_nums_config files in the CMakes
hmeriann f602008
a json string gets parsed
hmeriann e08843b
parseJSONMap and initialise RandomNumsConfig with the custom values f…
hmeriann f629ec1
Merge remote-tracking branch 'upstream/main' into random-values-from-…
hmeriann fa89b25
fix paths to the reusable workflows, since they were moved to the .wo…
hmeriann 6751d00
Merge branch 'main' into random-values-from-file
hmeriann 11c5910
add randoms_config_handle to fuzzyduck
hmeriann 566aff3
add config file
hmeriann 87d6a03
FileSystem::ReadFile uses reads the file with all the new line symbol…
hmeriann de5cada
pass config file path as randoms_config_filepath parameter
hmeriann ce877c4
turn the RandomNumsConfig into an unorderdered_map<percentages_enum, …
hmeriann 38757a5
rename to RandomPercentagesEnum
hmeriann 26ba5ec
fixed missing values
hmeriann 7275d9a
GetDefaultConfig() instead of throwing an exception when the file wit…
hmeriann ad51bdd
do not declare a variable for config again
hmeriann 1430522
remove file handling, because it's being handled by yyjson_read_file
hmeriann 3d395fd
add randoms_config_filepath to scripts/run_fuzzer.py
hmeriann 4930d43
naive way to parse nested config.json to a map
hmeriann fb32a9d
config_nested.json file
hmeriann 73b1cf1
parseJson recursively
hmeriann 58d4908
a test file
hmeriann 2b9ae4d
clean up
hmeriann f8aea67
set values of missing in the config file statement types to 0
hmeriann 5e5e7ad
add missing quote
hmeriann 0ddd49c
update the config file with almost all randoms
hmeriann 7ada4b3
update src/include/random_nums_config.hpp to align with the config
hmeriann 4cfe8c4
update StringToRandomPercentagesEnum in the src/random_nums_config.cpp
hmeriann ea50779
config_nested.json with all the default values
hmeriann c3c7725
src/include/random_nums_config.hpp corrected names
hmeriann ebe03d5
pass config to the statement generator
hmeriann 5b8f652
rename some values
hmeriann 628f2d8
remove duplicating line
hmeriann 1a1ff8a
make RandomNumsConfig class
hmeriann ef48353
limit count of generated set operations
hmeriann 3cd1bfb
set percentage to setop
hmeriann db0645b
add more values from the config file
hmeriann 8e5088e
Merge branch 'main' into random-values-from-file
hmeriann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"select_percentage": "70", | ||
"attach_percentage": "20", | ||
"attach_use_percentage": "80", | ||
"detach_percentage": "15", | ||
"set_percentage": "5", | ||
"delete_percentage": "25" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"attach_percentage": "20", | ||
"select": { | ||
"select_percentage": "1", | ||
"select_node": { | ||
"select_node_perc": "2", | ||
"select_node_is_distinct_perc": "3", | ||
"select_node_from_table_perc": "4", | ||
"select_node_where_perc": "5", | ||
"select_node_having_perc": "6", | ||
"select_node_groups": { | ||
"select_node_groups_perc": "7", | ||
"select_node_group_by_perc": "8" | ||
}, | ||
"select_node_qualify_perc": "9", | ||
"select_node_aggregate_perc": "10", | ||
"select_node_sample": { | ||
"select_node_sample_perc": "11", | ||
"select_node_sample_is_perc": "12", | ||
"select_node_sample_size": "13" | ||
} | ||
}, | ||
"result_modifiers": "14", | ||
"limit_percent_modifier": "15", | ||
"limit_percent_modifier_limit": "16", | ||
"limit_percent_modifier_offset": "17", | ||
"limit_modifier_limit": "18", | ||
"limit_modifier_offset": "19" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// ===----------------------------------------------------------------------===// | ||
// DuckDB | ||
|
||
// random_nums_config.hpp | ||
|
||
|
||
// ===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
#include "duckdb.hpp" | ||
#include "yyjson.hpp" | ||
|
||
namespace duckdb { | ||
|
||
enum class RandomPercentagesEnum : idx_t { | ||
SELECT = 0, | ||
ATTACH = 1, | ||
ATTACH_USE = 2, | ||
DETACH = 3, | ||
SET = 4, | ||
DELETE = 5, | ||
|
||
// ---------------------------------- | ||
// Generate Select Percentages Types | ||
// ---------------------------------- | ||
SELECT_NODE = 6, | ||
SELECT_NODE_IS_DISTINCT = 7, | ||
SELECT_NODE_FROM_TABLE = 8, | ||
SELECT_NODE_WHERE = 9, | ||
SELECT_NODE_HAVING = 10, | ||
SELECT_NODE_GROUPS = 11, | ||
SELECT_NODE_GROUP_BY = 12, | ||
SELECT_NODE_QUALIFY = 13, | ||
SELECT_NODE_AGGREGATE = 14, | ||
SELECT_NODE_SAMPLE = 15, | ||
SELECT_NODE_SAMPLE_IS_PERC = 16, | ||
SELECT_NODE_SAMPLE_SIZE = 17, | ||
RESULT_MODIFIERS = 18, | ||
LIMIT_PERCENT_MODIFIER = 19, | ||
LIMIT_PERCENT_MODIFIER_LIMIT = 20, | ||
LIMIT_PERCENT_MODIFIER_OFFSET = 21, | ||
LIMIT_MODIFIER_LIMIT = 22, | ||
LIMIT_MODIFIER_OFFSET = 23, | ||
|
||
COUNT | ||
|
||
}; | ||
|
||
unordered_map<RandomPercentagesEnum, idx_t> GetDefaultConfig(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the |
||
unordered_map<RandomPercentagesEnum, idx_t> GetConfigFromFile(const char *json_string); | ||
string RandomPercentagesEnumToString(RandomPercentagesEnum type); | ||
|
||
} // namespace duckdb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#include "include/random_nums_config.hpp" | ||
|
||
#include <algorithm> | ||
#include <iterator> | ||
#include <ctype.h> | ||
|
||
namespace duckdb { | ||
|
||
using namespace duckdb_yyjson; | ||
|
||
unordered_map<RandomPercentagesEnum, idx_t> GetDefaultConfig() { | ||
unordered_map<RandomPercentagesEnum, idx_t> default_config = { | ||
{ RandomPercentagesEnum::ATTACH, 40 }, | ||
{ RandomPercentagesEnum::ATTACH_USE, 50 }, | ||
{ RandomPercentagesEnum::DELETE, 40 }, | ||
{ RandomPercentagesEnum::DETACH, 60 }, | ||
{ RandomPercentagesEnum::SELECT, 60 }, | ||
{ RandomPercentagesEnum::SET, 30 } | ||
}; | ||
return default_config; | ||
} | ||
|
||
unordered_map<string, RandomPercentagesEnum> StringToRandomPercentagesEnum = { | ||
{ "attach_percentage", RandomPercentagesEnum::ATTACH }, | ||
{ "attach_use_percentage", RandomPercentagesEnum::ATTACH_USE }, | ||
{ "delete_percentage", RandomPercentagesEnum::DELETE }, | ||
{ "detach_percentage", RandomPercentagesEnum::DETACH }, | ||
{ "select_percentage", RandomPercentagesEnum::SELECT }, | ||
{ "select_node_perc", RandomPercentagesEnum::SELECT_NODE }, | ||
{ "select_node_is_distinct_perc", RandomPercentagesEnum::SELECT_NODE_IS_DISTINCT }, | ||
{ "select_node_from_table_perc", RandomPercentagesEnum::SELECT_NODE_FROM_TABLE }, | ||
{ "select_node_where_perc", RandomPercentagesEnum::SELECT_NODE_WHERE }, | ||
{ "select_node_having_perc", RandomPercentagesEnum::SELECT_NODE_HAVING }, | ||
{ "select_node_groups_perc", RandomPercentagesEnum::SELECT_NODE_GROUPS }, | ||
{ "select_node_group_by_perc", RandomPercentagesEnum::SELECT_NODE_GROUP_BY }, | ||
{ "select_node_qualify_perc", RandomPercentagesEnum::SELECT_NODE_QUALIFY }, | ||
{ "select_node_aggregate_perc", RandomPercentagesEnum::SELECT_NODE_AGGREGATE }, | ||
{ "select_node_sample_perc", RandomPercentagesEnum::SELECT_NODE_SAMPLE }, | ||
{ "select_node_sample_is_perc", RandomPercentagesEnum::SELECT_NODE_SAMPLE_IS_PERC }, | ||
{ "select_node_sample_size", RandomPercentagesEnum::SELECT_NODE_SAMPLE_SIZE }, | ||
{ "result_modifiers", RandomPercentagesEnum::RESULT_MODIFIERS }, | ||
{ "limit_percent_modifier", RandomPercentagesEnum::LIMIT_PERCENT_MODIFIER }, | ||
{ "limit_percent_modifier_limit", RandomPercentagesEnum::LIMIT_PERCENT_MODIFIER_LIMIT }, | ||
{ "limit_percent_modifier_offset", RandomPercentagesEnum::LIMIT_PERCENT_MODIFIER_OFFSET }, | ||
{ "limit_modifier_limit", RandomPercentagesEnum::LIMIT_MODIFIER_LIMIT }, | ||
{ "limit_modifier_offset", RandomPercentagesEnum::LIMIT_MODIFIER_OFFSET } | ||
}; | ||
|
||
void ParseJsonObj(yyjson_val *obj, unordered_map<RandomPercentagesEnum, idx_t> &config_from_file) { | ||
yyjson_obj_iter iter; | ||
yyjson_obj_iter_init(obj, &iter); | ||
size_t idx, max; | ||
yyjson_val *key, *val; | ||
yyjson_obj_foreach(obj, idx, max, key, val) { | ||
const char* root_key = yyjson_get_str(key); | ||
auto it = StringToRandomPercentagesEnum.find(root_key); | ||
if (it != StringToRandomPercentagesEnum.end()) { | ||
RandomPercentagesEnum perc_type = it->second; | ||
auto perc_value = yyjson_get_str(val); | ||
if (perc_value) { | ||
config_from_file[perc_type] = std::stoi(perc_value); | ||
} | ||
} | ||
if (yyjson_is_obj(val)) { | ||
ParseJsonObj(val, config_from_file); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
unordered_map<RandomPercentagesEnum, idx_t> GetConfigFromFile(const char *json_string) { | ||
|
||
unordered_map<RandomPercentagesEnum, idx_t> config_from_file; | ||
auto doc = yyjson_read_file(json_string, YYJSON_READ_NOFLAG, NULL, NULL); | ||
hmeriann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (doc) { | ||
yyjson_val *root = yyjson_doc_get_root(doc); | ||
if (yyjson_is_obj(root)) { | ||
ParseJsonObj(root, config_from_file); | ||
} | ||
yyjson_doc_free(doc); | ||
} else { | ||
// Couldn't read JSON with percentages config | ||
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.