Skip to content

Commit

Permalink
[Performance](func) Opt the any_value agg function no group by (apach…
Browse files Browse the repository at this point in the history
  • Loading branch information
HappenLee authored Jul 3, 2024
1 parent 4984222 commit cb795bd
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions be/src/vec/aggregate_functions/aggregate_function_min_max.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ template <typename Data>
struct AggregateFunctionMaxData : public Data {
using Self = AggregateFunctionMaxData;
using Data::IsFixedLength;
constexpr static bool IS_ANY = false;

AggregateFunctionMaxData() { reset(); }

Expand Down Expand Up @@ -476,6 +477,7 @@ template <typename Data>
struct AggregateFunctionMinData : Data {
using Self = AggregateFunctionMinData;
using Data::IsFixedLength;
constexpr static bool IS_ANY = false;

AggregateFunctionMinData() { reset(); }

Expand All @@ -502,6 +504,7 @@ template <typename Data>
struct AggregateFunctionAnyData : Data {
using Self = AggregateFunctionAnyData;
using Data::IsFixedLength;
constexpr static bool IS_ANY = true;

void change_if_better(const IColumn& column, size_t row_num, Arena* arena) {
this->change_first_time(column, row_num, arena);
Expand Down Expand Up @@ -542,6 +545,16 @@ class AggregateFunctionsSingleValue final
this->data(place).change_if_better(*columns[0], row_num, arena);
}

void add_batch_single_place(size_t batch_size, AggregateDataPtr place, const IColumn** columns,
Arena* arena) const override {
if constexpr (Data::IS_ANY) {
DCHECK_GT(batch_size, 0);
this->data(place).change_if_better(*columns[0], 0, arena);
} else {
Base::add_batch_single_place(batch_size, place, columns, arena);
}
}

void reset(AggregateDataPtr place) const override { this->data(place).reset(); }

void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs,
Expand Down

0 comments on commit cb795bd

Please sign in to comment.