Skip to main content

WalRecord

Enum WalRecord 

Source
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

§

Begin

Start of a transaction

Fields

§tx_id: u64
§

Commit

Commit of a transaction

Fields

§tx_id: u64
§

Rollback

Rollback of a transaction

Fields

§tx_id: u64
§

PageWrite

Write of a page — always carries uncompressed data (transparent to callers: read() decompresses on-the-fly).

Fields

§tx_id: u64
§page_id: u32
§data: Vec<u8>
§

TxCommitBatch

Atomic logical commit batch. Recovery applies all actions in order iff this complete record and checksum are present.

Fields

§tx_id: u64
§actions: Vec<Vec<u8>>
§

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.

Fields

§tx_id: u64
§page_id: u32
§ckpt_epoch: u64
§data: Vec<u8>
§

VectorInsert

Logical vector insert payload. Recovery can replay FP32 into the in-memory vector-turbo index without requiring snapshot files.

Fields

§collection: String
§entity_id: u64
§vector: Vec<f32>
§

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.

Fields

§kind: u8
§operation: u8
§name: String
§operands: Vec<Vec<u8>>
§

Checkpoint

Checkpoint marker (indicates up to which LSN pages are flushed)

Fields

§lsn: u64

Implementations§

Source§

impl WalRecord

Source

pub fn encode(&self) -> Vec<u8> ⓘ

Serialize record to bytes (including checksum).

PageWrite compression and physical framing are owned by reddb-file.

Source

pub fn encode_with_term(&self, term: u64) -> Vec<u8> ⓘ

Serialize record to bytes with the replication term stamped into the physical record envelope.

Source

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().

Source

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.

Source

pub fn encode_with_authority_into( &self, out: &mut Vec<u8>, authority: WalRecordAuthority, )

Source

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.

Source

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.

Source

pub fn read_with_authority<R: Read>( reader: &mut R, ) -> Result<Option<(WalRecordAuthority, WalRecord)>>

Read a record and return the term + ownership epoch stamped into its physical envelope.

Trait Implementations§

Source§

impl Clone for WalRecord

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WalRecord

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for WalRecord

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for WalRecord

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool