Gabriel39 commented on code in PR #11801:
URL: https://github.com/apache/doris/pull/11801#discussion_r947586766
##########
be/src/vec/aggregate_functions/aggregate_function_avg.h:
##########
@@ -136,6 +143,70 @@ class AggregateFunctionAvg final
column.get_data().push_back(this->data(place).template
result<ResultType>());
}
+ void deserialize_from_column(AggregateDataPtr places, const IColumn&
column, Arena* arena,
+ size_t num_rows) const override {
+ auto& col = assert_cast<const ColumnFixedLengthObject&>(column);
+ DCHECK(col.size() >= num_rows) << "source column's size should greater
than num_rows";
+ auto* data = col.get_data().data();
+ memcpy(places, data, sizeof(Data) * num_rows);
+ }
+
+ void serialize_to_column(const std::vector<AggregateDataPtr>& places,
size_t offset,
+ MutableColumnPtr& dst, const size_t num_rows)
const override {
+ auto& col = assert_cast<ColumnFixedLengthObject&>(*dst);
+ col.set_item_size(sizeof(Data));
+ col.resize(num_rows);
+ auto* data = col.get_data().data();
+ for (size_t i = 0; i != num_rows; ++i) {
+ *reinterpret_cast<Data*>(&data[sizeof(Data) * i]) =
+ *reinterpret_cast<Data*>(places[i] + offset);
+ }
+ }
+
+ void streaming_agg_serialize_to_column(const IColumn** columns,
MutableColumnPtr& dst,
+ const size_t num_rows, Arena*
arena) const override {
+ auto* src_data = assert_cast<const
ColVecType&>(*columns[0]).get_data().data();
+ auto& dst_col = static_cast<ColumnFixedLengthObject&>(*dst);
+ dst_col.set_item_size(sizeof(Data));
+ dst_col.resize(num_rows);
+ auto* data = dst_col.get_data().data();
+ for (size_t i = 0; i != num_rows; ++i) {
+ auto& state = *reinterpret_cast<Data*>(&data[sizeof(Data) * i]);
+ state.sum = src_data[i];
+ state.count = 1;
+ }
+ }
+
+ void deserialize_and_merge_from_column(AggregateDataPtr __restrict place,
const IColumn& column,
+ Arena* arena) const override {
+ auto& col = assert_cast<const ColumnFixedLengthObject&>(column);
+ const size_t num_rows = column.size();
+ DCHECK(col.size() >= num_rows) << "source column's size should greater
than num_rows";
+ auto* data = reinterpret_cast<const Data*>(col.get_data().data());
+
+ for (size_t i = 0; i != num_rows; ++i) {
+ this->data(place).sum += data[i].sum;
+ this->data(place).count += data[i].count;
+ }
+ }
+
+ void serialize_without_key_to_column(ConstAggregateDataPtr __restrict
place,
+ MutableColumnPtr& dst) const override
{
+ auto& col = assert_cast<ColumnFixedLengthObject&>(*dst);
+ col.set_item_size(sizeof(Data));
+ col.resize(1);
+ *reinterpret_cast<Data*>(col.get_data().data()) = this->data(place);
+ ;
Review Comment:
```suggestion
```
--
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]