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

Method start_new_segment

crates/commitlog/src/commitlog.rs:251–263  ·  view source on GitHub ↗

Start a new segment, preserving the current head's `Commit`. The caller must ensure that the current head is synced to disk as appropriate. It is not appropriate to sync after a write error, as that is likely to return an error as well: the `Commit` will be written to the new segment anyway.

(&mut self)

Source from the content-addressed store, hash-verified

249 /// is likely to return an error as well: the `Commit` will be written to
250 /// the new segment anyway.
251 fn start_new_segment(&mut self) -> io::Result<&mut Writer<R::SegmentWriter>> {
252 debug!(
253 "starting new segment offset={} prev-offset={}",
254 self.head.next_tx_offset(),
255 self.head.min_tx_offset()
256 );
257 let new = repo::create_segment_writer(&self.repo, self.opts, self.head.epoch(), self.head.next_tx_offset())?;
258 let old = mem::replace(&mut self.head, new);
259 self.tail.push(old.min_tx_offset());
260 self.head.commit = old.commit;
261
262 Ok(&mut self.head)
263 }
264}
265
266impl<R: Repo, T: Encode> Generic<R, T> {

Callers 1

commitMethod · 0.80

Calls 6

create_segment_writerFunction · 0.85
min_tx_offsetMethod · 0.80
OkFunction · 0.50
epochMethod · 0.45
next_tx_offsetMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected