pub struct MemTable { /* private fields */ }Expand description
A basic mem-table based on crossbeam-skiplist.
An initial implementation of memtable is part of week 1, day 1. It will be incrementally implemented in other chapters of week 1 and week 2.
Implementations§
Source§impl MemTable
impl MemTable
Sourcepub fn create_with_wal(id: usize, path: impl AsRef<Path>) -> Result<Self>
pub fn create_with_wal(id: usize, path: impl AsRef<Path>) -> Result<Self>
Create a new mem-table with WAL
Sourcepub fn recover_from_wal(id: usize, path: impl AsRef<Path>) -> Result<Self>
pub fn recover_from_wal(id: usize, path: impl AsRef<Path>) -> Result<Self>
Create a memtable from WAL
pub fn for_testing_put_slice(&self, key: &[u8], value: &[u8]) -> Result<()>
pub fn for_testing_get_slice(&self, key: &[u8]) -> Option<Bytes>
pub fn for_testing_scan_slice( &self, lower: Bound<&[u8]>, upper: Bound<&[u8]>, ) -> MemTableIterator
Sourcepub fn put(&self, key: &[u8], value: &[u8]) -> Result<()>
pub fn put(&self, key: &[u8], value: &[u8]) -> Result<()>
Put a key-value pair into the mem-table.
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.
pub fn sync_wal(&self) -> Result<()>
Sourcepub fn scan(&self, lower: Bound<&[u8]>, upper: Bound<&[u8]>) -> MemTableIterator
pub fn scan(&self, lower: Bound<&[u8]>, upper: Bound<&[u8]>) -> MemTableIterator
Get an iterator over a range of keys.
Sourcepub fn flush(&self, builder: &mut SsTableBuilder) -> Result<()>
pub fn flush(&self, builder: &mut SsTableBuilder) -> Result<()>
Flush the mem-table to SSTable. Implement in week 1 day 6.
pub fn id(&self) -> usize
pub fn approximate_size(&self) -> usize
Auto Trait Implementations§
impl Freeze for MemTable
impl !RefUnwindSafe for MemTable
impl Send for MemTable
impl Sync for MemTable
impl Unpin for MemTable
impl !UnwindSafe for MemTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more