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

Function commits

crates/commitlog/src/stream/reader.rs:41–62  ·  view source on GitHub ↗

Stream the `range` of transaction offsets from the commitlog in `repo` as raw commitlog data. The stream contains segment headers as they are encountered scanning the `range`. Only whole [`commit::StoredCommit`]s are yielded, so a `range` that doesn't fall on commit boundaries may yield extra data. Only the headers of the source commitlog are inspected (in order to be able to satisfy the `range

(repo: R, range: impl RangeBounds<u64>)

Source from the content-addressed store, hash-verified

39/// If the commitlog is empty, that is does not contain any commits, the
40/// returned stream yields nothing.
41pub fn commits<R>(repo: R, range: impl RangeBounds<u64>) -> impl Stream<Item = io::Result<Bytes>>
42where
43 R: AsyncRepo + Send + 'static,
44{
45 let mut range = RangeFromMaybeToInclusive::from_range_bounds(range);
46 let retain = move |segments: Vec<_>| retain_range(&segments, range);
47 try_stream! {
48 let segments = repo.existing_offsets().map(retain)?;
49 for segment_offset in segments {
50 if range.start < segment_offset {
51 range.start = segment_offset;
52 }
53 trace!("segment: segment={} start={}", segment_offset, range.start);
54
55 let segment = repo.open_segment_reader_async(segment_offset).await?;
56
57 for await chunk in read_segment(repo.clone(), segment, segment_offset, range) {
58 yield chunk.inspect_err(|e| warn!("error reading segment {segment_offset}: {e}"))?;
59 }
60 }
61 }
62}
63
64fn read_segment(
65 repo: impl Repo + Send + 'static,

Callers

nothing calls this directly

Calls 1

retain_rangeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…