pub struct CheckpointIndex { /* private fields */ }Expand description
In-memory sparse index of checkpoint offsets.
This index is rebuilt on startup by scanning for checkpoint records. It provides O(log n) lookup for the nearest checkpoint.
§Invariants
- Offsets are stored in ascending order
- Each offset corresponds to a valid checkpoint record in the log
Implementations§
Source§impl CheckpointIndex
impl CheckpointIndex
Sourcepub fn add(&mut self, offset: Offset)
pub fn add(&mut self, offset: Offset)
Adds a checkpoint offset to the index.
§Panics
Panics if the offset is not greater than the last offset (checkpoints must be added in order).
Sourcepub fn find_nearest(&self, offset: Offset) -> Option<Offset>
pub fn find_nearest(&self, offset: Offset) -> Option<Offset>
Finds the nearest checkpoint at or before the given offset.
Returns None if there are no checkpoints before the offset.
Trait Implementations§
Source§impl Clone for CheckpointIndex
impl Clone for CheckpointIndex
Source§fn clone(&self) -> CheckpointIndex
fn clone(&self) -> CheckpointIndex
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CheckpointIndex
impl Debug for CheckpointIndex
Source§impl Default for CheckpointIndex
impl Default for CheckpointIndex
Source§fn default() -> CheckpointIndex
fn default() -> CheckpointIndex
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CheckpointIndex
impl RefUnwindSafe for CheckpointIndex
impl Send for CheckpointIndex
impl Sync for CheckpointIndex
impl Unpin for CheckpointIndex
impl UnsafeUnpin for CheckpointIndex
impl UnwindSafe for CheckpointIndex
Blanket Implementations§
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
Mutably borrows from an owned value. Read more