Skip to content
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 topKWeighted aggregate function #4245

Merged
merged 1 commit into from
Feb 10, 2019

Conversation

andrewgolman
Copy link
Contributor

@andrewgolman andrewgolman commented Feb 3, 2019

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Category (leave one):

  • New Feature

Short description (up to few sentences):
Added topKWeighted aggregate function that takes additional argument with (unsigned integer) weight.

if (set.capacity() != AggregateFunctionTopK<T>::reserved)
set.resize(AggregateFunctionTopK<T>::reserved);
set.insert(static_cast<const ColumnVector<T> &>(*columns[0]).getData()[row_num],
static_cast<const ColumnVector<T> &>(*columns[1]).getData()[row_num]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function arguments can have different types.
try SELECT topKWeighted(10)(number, number % 100) FROM numbers(1000)

Copy link
Member

@alexey-milovidov alexey-milovidov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes required.

@@ -48,16 +48,21 @@ static IAggregateFunction * createWithExtraTypes(const DataTypePtr & argument_ty
return new AggregateFunctionTopKGeneric<false>(threshold, argument_type);
}

template<bool weighed>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo.

@alexey-milovidov alexey-milovidov changed the title Add topKWeighed aggregate function Add topKWeighted aggregate function Feb 10, 2019
@alexey-milovidov
Copy link
Member

It doesn't work for generic types:

SELECT topKWeighted(toString(number), number) FROM numbers(10)

alexey-milovidov added a commit that referenced this pull request Feb 10, 2019
alexey-milovidov added a commit that referenced this pull request Feb 10, 2019
@alexey-milovidov alexey-milovidov merged commit 31f2f9c into ClickHouse:master Feb 10, 2019
@alexey-milovidov
Copy link
Member

Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants