pub enum WalRecord {
PageOwnership {
record: PageOwnershipRecord,
},
Begin {
tx_id: u64,
},
Commit {
tx_id: u64,
},
Rollback {
tx_id: u64,
},
PageWrite {
tx_id: u64,
page_id: u32,
data: Vec<u8>,
},
TxCommitBatch {
tx_id: u64,
actions: Vec<Vec<u8>>,
},
FullPageImage {
tx_id: u64,
page_id: u32,
ckpt_epoch: u64,
data: Vec<u8>,
},
VectorInsert {
collection: String,
entity_id: u64,
vector: Vec<f32>,
},
ProbabilisticDelta {
kind: u8,
operation: u8,
name: String,
operands: Vec<Vec<u8>>,
},
Checkpoint {
lsn: u64,
},
}Expand description
A single entry in the write-ahead log
Variants§
PageOwnership
Durable page-ownership intent. It must be resolved before page reuse.
Fields
record: PageOwnershipRecordBegin
Start of a transaction
Commit
Commit of a transaction
Rollback
Rollback of a transaction
PageWrite
Write of a page — always carries uncompressed data (transparent to
callers: read() decompresses on-the-fly).
TxCommitBatch
Atomic logical commit batch. Recovery applies all actions in order iff this complete record and checksum are present.
FullPageImage
Full-page image — pristine page bytes captured before the first
modification per checkpoint cycle. Recovery applies these before
redo so torn writes are healed without the -dwb sidecar.
VectorInsert
Logical vector insert payload. Recovery can replay FP32 into the in-memory vector-turbo index without requiring snapshot files.
ProbabilisticDelta
Logical probabilistic-structure mutation delta. Checkpoints carry full snapshots through the regular store state; crash recovery replays these deltas after loading the latest snapshot.
Checkpoint
Checkpoint marker (indicates up to which LSN pages are flushed)
Implementations§
Source§impl WalRecord
impl WalRecord
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
pub fn encode(&self) -> Vec<u8> ⓘ
Serialize record to bytes (including checksum).
PageWrite compression and physical framing are owned by reddb-file.
Sourcepub fn encode_with_term(&self, term: u64) -> Vec<u8> ⓘ
pub fn encode_with_term(&self, term: u64) -> Vec<u8> ⓘ
Serialize record to bytes with the replication term stamped into the physical record envelope.
Sourcepub fn encode_into(&self, out: &mut Vec<u8>)
pub fn encode_into(&self, out: &mut Vec<u8>)
Serialize record into a caller-owned scratch buffer, appending the
encoded bytes (including checksum) to out.
This is the allocation-light entry point for the lock-free append path:
concurrent appenders each encode into their own per-call out buffer
before taking the WAL lock, so the scratch is never shared across
threads and needs no thread_local!. Reusing one out across many
records (the commit blob) avoids the fresh Vec + copy that
encode allocates per record. The bytes appended are
byte-identical to encode().
Sourcepub fn encode_with_term_into(&self, out: &mut Vec<u8>, term: u64)
pub fn encode_with_term_into(&self, out: &mut Vec<u8>, term: u64)
Serialize record into a caller-owned scratch buffer with the replication
term stamped into the physical envelope. See encode_into.
The checksum is computed over only the bytes this call appends (the slice starting at the buffer’s prior length), so appending after existing records leaves them untouched and keeps each record’s CRC self-contained.
The payload is written straight from this record’s own buffers — the append path never clones a page image or a commit batch into an owned file frame first.
Sourcepub fn read<R: Read>(reader: &mut R) -> Result<Option<WalRecord>>
pub fn read<R: Read>(reader: &mut R) -> Result<Option<WalRecord>>
Read a record from a reader.
Handles both v1 (PageWrite) and v2 (PageWriteCompressed) record
formats transparently — callers always receive uncompressed data.
Sourcepub fn read_with_term<R: Read>(
reader: &mut R,
) -> Result<Option<(u64, WalRecord)>>
pub fn read_with_term<R: Read>( reader: &mut R, ) -> Result<Option<(u64, WalRecord)>>
Read a record and return the term stamped into its physical envelope.
Read a record and return the term + ownership epoch stamped into its physical envelope.
Trait Implementations§
impl StructuralPartialEq for WalRecord
Auto Trait Implementations§
impl Forget for WalRecord
impl Freeze for WalRecord
impl RefUnwindSafe for WalRecord
impl Send for WalRecord
impl Sync for WalRecord
impl Unpin for WalRecord
impl UnsafeUnpin for WalRecord
impl UnwindSafe for WalRecord
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request