#![allow(unused_variables)] // TODO(you): remove this lint after implementing this mod #![allow(dead_code)] // TODO(you): remove this lint after implementing this mod use std::ops::Bound; use std::sync::Arc; use anyhow::Result; use bytes::Bytes; use crossbeam_skiplist::SkipMap; use ouroboros::self_referencing; use crate::iterators::StorageIterator; use crate::table::SsTableBuilder; /// A basic mem-table based on crossbeam-skiplist pub struct MemTable { map: SkipMap, } impl MemTable { /// Create a new mem-table. pub fn create() -> Self { unimplemented!() } /// Get a value by key. pub fn get(&self, key: &[u8]) -> Option { unimplemented!() } /// Put a key-value pair into the mem-table. pub fn put(&self, key: &[u8], value: &[u8]) { unimplemented!() } /// Get an iterator over a range of keys. pub fn scan(&self, lower: Bound<&[u8]>, upper: Bound<&[u8]>) -> MemTableIterator { unimplemented!() } /// Flush the mem-table to SSTable. pub fn flush(&self, builder: &mut SsTableBuilder) -> Result<()> { unimplemented!() } } type SkipMapRangeIter<'a> = crossbeam_skiplist::map::Range<'a, Bytes, (Bound, Bound), Bytes, Bytes>; /// An iterator over a range of `SkipMap`. #[self_referencing] pub struct MemTableIterator { map: Arc>, #[borrows(map)] #[not_covariant] iter: SkipMapRangeIter<'this>, item: (Bytes, Bytes), } impl StorageIterator for MemTableIterator { fn value(&self) -> &[u8] { unimplemented!() } fn key(&self) -> &[u8] { unimplemented!() } fn is_valid(&self) -> bool { unimplemented!() } fn next(&mut self) -> Result<()> { unimplemented!() } } #[cfg(test)] mod tests;