1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Shared current-state evidence carried by prepared mutations.
//!
//! HOT resolves and decodes these values; transaction batches only carry them.
//! Keeping their data definitions here prevents serving types owning the
//! mutation vocabulary. Their durable encodings and validation are unchanged.
use crate::changelog::{ChangeId, CommitId};
use crate::common::LixTimestamp;
use bytes::Bytes;
/// Stable physical address of a row in an immutable columnar base.
///
/// The owner commit is part of the address so consumers can fail closed when
/// a stale coordinate is presented against a different base.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub(crate) struct ColumnarBaseCoordinate {
pub(crate) base_commit_id: CommitId,
pub(crate) group_index: u32,
pub(crate) row_index: u32,
}
#[derive(Debug, Clone)]
pub(crate) enum CertifiedCurrentStatePredecessor {
Encoded(Bytes),
Packed(PackedHeadValue),
}
#[derive(Debug, Clone, Copy)]
pub(crate) struct PackedHeadValue {
pub(crate) change_id: ChangeId,
pub(crate) commit_id: CommitId,
pub(crate) deleted: bool,
pub(crate) created_at: LixTimestamp,
pub(crate) updated_at: LixTimestamp,
pub(crate) working_diff_baseline: PackedWorkingDiffBaseline,
pub(crate) columnar_base_coordinate: Option<ColumnarBaseCoordinate>,
}
/// Checkpoint-relative position of a current-state base row that is served
/// without a branch-local hot row.
///
/// The two bases are not interchangeable and must not share one encoding. A
/// *packed* current base is a collection published **inside** the active
/// working interval, so its rows were absent at the checkpoint. A *root*
/// current base is the referenced head itself, so its rows **are** the
/// checkpoint state. Collapsing both onto "has an active checkpoint id" made
/// the first branch-local mutation of a checkpointed identity look like a
/// creation.
#[derive(Debug, Clone, Copy)]
pub(crate) enum PackedWorkingDiffBaseline {
/// No active checkpoint owns this generation.
Disabled,
/// Published inside the active working interval: absent at the checkpoint.
AbsentAtCheckpoint { checkpoint_commit_id: CommitId },
/// Served from the referenced root current base: present at the active
/// checkpoint and unchanged since.
CleanAtCheckpoint,
}
/// One indexed value, encoded so that equality is a key prefix.
///
/// Integers use the same order-preserving flip as row-pk components so a
/// future range predicate can reuse this encoding unchanged.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub(crate) enum HotIndexValue {
String(String),
Integer(i64),
}