diff --git a/mini-lsm-starter/src/compact.rs b/mini-lsm-starter/src/compact.rs index 1e70994..8d48a1b 100644 --- a/mini-lsm-starter/src/compact.rs +++ b/mini-lsm-starter/src/compact.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality + mod leveled; mod simple_leveled; mod tiered; @@ -13,11 +15,8 @@ pub use simple_leveled::{ }; pub use tiered::{TieredCompactionController, TieredCompactionOptions, TieredCompactionTask}; -use crate::iterators::merge_iterator::MergeIterator; -use crate::iterators::StorageIterator; use crate::lsm_storage::{LsmStorageInner, LsmStorageState}; -use crate::manifest::ManifestRecord; -use crate::table::{SsTable, SsTableBuilder, SsTableIterator}; +use crate::table::SsTable; #[derive(Debug, Serialize, Deserialize)] pub enum CompactionTask { @@ -105,7 +104,7 @@ pub enum CompactionOptions { } impl LsmStorageInner { - fn compact(&self, task: &CompactionTask) -> Result>> { + fn compact(&self, _task: &CompactionTask) -> Result>> { unimplemented!() } diff --git a/mini-lsm-starter/src/compact/leveled.rs b/mini-lsm-starter/src/compact/leveled.rs index ee133fb..50db7b0 100644 --- a/mini-lsm-starter/src/compact/leveled.rs +++ b/mini-lsm-starter/src/compact/leveled.rs @@ -1,5 +1,3 @@ -use std::collections::HashSet; - use serde::{Deserialize, Serialize}; use crate::lsm_storage::LsmStorageState; @@ -33,25 +31,25 @@ impl LeveledCompactionController { fn find_overlapping_ssts( &self, - snapshot: &LsmStorageState, - sst_ids: &[usize], - in_level: usize, + _snapshot: &LsmStorageState, + _sst_ids: &[usize], + _in_level: usize, ) -> Vec { unimplemented!() } pub fn generate_compaction_task( &self, - snapshot: &LsmStorageState, + _snapshot: &LsmStorageState, ) -> Option { unimplemented!() } pub fn apply_compaction_result( &self, - snapshot: &LsmStorageState, - task: &LeveledCompactionTask, - output: &[usize], + _snapshot: &LsmStorageState, + _task: &LeveledCompactionTask, + _output: &[usize], ) -> (LsmStorageState, Vec) { unimplemented!() } diff --git a/mini-lsm-starter/src/compact/simple_leveled.rs b/mini-lsm-starter/src/compact/simple_leveled.rs index 036d2ea..fb88f7f 100644 --- a/mini-lsm-starter/src/compact/simple_leveled.rs +++ b/mini-lsm-starter/src/compact/simple_leveled.rs @@ -30,16 +30,16 @@ impl SimpleLeveledCompactionController { pub fn generate_compaction_task( &self, - snapshot: &LsmStorageState, + _snapshot: &LsmStorageState, ) -> Option { unimplemented!() } pub fn apply_compaction_result( &self, - snapshot: &LsmStorageState, - task: &SimpleLeveledCompactionTask, - output: &[usize], + _snapshot: &LsmStorageState, + _task: &SimpleLeveledCompactionTask, + _output: &[usize], ) -> (LsmStorageState, Vec) { unimplemented!() } diff --git a/mini-lsm-starter/src/compact/tiered.rs b/mini-lsm-starter/src/compact/tiered.rs index 5f92324..25f300e 100644 --- a/mini-lsm-starter/src/compact/tiered.rs +++ b/mini-lsm-starter/src/compact/tiered.rs @@ -1,5 +1,3 @@ -use std::collections::HashMap; - use serde::{Deserialize, Serialize}; use crate::lsm_storage::LsmStorageState; @@ -29,16 +27,16 @@ impl TieredCompactionController { pub fn generate_compaction_task( &self, - snapshot: &LsmStorageState, + _snapshot: &LsmStorageState, ) -> Option { unimplemented!() } pub fn apply_compaction_result( &self, - snapshot: &LsmStorageState, - task: &TieredCompactionTask, - output: &[usize], + _snapshot: &LsmStorageState, + _task: &TieredCompactionTask, + _output: &[usize], ) -> (LsmStorageState, Vec) { unimplemented!() } diff --git a/mini-lsm-starter/src/lsm_storage.rs b/mini-lsm-starter/src/lsm_storage.rs index 25a44d8..9ba7530 100644 --- a/mini-lsm-starter/src/lsm_storage.rs +++ b/mini-lsm-starter/src/lsm_storage.rs @@ -1,26 +1,24 @@ -use std::collections::{BTreeSet, HashMap}; -use std::fs::File; +#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality + +use std::collections::HashMap; use std::ops::Bound; use std::path::{Path, PathBuf}; use std::sync::atomic::AtomicUsize; use std::sync::Arc; -use anyhow::{Context, Result}; +use anyhow::Result; use bytes::Bytes; use parking_lot::{Mutex, RwLock}; use crate::block::Block; use crate::compact::{ - CompactionController, CompactionOptions, LeveledCompactionController, LeveledCompactionOptions, - SimpleLeveledCompactionController, SimpleLeveledCompactionOptions, TieredCompactionController, + CompactionController, CompactionOptions, LeveledCompactionOptions, + SimpleLeveledCompactionOptions, }; -use crate::iterators::merge_iterator::MergeIterator; -use crate::iterators::two_merge_iterator::TwoMergeIterator; -use crate::iterators::StorageIterator; use crate::lsm_iterator::{FusedIterator, LsmIterator}; -use crate::manifest::{Manifest, ManifestRecord}; -use crate::mem_table::{map_bound, MemTable}; -use crate::table::{FileObject, SsTable, SsTableBuilder, SsTableIterator}; +use crate::manifest::Manifest; +use crate::mem_table::MemTable; +use crate::table::SsTable; pub type BlockCache = moka::sync::Cache<(usize, usize), Arc>; @@ -108,7 +106,7 @@ impl MiniLsm { unimplemented!() } - pub fn open(path: impl AsRef, options: LsmStorageOptions) -> Result> { + pub fn open(_path: impl AsRef, _options: LsmStorageOptions) -> Result> { unimplemented!() } @@ -136,6 +134,10 @@ impl MiniLsm { self.inner.force_freeze_memtable()?; self.inner.force_flush_next_imm_memtable() } + + pub fn force_full_compaction(&self) -> Result<()> { + self.inner.force_full_compaction() + } } impl LsmStorageInner { @@ -144,22 +146,22 @@ impl LsmStorageInner { .fetch_add(1, std::sync::atomic::Ordering::SeqCst) } - pub(crate) fn open(path: impl AsRef, options: LsmStorageOptions) -> Result { + pub(crate) fn open(_path: impl AsRef, _options: LsmStorageOptions) -> Result { unimplemented!() } /// Get a key from the storage. In day 7, this can be further optimized by using a bloom filter. - pub fn get(&self, key: &[u8]) -> Result> { + pub fn get(&self, _key: &[u8]) -> 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<()> { + pub fn put(&self, _key: &[u8], _value: &[u8]) -> Result<()> { unimplemented!() } /// Remove a key from the storage by writing an empty value. - pub fn delete(&self, key: &[u8]) -> Result<()> { + pub fn delete(&self, _key: &[u8]) -> Result<()> { unimplemented!() } @@ -196,8 +198,8 @@ impl LsmStorageInner { /// Create an iterator over a range of keys. pub fn scan( &self, - lower: Bound<&[u8]>, - upper: Bound<&[u8]>, + _lower: Bound<&[u8]>, + _upper: Bound<&[u8]>, ) -> Result> { unimplemented!() } diff --git a/mini-lsm-starter/src/manifest.rs b/mini-lsm-starter/src/manifest.rs index c638ee9..e9b0059 100644 --- a/mini-lsm-starter/src/manifest.rs +++ b/mini-lsm-starter/src/manifest.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality + use std::fs::File; use std::path::Path; use std::sync::Arc; @@ -20,11 +22,11 @@ pub enum ManifestRecord { } impl Manifest { - pub fn create(path: impl AsRef) -> Result { + pub fn create(_path: impl AsRef) -> Result { unimplemented!() } - pub fn recover(path: impl AsRef) -> Result<(Self, Vec)> { + pub fn recover(_path: impl AsRef) -> Result<(Self, Vec)> { unimplemented!() } @@ -36,7 +38,7 @@ impl Manifest { self.add_record_when_init(record) } - pub fn add_record_when_init(&self, record: ManifestRecord) -> Result<()> { + pub fn add_record_when_init(&self, _record: ManifestRecord) -> Result<()> { unimplemented!() } } diff --git a/mini-lsm-starter/src/mem_table.rs b/mini-lsm-starter/src/mem_table.rs index c677a94..ffba242 100644 --- a/mini-lsm-starter/src/mem_table.rs +++ b/mini-lsm-starter/src/mem_table.rs @@ -1,10 +1,11 @@ +#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality + use std::ops::Bound; use std::path::Path; use std::sync::Arc; use anyhow::Result; use bytes::Bytes; -use crossbeam_skiplist::map::Entry; use crossbeam_skiplist::SkipMap; use ouroboros::self_referencing; @@ -29,27 +30,27 @@ pub(crate) fn map_bound(bound: Bound<&[u8]>) -> Bound { impl MemTable { /// Create a new mem-table. - pub fn create(id: usize) -> Self { + pub fn create(_id: usize) -> Self { unimplemented!() } /// Create a new mem-table with WAL - pub fn create_with_wal(id: usize, path: impl AsRef) -> Result { + pub fn create_with_wal(_id: usize, _path: impl AsRef) -> Result { unimplemented!() } /// Create a memtable from WAL - pub fn recover_from_wal(id: usize, path: impl AsRef) -> Result { + pub fn recover_from_wal(_id: usize, _path: impl AsRef) -> Result { unimplemented!() } /// Get a value by key. - pub fn get(&self, key: &[u8]) -> Option { + 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]) -> Result<()> { + pub fn put(&self, _key: &[u8], _value: &[u8]) -> Result<()> { unimplemented!() } @@ -61,12 +62,12 @@ impl MemTable { } /// Get an iterator over a range of keys. - pub fn scan(&self, lower: Bound<&[u8]>, upper: Bound<&[u8]>) -> MemTableIterator { + 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<()> { + pub fn flush(&self, _builder: &mut SsTableBuilder) -> Result<()> { unimplemented!() } diff --git a/mini-lsm-starter/src/wal.rs b/mini-lsm-starter/src/wal.rs index 23f73e7..49e017b 100644 --- a/mini-lsm-starter/src/wal.rs +++ b/mini-lsm-starter/src/wal.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality + use std::fs::File; use std::path::Path; use std::sync::Arc; @@ -12,15 +14,15 @@ pub struct Wal { } impl Wal { - pub fn create(path: impl AsRef) -> Result { + pub fn create(_path: impl AsRef) -> Result { unimplemented!() } - pub fn recover(path: impl AsRef, skiplist: &SkipMap) -> Result { + pub fn recover(_path: impl AsRef, _skiplist: &SkipMap) -> Result { unimplemented!() } - pub fn put(&self, key: &[u8], value: &[u8]) -> Result<()> { + pub fn put(&self, _key: &[u8], _value: &[u8]) -> Result<()> { unimplemented!() } diff --git a/mini-lsm/src/lsm_storage.rs b/mini-lsm/src/lsm_storage.rs index 9355e9b..a453bba 100644 --- a/mini-lsm/src/lsm_storage.rs +++ b/mini-lsm/src/lsm_storage.rs @@ -151,6 +151,10 @@ impl MiniLsm { self.inner.force_freeze_memtable()?; self.inner.force_flush_next_imm_memtable() } + + pub fn force_full_compaction(&self) -> Result<()> { + self.inner.force_full_compaction() + } } impl LsmStorageInner { diff --git a/rustfmt.toml b/rustfmt.toml.nightly similarity index 100% rename from rustfmt.toml rename to rustfmt.toml.nightly