fix: ensure WAL is atomic for each write batch (#84)
Signed-off-by: Alex Chi <iskyzh@gmail.com>
This commit is contained in:
@@ -91,6 +91,7 @@ impl MemTable {
|
||||
///
|
||||
/// In week 1, day 1, simply put the key-value pair into the skipmap.
|
||||
/// In week 2, day 6, also flush the data to WAL.
|
||||
/// In week 3, day 5, modify the function to use the batch API.
|
||||
pub fn put(&self, key: &[u8], value: &[u8]) -> Result<()> {
|
||||
let estimated_size = key.len() + value.len();
|
||||
self.map
|
||||
@@ -103,6 +104,11 @@ impl MemTable {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Implement this in week 3, day 5.
|
||||
pub fn put_batch(&self, _data: &[(KeySlice, &[u8])]) -> Result<()> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn sync_wal(&self) -> Result<()> {
|
||||
if let Some(ref wal) = self.wal {
|
||||
wal.sync()?;
|
||||
|
@@ -79,6 +79,11 @@ impl Wal {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Implement this in week 3, day 5.
|
||||
pub fn put_batch(&self, _data: &[(&[u8], &[u8])]) -> Result<()> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn sync(&self) -> Result<()> {
|
||||
let mut file = self.file.lock();
|
||||
file.flush()?;
|
||||
|
Reference in New Issue
Block a user