timeseries_table_format/transaction_log/actions.rs
1//! Log actions and commit payload definitions.
2//!
3//! Each commit file stores a [`Commit`] containing ordered [`LogAction`] values
4//! that mutate table state: adding/removing segments or updating table metadata.
5//! The surrounding modules own the data structures referenced here, while this
6//! module focuses on the log’s “verbs”.
7use chrono::{DateTime, Utc};
8use serde::{Deserialize, Serialize};
9
10use crate::transaction_log::{IndexKind, TableMetaDelta, segments::SegmentMeta};
11/// An action recorded in a commit.
12///
13/// Each commit contains a sequence of actions that are applied in order to
14/// evolve table state.
15#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
16pub enum LogAction {
17 /// Add a segment whose path is not currently live.
18 AddSegment(SegmentMeta),
19
20 /// Remove a segment by its canonical table-relative path.
21 RemoveSegment {
22 /// Canonical table-relative path of the segment to remove.
23 path: String,
24 },
25
26 /// Update table-level metadata (v0.1 uses full replacement).
27 UpdateTableMeta(TableMetaDelta),
28
29 /// Points to the table-level coverage snapshot sidecar for this commit version.
30 UpdateTableCoverage {
31 /// Canonical ordered-index coverage descriptor.
32 index_kind: IndexKind,
33 /// Path to the coverage data.
34 coverage_path: String,
35 },
36}
37
38/// A single, immutable commit in the metadata log.
39///
40/// Commits are written to files such as `_timeseries_log/0000000001.json`.
41/// The version field must match the file name; `base_version` records what
42/// the writer believed was the current version when the commit was prepared.
43#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
44pub struct Commit {
45 /// The version number of this commit (monotonic, starting from 1).
46 pub version: u64,
47
48 /// The version that the writer believed was current when preparing this
49 /// commit. Used by the OCC layer as a guard.
50 pub base_version: u64,
51
52 /// Commit creation timestamp, stored as RFC3339 UTC.
53 pub timestamp: DateTime<Utc>,
54
55 /// Ordered list of actions that describe how table state changes in this commit.
56 pub actions: Vec<LogAction>,
57}