(root_path: &Path, version: VersionNumber)
| 115 | } |
| 116 | |
| 117 | pub fn from_existing(root_path: &Path, version: VersionNumber) -> Result<Self, BufIoError> { |
| 118 | let file_path: Arc<Path> = root_path.join(format!("{}.wal", *version)).into(); |
| 119 | |
| 120 | let mut file = OpenOptions::new().read(true).open(&file_path)?; |
| 121 | |
| 122 | let bufman = FilelessBufferManager::from_file(&mut file, 8192)?; |
| 123 | let cursor = bufman.open_cursor()?; |
| 124 | let records_upserted = bufman.read_u32_with_cursor(cursor)?; |
| 125 | let records_deleted = bufman.read_u32_with_cursor(cursor)?; |
| 126 | let total_operations = bufman.read_u32_with_cursor(cursor)?; |
| 127 | bufman.seek_with_cursor(cursor, 0)?; |
| 128 | bufman.update_u32_with_cursor(cursor, records_upserted)?; |
| 129 | bufman.update_u32_with_cursor(cursor, records_deleted)?; |
| 130 | bufman.update_u32_with_cursor(cursor, total_operations)?; |
| 131 | |
| 132 | Ok(Self { |
| 133 | bufman, |
| 134 | cursor, |
| 135 | read_lock: Mutex::new(()), |
| 136 | records_upserted: AtomicU32::new(records_upserted), |
| 137 | records_deleted: AtomicU32::new(records_deleted), |
| 138 | total_operations: AtomicU32::new(total_operations), |
| 139 | }) |
| 140 | } |
| 141 | |
| 142 | pub fn records_upserted(&self) -> u32 { |
| 143 | self.records_upserted.load(Ordering::Relaxed) |
nothing calls this directly
no test coverage detected