HappenLee commented on code in PR #14209:
URL: https://github.com/apache/doris/pull/14209#discussion_r1020768086
##########
be/src/vec/aggregate_functions/aggregate_function_topn.h:
##########
@@ -228,6 +230,34 @@ struct AggregateFunctionTopNImplArray {
}
};
+//for topn_weighted agg
+template <typename T, bool has_default_param>
+struct AggregateFunctionTopNImplWeight {
+ using ColVecType =
+ std::conditional_t<IsDecimalNumber<T>, ColumnDecimal<Decimal128>,
ColumnVector<T>>;
+ static void add(AggregateFunctionTopNData<T>& __restrict place, const
IColumn** columns,
+ size_t row_num) {
+ if constexpr (has_default_param) {
+ place.set_paramenters(
+ static_cast<const
ColumnInt32*>(columns[2])->get_element(row_num),
+ static_cast<const
ColumnInt32*>(columns[3])->get_element(row_num));
+
+ } else {
+ place.set_paramenters(
+ static_cast<const
ColumnInt32*>(columns[2])->get_element(row_num));
+ }
+ if constexpr (std::is_same_v<T, std::string>) {
Review Comment:
here should do not use string. use `StringRef` or `StringValue` replace
##########
be/src/vec/aggregate_functions/aggregate_function_topn.h:
##########
@@ -228,6 +230,34 @@ struct AggregateFunctionTopNImplArray {
}
};
+//for topn_weighted agg
+template <typename T, bool has_default_param>
+struct AggregateFunctionTopNImplWeight {
+ using ColVecType =
+ std::conditional_t<IsDecimalNumber<T>, ColumnDecimal<Decimal128>,
ColumnVector<T>>;
+ static void add(AggregateFunctionTopNData<T>& __restrict place, const
IColumn** columns,
+ size_t row_num) {
+ if constexpr (has_default_param) {
+ place.set_paramenters(
+ static_cast<const
ColumnInt32*>(columns[2])->get_element(row_num),
+ static_cast<const
ColumnInt32*>(columns[3])->get_element(row_num));
+
+ } else {
+ place.set_paramenters(
+ static_cast<const
ColumnInt32*>(columns[2])->get_element(row_num));
+ }
+ if constexpr (std::is_same_v<T, std::string>) {
+ StringRef ref = static_cast<const
ColumnString&>(*columns[0]).get_data_at(row_num);
+ auto weight = static_cast<const
ColumnVector<Int64>&>(*columns[1]).get_data()[row_num];
+ place.add(std::string(ref.data, ref.size), weight);
Review Comment:
same as up, here cause useless mem copy
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]