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
Optimize group by constant keys #53549
Merged
Merged
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7fa72f5
Optimize group by constant keys
Avogar 1f5e209
Better comment
Avogar aac5131
Fix for no_more_keys
Avogar 0da8fe2
Add missing constexpr
Avogar 2d4167c
FRemove unneded changes
Avogar 93ba737
Merge branch 'master' of github.com:ClickHouse/ClickHouse into group-…
Avogar 59ca237
Better
Avogar 27fb1b5
Fix test
Avogar 4b5784f
Fix test
Avogar b106395
Update test reference
Avogar 5b29640
Merge branch 'master' into group-by-constant-keys
Avogar 2075f9c
Merge branch 'master' into group-by-constant-keys
Avogar a075d03
Fix
Avogar File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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,39 @@ | ||
#pragma once | ||
#include <utility> | ||
|
||
namespace DB | ||
{ | ||
|
||
/// Special struct that helps to convert bool variables to function template bool arguments. | ||
/// It can be used to avoid multiple nested if/else on bool arguments. How to use it: | ||
/// Imagine you have template function | ||
/// template <bool b1, bool b2, ..., bool bn> return_type foo(...); | ||
/// and bool variables b1, b2, ..., bn. To pass these variables as template for foo you can do the following: | ||
/// | ||
/// auto call_foo = []<bool b1, bool b2, ..., bool bn>() | ||
/// { | ||
/// return foo<b1, b2, ..., bn>(...); | ||
/// } | ||
/// | ||
/// BoolArgsToTemplateArgsDispatcher::call<decltype(call_foo)>(call_foo, b1, b2, ..., bn); | ||
|
||
template <class Functor, bool... Args> | ||
struct BoolArgsToTemplateArgsDispatcher | ||
{ | ||
template <typename... Args1> | ||
static auto call(Functor f, Args1&&... args) | ||
{ | ||
return f.template operator()<Args...>(std::forward<Args1>(args)...); | ||
} | ||
|
||
template <class... Args1> | ||
static auto call(Functor f, bool b, Args1&&... ar1) | ||
{ | ||
if (b) | ||
return BoolArgsToTemplateArgsDispatcher<Functor, Args..., true>::call(f, std::forward<Args1>(ar1)...); | ||
else | ||
return BoolArgsToTemplateArgsDispatcher<Functor, Args..., false>::call(f, std::forward<Args1>(ar1)...); | ||
} | ||
}; | ||
|
||
} |
This file contains 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 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 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 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 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 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 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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it better? I didn't understand why we need this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise we will need to write ~16 if/else branches to check all 4 bool arguments (maybe some of them won't actually appear, but still a lot).
Like https://pastila.nl/?01f3324d/a170ed3f747f063f81f5821188dd8aa3#B7nUAYOQzbzMvGUQ6wClTw==
And IMHO do it in a few lines with some dispatcher class is better. But you can disagree and I can bring back this batch of if/else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like dispatchers as well. I think the issue is with executeImplBatch and we should refactor it somehow.