1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/storage/statistics/column_statistics.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/storage/statistics/base_statistics.hpp"
12#include "duckdb/storage/statistics/distinct_statistics.hpp"
13
14namespace duckdb {
15
16class ColumnStatistics {
17public:
18 explicit ColumnStatistics(BaseStatistics stats_p);
19 ColumnStatistics(BaseStatistics stats_p, unique_ptr<DistinctStatistics> distinct_stats_p);
20
21public:
22 static shared_ptr<ColumnStatistics> CreateEmptyStats(const LogicalType &type);
23
24 void Merge(ColumnStatistics &other);
25
26 void UpdateDistinctStatistics(Vector &v, idx_t count);
27
28 BaseStatistics &Statistics();
29
30 bool HasDistinctStats();
31 DistinctStatistics &DistinctStats();
32 void SetDistinct(unique_ptr<DistinctStatistics> distinct_stats);
33
34 shared_ptr<ColumnStatistics> Copy() const;
35 void Serialize(Serializer &serializer) const;
36 static shared_ptr<ColumnStatistics> Deserialize(Deserializer &source, const LogicalType &type);
37
38private:
39 BaseStatistics stats;
40 //! The approximate count distinct stats of the column
41 unique_ptr<DistinctStatistics> distinct_stats;
42};
43
44} // namespace duckdb
45