@@ -93,6 +93,7 @@ impl CompactionController {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum CompactionOptions {
|
||||
/// Leveled compaction with partial compaction + dynamic level support (= RocksDB's Leveled
|
||||
/// Compaction)
|
||||
|
@@ -38,6 +38,11 @@ pub struct LsmStorageState {
|
||||
pub sstables: HashMap<usize, Arc<SsTable>>,
|
||||
}
|
||||
|
||||
pub enum WriteBatchRecord<T: AsRef<[u8]>> {
|
||||
Put(T, T),
|
||||
Del(T),
|
||||
}
|
||||
|
||||
impl LsmStorageState {
|
||||
fn create(options: &LsmStorageOptions) -> Self {
|
||||
let levels = match &options.compaction_options {
|
||||
@@ -156,6 +161,10 @@ impl MiniLsm {
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn write_batch<T: AsRef<[u8]>>(&self, batch: &[WriteBatchRecord<T>]) -> Result<()> {
|
||||
self.inner.write_batch(batch)
|
||||
}
|
||||
|
||||
pub fn get(&self, key: &[u8]) -> Result<Option<Bytes>> {
|
||||
self.inner.get(key)
|
||||
}
|
||||
@@ -245,6 +254,11 @@ impl LsmStorageInner {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
/// Write a batch of data into the storage. Implement in week 2 day 7.
|
||||
pub fn write_batch<T: AsRef<[u8]>>(&self, _batch: &[WriteBatchRecord<T>]) -> Result<()> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
/// Put a key-value pair into the storage by writing into the current memtable.
|
||||
pub fn put(&self, _key: &[u8], _value: &[u8]) -> Result<()> {
|
||||
unimplemented!()
|
||||
|
Reference in New Issue
Block a user