-
Notifications
You must be signed in to change notification settings - Fork 411
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
Add decrease interface for aggregation #9737
base: master
Are you sure you want to change the base?
Conversation
/retest |
|
||
void decrease(AggregateDataPtr __restrict, const IColumn **, const size_t, Arena *) const override | ||
{ | ||
throw Exception("Not implemented yet"); |
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.
add method name and agg func name in error message?
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.
add method name and agg func name in error message?
done
@@ -594,6 +600,10 @@ struct AggregateFunctionMinData : Data | |||
} | |||
bool changeIfBetter(const Self & to, Arena * arena) { return this->changeIfLess(to, arena); } | |||
|
|||
void prepareWindow() { throw Exception("Not implemented yet"); } |
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.
Looks like SingleValueDataGeneric
derived from CommonImpl
, so prepareWindow
is not needed here?
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.
Looks like
SingleValueDataGeneric
derived fromCommonImpl
, soprepareWindow
is not needed here?
done
@@ -602,10 +612,13 @@ struct AggregateFunctionMaxData : Data | |||
{ | |||
using Self = AggregateFunctionMaxData<Data>; | |||
|
|||
void insertResultInto(IColumn & to) const { Data::insertResultInto(to); } |
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.
ditto
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.
ditto
done
@@ -594,6 +600,10 @@ struct AggregateFunctionMinData : Data | |||
} | |||
bool changeIfBetter(const Self & to, Arena * arena) { return this->changeIfLess(to, arena); } | |||
|
|||
void prepareWindow() { throw Exception("Not implemented yet"); } | |||
|
|||
void insertResultInto(IColumn & to) const { Data::insertResultInto(to); } |
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.
this can be removed?
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.
this can be removed?
done
|
||
bool changeIfLess(const Self & to, Arena * arena) | ||
{ | ||
if (saved_values != nullptr) |
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.
Is this necessary ? you mean prepareWindow()
is not always called?
but reset()
didn't check if saved_values
is nullptr
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.
Is this necessary ? you mean
prepareWindow()
is not always called? butreset()
didn't check ifsaved_values
is nullptr
Yes, in some circumstance, we will never call decrease function.
/cc @guo-shaoge |
int recursion_level) const | ||
{ | ||
AggregateFunctionCombinatorPtr combinator | ||
= AggregateFunctionCombinatorFactory::instance().tryFindSuffix("NullForWindow"); |
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.
even if the argument is not null, it still need this combinator?
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.
even if the argument is not null, it still need this combinator?
yes
@@ -75,7 +75,10 @@ class AggregateFunctionForEach final | |||
size_t old_size = state.dynamic_array_size; | |||
if (old_size < new_size) | |||
{ | |||
state.array_of_aggregate_datas = arena.realloc( | |||
if unlikely (arena == nullptr) | |||
throw Exception("Get nullptr in ensureAggregateData"); |
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.
throw Exception("Get nullptr in ensureAggregateData"); | |
throw Exception("Get null arena ptr in ensureAggregateData"); |
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.
done
} | ||
} | ||
|
||
void prepareWindow(AggregateDataPtr __restrict place) const override |
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 suggest that for the agg function that is not supported by window operator, do not implement these window function specific interface, since it will never be used and can not be well tested.
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 suggest that for the agg function that is not supported by window operator, do not implement these window function specific interface, since it will never be used and can not be well tested.
done
using Self = SingleValueDataFixedForWindow<T>; | ||
using ColumnType = std::conditional_t<IsDecimal<T>, ColumnDecimal<T>, ColumnVector<T>>; | ||
|
||
mutable std::deque<T> * saved_values; |
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 need use raw pointer here
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 need use raw pointer here
we now drop pointer now.
void changeIfLess(const IColumn & column, size_t row_num, Arena * arena) | ||
{ | ||
auto to_value = static_cast<const ColumnType &>(column).getData()[row_num]; | ||
if (saved_values != nullptr) |
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 can't we ensure that saved_values
must be not null? If the call fallback to SingleValueDataFixed<T>::changeIfLess(column, row_num, arena);
it seems meaningless.
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 can't we ensure that
saved_values
must be not null? If the call fallback toSingleValueDataFixed<T>::changeIfLess(column, row_num, arena);
it seems meaningless.
The check for saved_values
has been deleted.
|
||
if (result_is_nullable && need_counter) | ||
{ | ||
auto tmp = prefix_size; |
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.
if prefix_size >= sizeof(Int64)
there is no need to use more prefix size?
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.
if
prefix_size >= sizeof(Int64)
there is no need to use more prefix size?
no, when prefix_size == sizeof(Int64) the null flag always needs 1 byte, in this case we need more prefix size, when prefix_size > sizeof(Int64), in order to ensure the alignment, we may still need to add prefix size to ensure the alignment.
if constexpr (is_add) | ||
{ | ||
this->addCounter(place); | ||
this->setFlag(place); |
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 still need the flag if we already has counter?
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 still need the flag if we already has counter?
Because we inherit AggregateFunctionNullBase
and AggregateFunctionNullBase
needs this flag.
/unhold |
if constexpr (is_min) | ||
iter = saved_values.begin(); | ||
else | ||
iter = --(saved_values.end()); |
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.
iter = --(saved_values.end()); | |
auto iter = std::prev(saved_values.end()); |
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.
done
namespace DB | ||
{ | ||
/** Aggregate functions that store one of passed values. | ||
* For example: min, max, any, anyLast. | ||
*/ | ||
|
||
struct CommonImpl | ||
{ | ||
static void decrease(const IColumn &, size_t) { throw Exception(" decrease is not implemented yet"); } |
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 extra space before error msg?
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 extra space before error msg?
done
other lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: guo-shaoge The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
@xzhangxian1008: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
What problem does this PR solve?
Issue Number: ref #7376
Problem Summary:
What is changed and how it works?
Check List
Tests
Side effects
Documentation
Release note