Skip to main content

reifydb_core/value/column/
stats.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2025 ReifyDB
3
4use std::collections::HashMap;
5
6use reifydb_type::value::Value;
7
8#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
9pub enum Stat {
10	Min,
11	Max,
12	NoneCount,
13	TrueCount,
14	FalseCount,
15	IsSorted,
16	IsStrictSorted,
17	IsConstant,
18	DistinctCount,
19	RunCount,
20	UncompressedSize,
21}
22
23#[derive(Clone, Debug, Default)]
24pub struct StatsSet {
25	facts: HashMap<Stat, Value>,
26}
27
28impl StatsSet {
29	pub fn new() -> Self {
30		Self::default()
31	}
32
33	pub fn get(&self, stat: Stat) -> Option<&Value> {
34		self.facts.get(&stat)
35	}
36
37	pub fn set(&mut self, stat: Stat, value: Value) {
38		self.facts.insert(stat, value);
39	}
40
41	pub fn known(&self) -> impl Iterator<Item = Stat> + '_ {
42		self.facts.keys().copied()
43	}
44
45	pub fn len(&self) -> usize {
46		self.facts.len()
47	}
48
49	pub fn is_empty(&self) -> bool {
50		self.facts.is_empty()
51	}
52}