pub struct Wal { /* private fields */ }Expand description
Write-Ahead Log
Implementations§
Source§impl Wal
impl Wal
Sourcepub fn create(path: impl AsRef<Path>) -> Result<Self>
pub fn create(path: impl AsRef<Path>) -> Result<Self>
Create or open a WAL file (simple API for backward compatibility)
Sourcepub fn with_config(config: WalConfig) -> Result<Self>
pub fn with_config(config: WalConfig) -> Result<Self>
Create a new WAL with custom configuration
Sourcepub fn current_file_size(&self) -> u64
pub fn current_file_size(&self) -> u64
Get current WAL file size
Sourcepub fn current_file_number(&self) -> u64
pub fn current_file_number(&self) -> u64
Get current WAL file number
Sourcepub fn recover(wal_dir: impl AsRef<Path>) -> Result<(Vec<WalEntry>, u64)>
pub fn recover(wal_dir: impl AsRef<Path>) -> Result<(Vec<WalEntry>, u64)>
Recover all entries from WAL files in a directory
Reads all WAL files in sequence order and returns recovered entries. Handles corrupted and incomplete entries gracefully by skipping them.
Returns (entries, max_sequence) where max_sequence is the highest sequence number found during recovery.
Sourcepub fn current_size(&self) -> u64
pub fn current_size(&self) -> u64
Get current active WAL file size in bytes
Sourcepub fn total_wal_size(&self) -> Result<u64>
pub fn total_wal_size(&self) -> Result<u64>
Get total size of all WAL files in the WAL directory
Sourcepub fn truncate_before(&mut self, sequence: u64) -> Result<u64>
pub fn truncate_before(&mut self, sequence: u64) -> Result<u64>
Truncate WAL files whose max sequence number is <= the given sequence.
This is used after a memtable flush to remove WAL files that are no longer needed. The current active WAL file is never removed.
Returns the number of files truncated (removed).
Sourcepub fn recover_with_stats(
wal_dir: impl AsRef<Path>,
) -> Result<(Vec<WalEntry>, u64, RecoveryStats)>
pub fn recover_with_stats( wal_dir: impl AsRef<Path>, ) -> Result<(Vec<WalEntry>, u64, RecoveryStats)>
Recover all entries from WAL files with detailed statistics
Like recover(), but also returns RecoveryStats with counts of
recovered entries, corrupted entries, and total bytes recovered.
Sourcepub fn replay_to_memtable(
wal_dir: impl AsRef<Path>,
memtable: &Memtable,
) -> Result<u64>
pub fn replay_to_memtable( wal_dir: impl AsRef<Path>, memtable: &Memtable, ) -> Result<u64>
Replay WAL entries to a memtable
Applies all entries from the WAL directory to the provided memtable. This is used during crash recovery to rebuild memtable state.
Returns the maximum sequence number found during replay.
Auto Trait Implementations§
impl Freeze for Wal
impl RefUnwindSafe for Wal
impl Send for Wal
impl Sync for Wal
impl Unpin for Wal
impl UnsafeUnpin for Wal
impl UnwindSafe for Wal
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.