| 1 | #include <AggregateFunctions/QuantileTDigest.h> |
|---|---|
| 2 | #include <IO/WriteBufferFromString.h> |
| 3 | #include <IO/ReadBufferFromString.h> |
| 4 | |
| 5 | int main(int, char **) |
| 6 | { |
| 7 | using namespace DB; |
| 8 | |
| 9 | QuantileTDigest<float> tdigest; |
| 10 | tdigest.add(1); |
| 11 | tdigest.add(2); |
| 12 | tdigest.add(3); |
| 13 | std::cout << tdigest.get(0.5) << "\n"; |
| 14 | WriteBufferFromOwnString wb; |
| 15 | tdigest.serialize(wb); |
| 16 | QuantileTDigest<float> other; |
| 17 | ReadBufferFromString rb{wb.str()}; |
| 18 | other.deserialize(rb); |
| 19 | std::cout << other.get(0.5) << "\n"; |
| 20 | |
| 21 | return 0; |
| 22 | } |
| 23 |