[Enhancement] Split sumcount and distinct registration files (#63521)

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
Murphy 2025-09-26 13:45:33 +08:00 committed by GitHub
parent 6abc22dfa7
commit aab55d74fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 49 additions and 26 deletions

View File

@ -27,6 +27,7 @@ set(EXPR_FILES
agg/factory/aggregate_resolver_minmaxany.cpp
agg/factory/aggregate_resolver_others.cpp
agg/factory/aggregate_resolver_sumcount.cpp
agg/factory/aggregate_resolver_distinct.cpp
agg/factory/aggregate_resolver_stream.cpp
agg/factory/aggregate_resolver_utility.cpp
agg/factory/aggregate_resolver_variance.cpp

View File

@ -0,0 +1,48 @@
// Copyright 2021-present StarRocks, Inc. All rights reserved.
//
// Licensed 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
//
// https://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 "column/type_traits.h"
#include "exprs/agg/distinct.h"
#include "exprs/agg/factory/aggregate_factory.hpp"
#include "exprs/agg/factory/aggregate_resolver.hpp"
#include "types/logical_type.h"
namespace starrocks {
struct DistinctDispatcher {
template <LogicalType lt>
void operator()(AggregateFuncResolver* resolver) {
if constexpr (lt_is_aggregate<lt>) {
using DistinctState = DistinctAggregateState<lt, SumResultLT<lt>>;
using DistinctState2 = DistinctAggregateStateV2<lt, SumResultLT<lt>>;
resolver->add_aggregate_mapping<lt, TYPE_BIGINT, DistinctState>(
"multi_distinct_count", false, AggregateFactory::MakeCountDistinctAggregateFunction<lt>());
resolver->add_aggregate_mapping<lt, TYPE_BIGINT, DistinctState2>(
"multi_distinct_count2", false, AggregateFactory::MakeCountDistinctAggregateFunctionV2<lt>());
resolver->add_aggregate_mapping<lt, SumResultLT<lt>, DistinctState>(
"multi_distinct_sum", false, AggregateFactory::MakeSumDistinctAggregateFunction<lt>());
resolver->add_aggregate_mapping<lt, SumResultLT<lt>, DistinctState2>(
"multi_distinct_sum2", false, AggregateFactory::MakeSumDistinctAggregateFunctionV2<lt>());
}
}
};
void AggregateFuncResolver::register_distinct() {
for (auto type : aggregate_types()) {
type_dispatch_all(type, DistinctDispatcher(), this);
}
}
} // namespace starrocks

View File

@ -13,7 +13,6 @@
// limitations under the License.
#include "column/type_traits.h"
#include "exprs/agg/distinct.h"
#include "exprs/agg/factory/aggregate_factory.hpp"
#include "exprs/agg/factory/aggregate_resolver.hpp"
#include "exprs/agg/sum.h"
@ -52,25 +51,6 @@ struct StorageSumDispatcher {
}
};
struct DistinctDispatcher {
template <LogicalType lt>
void operator()(AggregateFuncResolver* resolver) {
if constexpr (lt_is_aggregate<lt>) {
using DistinctState = DistinctAggregateState<lt, SumResultLT<lt>>;
using DistinctState2 = DistinctAggregateStateV2<lt, SumResultLT<lt>>;
resolver->add_aggregate_mapping<lt, TYPE_BIGINT, DistinctState>(
"multi_distinct_count", false, AggregateFactory::MakeCountDistinctAggregateFunction<lt>());
resolver->add_aggregate_mapping<lt, TYPE_BIGINT, DistinctState2>(
"multi_distinct_count2", false, AggregateFactory::MakeCountDistinctAggregateFunctionV2<lt>());
resolver->add_aggregate_mapping<lt, SumResultLT<lt>, DistinctState>(
"multi_distinct_sum", false, AggregateFactory::MakeSumDistinctAggregateFunction<lt>());
resolver->add_aggregate_mapping<lt, SumResultLT<lt>, DistinctState2>(
"multi_distinct_sum2", false, AggregateFactory::MakeSumDistinctAggregateFunctionV2<lt>());
}
}
};
void AggregateFuncResolver::register_sumcount() {
for (auto type : aggregate_types()) {
type_dispatch_all(type, SumDispatcher(), this);
@ -93,10 +73,4 @@ void AggregateFuncResolver::register_sumcount() {
AggregateFactory::MakeCountNullableAggregateFunction<true>());
}
void AggregateFuncResolver::register_distinct() {
for (auto type : aggregate_types()) {
type_dispatch_all(type, DistinctDispatcher(), this);
}
}
} // namespace starrocks