Skip to main content

ChainAssembler

Struct ChainAssembler 

Source
pub struct ChainAssembler { /* private fields */ }
Expand description

Reconstructs a (possibly chained) commit from consecutive framed WAL records, fed one at a time in physical log order. The overwhelmingly common case — a BARE/WITH_COMMAND record — reconstructs immediately. A chained commit’s CHAIN_CONTINUE fragments are buffered until the matching CHAIN_FINAL is fed, at which point the whole op-set is returned — in full, exactly once, never partially. This is the one reconstruction implementation crash recovery and replication apply both use, so there is never a second, potentially drifting copy of this logic.

Implementations§

Source§

impl ChainAssembler

Source

pub fn feed(&mut self, raw: &[u8], offset: u64) -> Result<ChainFeed, String>

Feed one decoded, checksum-verified framed record, at offset in whatever byte stream the caller is scanning (the segment file for recovery, the replication page stream for a follower). Purely structural: never decodes the op-set or command (see ChainFeed::Complete’s doc for why).

§Errors

Returns an error if a CHAIN_CONTINUE/CHAIN_FINAL arrives for a different LSN than the currently-open chain, if a BARE/ WITH_COMMAND record arrives while a chain is open, or if the frame itself fails to decode (bad magic/version/checksum) — all of which indicate a corrupt or reordered log, never a legitimate write pattern.

Source

pub fn is_open(&self) -> bool

True while a chain is open (fragments buffered, final not yet seen).

Source

pub fn open_lsn(&self) -> Option<u64>

The LSN of the currently-open chain, if any.

Source

pub fn open_start_offset(&self) -> Option<u64>

The byte offset where the currently-open chain’s first fragment began, if any — what a caller reaching end-of-stream with an open chain must truncate back to (discarding the whole incomplete chain, never partially applying it).

Trait Implementations§

Source§

impl Default for ChainAssembler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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.