MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / lazy_read_all_payloads

Function lazy_read_all_payloads

nodedb-wal/src/lazy_reader.rs:211–234  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

209
210 #[test]
211 fn lazy_read_all_payloads() {
212 let dir = tempfile::tempdir().unwrap();
213 let path = dir.path().join("test.wal");
214
215 {
216 let mut w = WalWriter::open_without_direct_io(&path).unwrap();
217 w.append(RecordType::Put as u32, 1, 0, 0, b"hello").unwrap();
218 w.append(RecordType::VectorPut as u32, 1, 0, 0, b"vector-data")
219 .unwrap();
220 w.append(RecordType::Put as u32, 2, 1, 0, b"world").unwrap();
221 w.sync().unwrap();
222 }
223
224 let mut reader = LazyWalReader::open(&path).unwrap();
225 let mut records = Vec::new();
226 while let Some(header) = reader.next_header().unwrap() {
227 let payload = reader.read_payload(&header).unwrap();
228 records.push((header, payload));
229 }
230 assert_eq!(records.len(), 3);
231 assert_eq!(records[0].1, b"hello");
232 assert_eq!(records[1].1, b"vector-data");
233 assert_eq!(records[2].1, b"world");
234 }
235
236 #[test]
237 fn lazy_skip_non_matching() {

Callers

nothing calls this directly

Calls 8

joinMethod · 0.80
next_headerMethod · 0.80
read_payloadMethod · 0.80
openFunction · 0.50
pathMethod · 0.45
appendMethod · 0.45
syncMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected