MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / open_segment_reader

Function open_segment_reader

crates/commitlog/src/repo/mod.rs:425–437  ·  view source on GitHub ↗

Open the existing segment at `offset` for reading. Unlike [`resume_segment_writer`], this does not traverse the segment. It does, however, attempt to read the segment header and checks that the log format version and checksum algorithm are compatible.

(
    repo: &R,
    max_log_format_version: u8,
    offset: u64,
)

Source from the content-addressed store, hash-verified

423/// does, however, attempt to read the segment header and checks that the log
424/// format version and checksum algorithm are compatible.
425pub fn open_segment_reader<R: Repo>(
426 repo: &R,
427 max_log_format_version: u8,
428 offset: u64,
429) -> io::Result<Reader<R::SegmentReader>> {
430 let segment = segment_label(repo, offset);
431 debug!("open segment reader for {segment}");
432 let storage = repo
433 .open_segment_reader(offset)
434 .map_err(|source| with_segment_context("opening segment for read", repo, offset, source))?;
435 Reader::new(max_log_format_version, offset, storage)
436 .map_err(|source| with_segment_context("reading segment header", repo, offset, source))
437}
438
439/// Obtain the canonical [CompressOnce] compressor for segments.
440///

Callers 8

write_read_roundtripFunction · 0.85
metadataFunction · 0.85
commitsFunction · 0.85
transactionsFunction · 0.85
reset_to_internalFunction · 0.85
nextMethod · 0.85
open_segment_readerMethod · 0.85

Calls 4

segment_labelFunction · 0.85
with_segment_contextFunction · 0.85
newFunction · 0.50
open_segment_readerMethod · 0.45

Tested by 5

write_read_roundtripFunction · 0.68
metadataFunction · 0.68
commitsFunction · 0.68
transactionsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…