2011-09-19 03:40:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/AggregateFunctions/IAggregateFunction.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/** Интерфейс для агрегатных функций, принимающих одно значение. Это почти все агрегатные функции.
|
|
|
|
*/
|
2013-02-08 19:34:44 +00:00
|
|
|
template <typename T>
|
|
|
|
class IUnaryAggregateFunction : public IAggregateFunctionHelper<T>
|
2011-09-19 03:40:05 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
void setArguments(const DataTypes & arguments)
|
|
|
|
{
|
|
|
|
if (arguments.size() != 1)
|
2013-02-08 23:41:05 +00:00
|
|
|
throw Exception("Passed " + Poco::NumberFormatter::format(arguments.size()) + " arguments to unary aggregate function " + this->getName(),
|
2011-09-19 03:40:05 +00:00
|
|
|
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
2011-09-26 04:00:46 +00:00
|
|
|
setArgument(arguments[0]);
|
2011-09-19 03:40:05 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 05:07:47 +00:00
|
|
|
virtual void setArgument(const DataTypePtr & argument) = 0;
|
|
|
|
|
2011-09-19 03:40:05 +00:00
|
|
|
/// Добавить значение.
|
2013-02-08 23:41:05 +00:00
|
|
|
void add(AggregateDataPtr place, const Row & row) const
|
2011-09-19 03:40:05 +00:00
|
|
|
{
|
2013-02-08 19:34:44 +00:00
|
|
|
addOne(place, row[0]);
|
2011-09-19 03:40:05 +00:00
|
|
|
}
|
|
|
|
|
2013-02-08 23:41:05 +00:00
|
|
|
virtual void addOne(AggregateDataPtr place, const Field & value) const = 0;
|
2011-09-19 03:40:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|