Start a new segment, preserving the current head's `Commit`. The caller must ensure that the current head is synced to disk as appropriate. It is not appropriate to sync after a write error, as that is likely to return an error as well: the `Commit` will be written to the new segment anyway.
(&mut self)
| 249 | /// is likely to return an error as well: the `Commit` will be written to |
| 250 | /// the new segment anyway. |
| 251 | fn start_new_segment(&mut self) -> io::Result<&mut Writer<R::SegmentWriter>> { |
| 252 | debug!( |
| 253 | "starting new segment offset={} prev-offset={}", |
| 254 | self.head.next_tx_offset(), |
| 255 | self.head.min_tx_offset() |
| 256 | ); |
| 257 | let new = repo::create_segment_writer(&self.repo, self.opts, self.head.epoch(), self.head.next_tx_offset())?; |
| 258 | let old = mem::replace(&mut self.head, new); |
| 259 | self.tail.push(old.min_tx_offset()); |
| 260 | self.head.commit = old.commit; |
| 261 | |
| 262 | Ok(&mut self.head) |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | impl<R: Repo, T: Encode> Generic<R, T> { |
no test coverage detected