reifydb_store_commit/
lib.rs1#![cfg_attr(not(debug_assertions), deny(clippy::disallowed_methods))]
5#![cfg_attr(debug_assertions, warn(clippy::disallowed_methods))]
6#![cfg_attr(not(debug_assertions), deny(warnings))]
7#![allow(clippy::tabs_in_doc_comments)]
8
9pub mod entry;
10pub mod rows;
11pub mod store;
12
13use std::collections::HashMap;
14
15use reifydb_codec::key::encoded::EncodedKey;
16use reifydb_core::{common::CommitVersion, interface::store::EntryKind, key::typed::OpaqueKey};
17use reifydb_store::coverage::cursor::{Cursor, ScannedStop};
18use reifydb_value::util::cowvec::CowVec;
19
20#[derive(Debug, Copy, Clone, PartialEq, Eq)]
21pub enum MultiVersionScope {
22 AsOf {
23 read: CommitVersion,
24 },
25 Between {
26 after: CommitVersion,
27 read: CommitVersion,
28 },
29}
30
31impl MultiVersionScope {
32 #[inline]
33 pub fn read(&self) -> CommitVersion {
34 match self {
35 Self::AsOf {
36 read,
37 }
38 | Self::Between {
39 read,
40 ..
41 } => *read,
42 }
43 }
44
45 #[inline]
46 pub fn contains(&self, v: CommitVersion) -> bool {
47 match self {
48 Self::AsOf {
49 read,
50 } => v <= *read,
51 Self::Between {
52 after,
53 read,
54 } => v > *after && v <= *read,
55 }
56 }
57}
58
59pub type TierBatch = HashMap<EntryKind, Vec<(EncodedKey, Option<CowVec<u8>>)>>;
60
61#[derive(Debug, Clone)]
62pub enum VersionedGetResult {
63 Value {
64 value: CowVec<u8>,
65 version: CommitVersion,
66 },
67 Tombstone,
68 NotFound,
69}
70
71impl VersionedGetResult {
72 pub fn value(self) -> Option<CowVec<u8>> {
73 match self {
74 VersionedGetResult::Value {
75 value,
76 ..
77 } => Some(value),
78 VersionedGetResult::Tombstone | VersionedGetResult::NotFound => None,
79 }
80 }
81}
82
83#[derive(Debug, Clone)]
84pub struct RawEntry<K = EncodedKey> {
85 pub key: K,
86 pub version: CommitVersion,
87 pub value: Option<CowVec<u8>>,
88}
89
90#[derive(Debug, Clone)]
91pub struct RangeBatch<K = EncodedKey> {
92 pub entries: Vec<RawEntry<K>>,
93 pub has_more: bool,
94}
95
96impl<K> RangeBatch<K> {
97 pub fn empty() -> Self {
98 Self {
99 entries: Vec::new(),
100 has_more: false,
101 }
102 }
103
104 pub fn is_empty(&self) -> bool {
105 self.entries.is_empty()
106 }
107}
108
109#[derive(Debug, Clone, Copy, PartialEq, Eq)]
110pub enum RangeStop {
111 Scanned,
112 AbsentTable,
113}
114
115pub type RangeCursor = Cursor<RangeStop, OpaqueKey>;
116
117impl ScannedStop for RangeStop {
118 fn scanned(&self) -> bool {
119 matches!(self, RangeStop::Scanned)
120 }
121}
122
123#[derive(Debug, Default)]
124pub struct HistoricalSweep {
125 pub entries: Vec<(EncodedKey, CommitVersion)>,
126 pub remaining: u64,
127}