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 | |
14 | namespace duckdb { |
15 | |
16 | class ColumnStatistics { |
17 | public: |
18 | explicit ColumnStatistics(BaseStatistics stats_p); |
19 | ColumnStatistics(BaseStatistics stats_p, unique_ptr<DistinctStatistics> distinct_stats_p); |
20 | |
21 | public: |
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 | |
38 | private: |
39 | BaseStatistics stats; |
40 | //! The approximate count distinct stats of the column |
41 | unique_ptr<DistinctStatistics> distinct_stats; |
42 | }; |
43 | |
44 | } // namespace duckdb |
45 |