2021-04-14 20:38:56 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AggregateFunctions/Bfloat16Histogram.h>
|
|
|
|
|
2021-04-24 19:11:56 +00:00
|
|
|
namespace DB
|
2021-04-14 20:38:56 +00:00
|
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2021-04-24 19:11:56 +00:00
|
|
|
template <typename Value>
|
|
|
|
struct QuantileBfloat16Histogram
|
2021-04-14 20:38:56 +00:00
|
|
|
{
|
2021-04-24 19:11:56 +00:00
|
|
|
using Histogram = Bfloat16Histogram<Value>;
|
|
|
|
Histogram data;
|
2021-04-14 20:38:56 +00:00
|
|
|
|
2021-04-24 19:11:56 +00:00
|
|
|
void add(const Value & x) { data.add(x); }
|
2021-04-14 20:38:56 +00:00
|
|
|
|
|
|
|
template <typename Weight>
|
|
|
|
void add(const Value &, const Weight &)
|
|
|
|
{
|
|
|
|
throw Exception("Method add with weight is not implemented for QuantileBfloat16Histogram", ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
2021-04-24 19:11:56 +00:00
|
|
|
void merge(const QuantileBfloat16Histogram & rhs) { data.merge(rhs.data); }
|
2021-04-14 20:38:56 +00:00
|
|
|
|
2021-04-24 19:11:56 +00:00
|
|
|
void serialize(WriteBuffer & buf) const { data.write(buf); }
|
2021-04-14 20:38:56 +00:00
|
|
|
|
2021-04-24 19:11:56 +00:00
|
|
|
void deserialize(ReadBuffer & buf) { data.read(buf); }
|
2021-04-14 20:38:56 +00:00
|
|
|
|
2021-04-24 19:11:56 +00:00
|
|
|
Value get(Float64 level) { return data.quantile(level); }
|
2021-04-14 20:38:56 +00:00
|
|
|
|
|
|
|
void getMany(const Float64 * levels, const size_t * indices, size_t size, Value * result)
|
|
|
|
{
|
|
|
|
data.quantilesMany(levels, indices, size, result);
|
|
|
|
}
|
|
|
|
|
2021-04-24 19:11:56 +00:00
|
|
|
Float64 getFloat(Float64 level) { return data.quantile(level); }
|
2021-04-14 20:38:56 +00:00
|
|
|
|
|
|
|
void getManyFloat(const Float64 * levels, const size_t * indices, size_t size, Float64 * result)
|
|
|
|
{
|
|
|
|
data.quantilesMany(levels, indices, size, result);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-04-14 21:06:22 +00:00
|
|
|
}
|