Module wal

Module wal 

Source
Expand description

Write-Ahead Logging (WAL) for crash recovery

This module provides a write-ahead log implementation that ensures durability and enables crash recovery. All writes are first logged to a sequential append-only file before being applied to the main store.

§Features

  • Append-only log for fast writes
  • Crash recovery via log replay
  • Checkpointing for log compaction
  • Concurrent readers during write operations

§Usage

use vecstore::wal::{WriteAheadLog, LogEntry, Operation};

let mut wal = WriteAheadLog::open("store.wal")?;

// Log an operation
let entry = LogEntry::Insert {
    id: "doc1".to_string(),
    vector: vec![0.1, 0.2, 0.3],
};
wal.append(entry)?;

// Recover from crash
let entries = wal.replay()?;
for entry in entries {
    // Apply entry to main store
}

// Checkpoint and truncate
wal.checkpoint()?;

Structs§

WriteAheadLog
Write-Ahead Log implementation

Enums§

LogEntry
A single entry in the write-ahead log