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: u64The oldest address still in the file.
log_head: u64The boundary between the stable region and the read only region.
log_read_only: u64The boundary between the read only region and the mutable region.
log_tail: u64Where the next append goes, and where replay starts.
index_image_addr: u64Where the checkpointed index image lives.
index_image_len: u64How long it is.
key_count: u64Keys in this shard at the checkpoint, for INFO and for a sanity check
after replay.
epoch: u32The shard’s epoch at the checkpoint.
Implementations§
Source§impl CheckpointEntry
impl CheckpointEntry
Sourcepub fn encode(&self, buf: &mut [u8])
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.
Sourcepub fn decode(buf: &[u8]) -> Result<CheckpointEntry>
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.
Sourcepub const fn addresses_are_ordered(&self) -> bool
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
impl Clone for CheckpointEntry
Source§fn clone(&self) -> CheckpointEntry
fn clone(&self) -> CheckpointEntry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more