ClickHouse/src/Storages/Statistics/TDigestStatistic.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
679 B
C++
Raw Normal View History

2023-11-28 15:32:47 +00:00
#include <Storages/Statistics/TDigestStatistic.h>
2023-10-29 23:39:16 +00:00
namespace DB
{
Float64 TDigestStatistic::estimateLess(Float64 val) const
{
return data.getCountLessThan(val);
}
void TDigestStatistic::serialize(WriteBuffer & buf)
{
data.serialize(buf);
}
void TDigestStatistic::deserialize(ReadBuffer & buf)
{
data.deserialize(buf);
}
void TDigestStatistic::update(const ColumnPtr & column)
{
size_t size = column->size();
for (size_t i = 0; i < size; ++i)
{
/// TODO: support more types.
Float64 value = column->getFloat64(i);
data.add(value, 1);
}
}
UInt64 TDigestStatistic::count()
{
return static_cast<UInt64>(data.count);
}
}