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

Function commits

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

Source from the content-addressed store, hash-verified

855
856 #[test]
857 fn commits() {
858 let repo = repo::Memory::unlimited();
859 let commits = vec![
860 vec![(0, [1; 32]), (1, [2; 32])],
861 vec![(2, [3; 32])],
862 vec![(3, [4; 32]), (4, [5; 32])],
863 ];
864
865 let mut writer = repo::create_segment_writer(&repo, <_>::default(), Commit::DEFAULT_EPOCH, 0).unwrap();
866
867 for commit in &commits {
868 writer.commit(commit.clone()).unwrap();
869 }
870
871 writer.flush().unwrap();
872
873 let reader = repo::open_segment_reader(&repo, DEFAULT_LOG_FORMAT_VERSION, 0).unwrap();
874 let mut commits1 = Vec::with_capacity(commits.len());
875 let mut min_tx_offset = 0;
876 for txs in commits {
877 let n = txs.len();
878 commits1.push(Commit {
879 min_tx_offset,
880 n: n as u16,
881 records: itertools::concat(txs.into_iter().map(|(_, payload)| payload.to_vec())),
882 epoch: 0,
883 });
884 min_tx_offset += n as u64;
885 }
886 let commits2 = reader
887 .commits()
888 .map_ok(Into::into)
889 .collect::<Result<Vec<Commit>, _>>()
890 .unwrap();
891 assert_eq!(commits1, commits2);
892 }
893
894 #[test]
895 fn transactions() {

Callers

nothing calls this directly

Calls 12

create_segment_writerFunction · 0.85
open_segment_readerFunction · 0.85
to_vecMethod · 0.80
commitMethod · 0.65
unwrapMethod · 0.45
cloneMethod · 0.45
flushMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45
mapMethod · 0.45
into_iterMethod · 0.45
commitsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…