| 152 | } |
| 153 | |
| 154 | pub fn flush(self, root_path: &Path, version: VersionNumber) -> Result<(), BufIoError> { |
| 155 | let cursor = self.bufman.open_cursor()?; |
| 156 | self.bufman |
| 157 | .update_u32_with_cursor(cursor, self.records_upserted.load(Ordering::Acquire))?; |
| 158 | self.bufman |
| 159 | .update_u32_with_cursor(cursor, self.records_deleted.load(Ordering::Acquire))?; |
| 160 | self.bufman |
| 161 | .update_u32_with_cursor(cursor, self.total_operations.load(Ordering::Acquire))?; |
| 162 | self.bufman.close_cursor(cursor)?; |
| 163 | let file_path: Arc<Path> = root_path.join(format!("{}.wal", *version)).into(); |
| 164 | |
| 165 | let mut file = OpenOptions::new() |
| 166 | .write(true) |
| 167 | .create(true) |
| 168 | .truncate(false) |
| 169 | .open(&file_path)?; |
| 170 | self.bufman.flush(&mut file) |
| 171 | } |
| 172 | |
| 173 | pub fn append(&self, op: VectorOp) -> Result<(), BufIoError> { |
| 174 | let mut buf = Vec::new(); |