From de52f6e35608b13c535be34ac9c7e6f00e36fec1 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Tue, 2 Apr 2024 17:32:22 +0800 Subject: [PATCH 1/4] [Improvement](agg) Improve count distinct distribute keys --- .../aggregate_function_simple_factory.cpp | 2 + .../aggregate_function_uniq_without_key.cpp | 73 +++++ .../aggregate_function_uniq_without_key.h | 256 ++++++++++++++++++ 3 files changed, 331 insertions(+) create mode 100644 be/src/vec/aggregate_functions/aggregate_function_uniq_without_key.cpp create mode 100644 be/src/vec/aggregate_functions/aggregate_function_uniq_without_key.h diff --git a/be/src/vec/aggregate_functions/aggregate_function_simple_factory.cpp b/be/src/vec/aggregate_functions/aggregate_function_simple_factory.cpp index 00597b212befd0..d95d0ce6ccb90d 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_simple_factory.cpp +++ b/be/src/vec/aggregate_functions/aggregate_function_simple_factory.cpp @@ -40,6 +40,7 @@ void register_aggregate_function_count(AggregateFunctionSimpleFactory& factory); void register_aggregate_function_count_by_enum(AggregateFunctionSimpleFactory& factory); void register_aggregate_function_HLL_union_agg(AggregateFunctionSimpleFactory& factory); void register_aggregate_function_uniq(AggregateFunctionSimpleFactory& factory); +void register_aggregate_function_uniq_distribute_key(AggregateFunctionSimpleFactory& factory); void register_aggregate_function_bit(AggregateFunctionSimpleFactory& factory); void register_aggregate_function_bitmap(AggregateFunctionSimpleFactory& factory); void register_aggregate_function_quantile_state(AggregateFunctionSimpleFactory& factory); @@ -80,6 +81,7 @@ AggregateFunctionSimpleFactory& AggregateFunctionSimpleFactory::instance() { register_aggregate_function_count(instance); register_aggregate_function_count_by_enum(instance); register_aggregate_function_uniq(instance); + register_aggregate_function_uniq_distribute_key(instance); register_aggregate_function_bit(instance); register_aggregate_function_bitmap(instance); register_aggregate_function_group_array_intersect(instance); diff --git a/be/src/vec/aggregate_functions/aggregate_function_uniq_without_key.cpp b/be/src/vec/aggregate_functions/aggregate_function_uniq_without_key.cpp new file mode 100644 index 00000000000000..9d8f0c7fa6d65c --- /dev/null +++ b/be/src/vec/aggregate_functions/aggregate_function_uniq_without_key.cpp @@ -0,0 +1,73 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "vec/aggregate_functions/aggregate_function_uniq_without_key.h" + +#include + +#include "vec/aggregate_functions/aggregate_function_simple_factory.h" +#include "vec/aggregate_functions/factory_helpers.h" +#include "vec/aggregate_functions/helpers.h" + +namespace doris::vectorized { + +template