reifydb_core/key/operator/keyspace/
distinct.rs1use reifydb_value::value::row_number::RowNumber;
5
6use crate::{
7 key::{
8 operator::{
9 state::{GroupId, KeyspaceId},
10 traits::Keyspace,
11 },
12 typed::{
13 BoundedKey, DenseKey, KeyLayout,
14 direction::{Asc, Desc, Direction, KeyField},
15 layout::{KeyColumn, KeyColumnType, KeyLayout, KeyValue, KeyValues},
16 },
17 },
18 metrics::heap::HeapSize,
19};
20
21#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, KeyLayout, HeapSize)]
22pub struct DistinctEntryKey {
23 pub group: Desc<GroupId>,
24 pub row: Asc<RowNumber>,
25}
26
27#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, KeyLayout, HeapSize)]
28pub struct DistinctLayoutKey {}
29
30#[derive(Clone, Copy, Debug, PartialEq, Eq)]
31pub struct DistinctEntry;
32
33impl Keyspace for DistinctEntry {
34 const ID: KeyspaceId = KeyspaceId::DISTINCT_ENTRY;
35 const NAME: &'static str = "DISTINCT_ENTRY";
36 const RANGE_CACHED: bool = true;
37
38 type GroupedKey = DistinctEntryKey;
39 type Suffix = Asc<RowNumber>;
40
41 fn split(key: &Self::GroupedKey) -> (GroupId, Self::Suffix) {
42 (key.group.0, key.row)
43 }
44
45 fn join(group: GroupId, suffix: Self::Suffix) -> Self::GroupedKey {
46 DistinctEntryKey {
47 group: Desc(group),
48 row: suffix,
49 }
50 }
51}
52
53#[derive(Clone, Copy, Debug, PartialEq, Eq)]
54pub struct DistinctLayout;
55
56impl Keyspace for DistinctLayout {
57 const ID: KeyspaceId = KeyspaceId::DISTINCT_LAYOUT;
58 const NAME: &'static str = "DISTINCT_LAYOUT";
59 const RANGE_CACHED: bool = true;
60
61 type GroupedKey = DistinctLayoutKey;
62 type Suffix = DistinctLayoutKey;
63
64 fn split(key: &Self::GroupedKey) -> (GroupId, Self::Suffix) {
65 (GroupId::ROOT, *key)
66 }
67
68 fn join(_group: GroupId, suffix: Self::Suffix) -> Self::GroupedKey {
69 suffix
70 }
71}