#pragma once #include #include #include #include namespace DB { /// Просто считает, сколько раз её вызвали class AggregateFunctionCount : public INullaryAggregateFunction { private: UInt64 count; public: AggregateFunctionCount() : count(0) {} String getName() const { return "count"; } String getTypeID() const { return "count"; } AggregateFunctionPlainPtr cloneEmpty() const { return new AggregateFunctionCount; } DataTypePtr getReturnType() const { return new DataTypeVarUInt; } void addZero() { ++count; } void merge(const IAggregateFunction & rhs) { count += static_cast(rhs).count; } void serialize(WriteBuffer & buf) const { writeVarUInt(count, buf); } void deserializeMerge(ReadBuffer & buf) { UInt64 tmp; readVarUInt(tmp, buf); count += tmp; } Field getResult() const { return count; } }; }