mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
Merge pull request #3263 from yandex/CLICKHOUSE-4007
CLICKHOUSE-4007: Fix PerfTest substitution function
This commit is contained in:
commit
38f3ee091d
@ -1159,11 +1159,8 @@ private:
|
|||||||
|
|
||||||
StringToVector::iterator substitutions_first = substitutions.begin();
|
StringToVector::iterator substitutions_first = substitutions.begin();
|
||||||
StringToVector::iterator substitutions_last = substitutions.end();
|
StringToVector::iterator substitutions_last = substitutions.end();
|
||||||
--substitutions_last;
|
|
||||||
|
|
||||||
std::map<String, String> substitutions_map;
|
runThroughAllOptionsAndPush(substitutions_first, substitutions_last, query, queries);
|
||||||
|
|
||||||
runThroughAllOptionsAndPush(substitutions_first, substitutions_last, query, queries, substitutions_map);
|
|
||||||
|
|
||||||
return queries;
|
return queries;
|
||||||
}
|
}
|
||||||
@ -1173,44 +1170,37 @@ private:
|
|||||||
void runThroughAllOptionsAndPush(StringToVector::iterator substitutions_left,
|
void runThroughAllOptionsAndPush(StringToVector::iterator substitutions_left,
|
||||||
StringToVector::iterator substitutions_right,
|
StringToVector::iterator substitutions_right,
|
||||||
const String & template_query,
|
const String & template_query,
|
||||||
std::vector<String> & queries,
|
std::vector<String> & queries)
|
||||||
const StringKeyValue & template_substitutions_map = StringKeyValue())
|
|
||||||
{
|
{
|
||||||
String name = substitutions_left->first;
|
if (substitutions_left == substitutions_right)
|
||||||
std::vector<String> values = substitutions_left->second;
|
{
|
||||||
|
queries.push_back(template_query); /// completely substituted query
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (const String & value : values)
|
String substitution_mask = "{" + substitutions_left->first + "}";
|
||||||
|
|
||||||
|
if (template_query.find(substitution_mask) == String::npos) /// nothing to substitute here
|
||||||
|
{
|
||||||
|
runThroughAllOptionsAndPush(std::next(substitutions_left), substitutions_right, template_query, queries);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const String & value : substitutions_left->second)
|
||||||
{
|
{
|
||||||
/// Copy query string for each unique permutation
|
/// Copy query string for each unique permutation
|
||||||
Query query = template_query;
|
Query query = template_query;
|
||||||
StringKeyValue substitutions_map = template_substitutions_map;
|
|
||||||
size_t substr_pos = 0;
|
size_t substr_pos = 0;
|
||||||
|
|
||||||
while (substr_pos != String::npos)
|
while (substr_pos != String::npos)
|
||||||
{
|
{
|
||||||
substr_pos = query.find("{" + name + "}");
|
substr_pos = query.find(substitution_mask);
|
||||||
|
|
||||||
if (substr_pos != String::npos)
|
if (substr_pos != String::npos)
|
||||||
{
|
query.replace(substr_pos, substitution_mask.length(), value);
|
||||||
query.replace(substr_pos, 1 + name.length() + 1, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
substitutions_map[name] = value;
|
runThroughAllOptionsAndPush(std::next(substitutions_left), substitutions_right, query, queries);
|
||||||
|
|
||||||
/// If we've reached the end of substitution chain
|
|
||||||
if (substitutions_left == substitutions_right)
|
|
||||||
{
|
|
||||||
queries.push_back(query);
|
|
||||||
substitutions_maps.push_back(substitutions_map);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
StringToVector::iterator next_it = substitutions_left;
|
|
||||||
++next_it;
|
|
||||||
|
|
||||||
runThroughAllOptionsAndPush(next_it, substitutions_right, query, queries, substitutions_map);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user