Skip to main content

CheckpointEntry

Struct CheckpointEntry 

Source
pub struct CheckpointEntry {
    pub log_begin: u64,
    pub log_head: u64,
    pub log_read_only: u64,
    pub log_tail: u64,
    pub index_image_addr: u64,
    pub index_image_len: u64,
    pub key_count: u64,
    pub epoch: u32,
}
Expand description

One shard’s position in its log, as of the last checkpoint.

Sixty four bytes, one cache line, which is not an accident: recovery reads every one of these and nothing else before it starts replaying.

Fields§

§log_begin: u64

The oldest address still in the file.

§log_head: u64

The boundary between the stable region and the read only region.

§log_read_only: u64

The boundary between the read only region and the mutable region.

§log_tail: u64

Where the next append goes, and where replay starts.

§index_image_addr: u64

Where the checkpointed index image lives.

§index_image_len: u64

How long it is.

§key_count: u64

Keys in this shard at the checkpoint, for INFO and for a sanity check after replay.

§epoch: u32

The shard’s epoch at the checkpoint.

Implementations§

Source§

impl CheckpointEntry

Source

pub fn encode(&self, buf: &mut [u8])

Writes the entry and its checksum into 64 bytes.

§Panics

If buf is not exactly CHECKPOINT_ENTRY_LEN bytes.

Source

pub fn decode(buf: &[u8]) -> Result<CheckpointEntry>

Reads one entry back, checking its checksum and its ordering.

The ordering check is the useful one. Four addresses that are not monotonic describe a log with a negative sized region, and replaying from that produces a plausible looking database out of arbitrary bytes.

Source

pub const fn addresses_are_ordered(&self) -> bool

begin <= head <= read_only <= tail, which 06 section 2 requires.

Trait Implementations§

Source§

impl Clone for CheckpointEntry

Source§

fn clone(&self) -> CheckpointEntry

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 Copy for CheckpointEntry

Source§

impl Debug for CheckpointEntry

Source§

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

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

impl Default for CheckpointEntry

Source§

fn default() -> CheckpointEntry

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

impl Eq for CheckpointEntry

Source§

impl PartialEq for CheckpointEntry

Source§

fn eq(&self, other: &CheckpointEntry) -> 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 CheckpointEntry

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> 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, 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> 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.