MCPcopy Create free account
hub / github.com/cosdata/cosdata / new

Method new

src/models/durable_wal.rs:21–43  ·  view source on GitHub ↗
(root_path: &Path, version: VersionNumber)

Source from the content-addressed store, hash-verified

19
20impl DurableWALFile {
21 pub fn new(root_path: &Path, version: VersionNumber) -> Result<Self, BufIoError> {
22 let file_path: Arc<Path> = root_path.join(format!("{}.wal", *version)).into();
23
24 let file = OpenOptions::new()
25 .write(true)
26 .read(true)
27 .create(true)
28 .truncate(false)
29 .open(&file_path)?;
30 let bufman = BufferManager::new(file, 8192)?;
31 let cursor = bufman.open_cursor()?;
32 bufman.update_u32_with_cursor(cursor, 0)?;
33 bufman.update_u32_with_cursor(cursor, 0)?;
34 bufman.update_u32_with_cursor(cursor, 0)?;
35
36 Ok(Self {
37 bufman,
38 cursor,
39 records_upserted: 0,
40 records_deleted: 0,
41 total_operations: 0,
42 })
43 }
44
45 pub fn records_upserted(&self) -> u32 {
46 self.records_upserted

Callers

nothing calls this directly

Calls 3

open_cursorMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected