MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / replay_all_segments

Function replay_all_segments

nodedb-wal/src/segmented.rs:289–301  ·  view source on GitHub ↗

Replay all records from all segments in a WAL directory, in LSN order. Segments are read in order of their first_lsn. Within each segment, records are read sequentially. This produces a globally ordered stream.

(wal_dir: &Path)

Source from the content-addressed store, hash-verified

287/// Segments are read in order of their first_lsn. Within each segment,
288/// records are read sequentially. This produces a globally ordered stream.
289pub fn replay_all_segments(wal_dir: &Path) -> Result<Vec<WalRecord>> {
290 let segments = discover_segments(wal_dir)?;
291 let mut all_records = Vec::new();
292
293 for seg in &segments {
294 let reader = crate::reader::WalReader::open(&seg.path)?;
295 for record_result in reader.records() {
296 all_records.push(record_result?);
297 }
298 }
299
300 Ok(all_records)
301}
302
303/// Paginated replay from a WAL directory: reads at most `max_records` from `from_lsn`.
304///

Callers 2

replayMethod · 0.85
replayMethod · 0.85

Calls 4

discover_segmentsFunction · 0.85
openFunction · 0.50
recordsMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected