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

Function metadata

crates/commitlog/src/segment.rs:812–854  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

810
811 #[test]
812 fn metadata() {
813 let repo = repo::Memory::unlimited();
814
815 let mut writer = repo::create_segment_writer(&repo, <_>::default(), Commit::DEFAULT_EPOCH, 0).unwrap();
816 // Commit 0..2
817 writer.commit([(0, [0; 32]), (1, [0; 32])]).unwrap();
818 // Commit 2..3
819 writer.commit([(2, [1; 32])]).unwrap();
820 // Commit 3..5
821 writer.commit([(3, [2; 32]), (4, [2; 32])]).unwrap();
822
823 writer.flush().unwrap();
824
825 let reader = repo::open_segment_reader(&repo, DEFAULT_LOG_FORMAT_VERSION, 0).unwrap();
826 let Metadata {
827 header,
828 tx_range,
829 size_in_bytes,
830 max_epoch,
831 max_commit_offset,
832 max_commit,
833 } = reader.metadata().unwrap();
834
835 assert_eq!(
836 (
837 header,
838 tx_range,
839 size_in_bytes,
840 max_epoch,
841 max_commit_offset,
842 max_commit.is_some_and(|meta| meta.tx_range == (3..5))
843 ),
844 (
845 Header::default(),
846 0..5,
847 // header + 5 txs + 3 commits
848 (Header::LEN + (5 * 32) + (3 * Commit::FRAMING_LEN)) as u64,
849 Commit::DEFAULT_EPOCH,
850 3,
851 true
852 )
853 );
854 }
855
856 #[test]
857 fn commits() {

Callers 4

build_csharpFunction · 0.85
create_segmentMethod · 0.85
prepare_testsFunction · 0.85
try_hardlinkMethod · 0.85

Calls 6

create_segment_writerFunction · 0.85
open_segment_readerFunction · 0.85
commitMethod · 0.65
unwrapMethod · 0.45
flushMethod · 0.45
metadataMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…