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

Method compress_segments

crates/commitlog/src/lib.rs:380–399  ·  view source on GitHub ↗

Compress the segments at the offsets provided, marking them as immutable. `offsets` must contain the exact segment offsets, no rounding to the nearest offset is performed. If a segment is not found on disk, an error is returned and no further segments from the list are processed. The latest, writable segment will not be compressed. If `offsets` contains its offset, an error is returned. This me

(&self, offsets: &[u64])

Source from the content-addressed store, hash-verified

378 /// small overhead to open the file and determining its format, but
379 /// otherwise does nothing.
380 pub fn compress_segments(&self, offsets: &[u64]) -> io::Result<CompressionStats> {
381 let (repo, head_offset) = {
382 let inner = self.inner.read().unwrap();
383 let repo = inner.repo.clone();
384 let head_offset = inner.head.min_tx_offset();
385
386 (repo, head_offset)
387 };
388 if offsets.contains(&head_offset) {
389 return Err(io::Error::new(
390 io::ErrorKind::InvalidInput,
391 format!("refusing to compress mutable segment {head_offset}"),
392 ));
393 }
394 let mut stats = <_>::default();
395 for offset in offsets {
396 stats += repo.compress_segment(*offset)?;
397 }
398 Ok(stats)
399 }
400
401 /// Remove all data from the log and reopen it.
402 ///

Callers 2

compressionFunction · 0.45

Calls 9

min_tx_offsetMethod · 0.80
compress_segmentMethod · 0.80
ErrFunction · 0.50
newFunction · 0.50
OkFunction · 0.50
unwrapMethod · 0.45
readMethod · 0.45
cloneMethod · 0.45
containsMethod · 0.45

Tested by 1

compressionFunction · 0.36