fix warnings

Signed-off-by: Alex Chi <iskyzh@gmail.com>
This commit is contained in:
Alex Chi
2024-01-20 11:14:19 +08:00
parent 9fd30f6aa8
commit b1458a66b2
10 changed files with 62 additions and 56 deletions

View File

@@ -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<Vec<Arc<SsTable>>> {
fn compact(&self, _task: &CompactionTask) -> Result<Vec<Arc<SsTable>>> {
unimplemented!()
}

View File

@@ -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<usize> {
unimplemented!()
}
pub fn generate_compaction_task(
&self,
snapshot: &LsmStorageState,
_snapshot: &LsmStorageState,
) -> Option<LeveledCompactionTask> {
unimplemented!()
}
pub fn apply_compaction_result(
&self,
snapshot: &LsmStorageState,
task: &LeveledCompactionTask,
output: &[usize],
_snapshot: &LsmStorageState,
_task: &LeveledCompactionTask,
_output: &[usize],
) -> (LsmStorageState, Vec<usize>) {
unimplemented!()
}

View File

@@ -30,16 +30,16 @@ impl SimpleLeveledCompactionController {
pub fn generate_compaction_task(
&self,
snapshot: &LsmStorageState,
_snapshot: &LsmStorageState,
) -> Option<SimpleLeveledCompactionTask> {
unimplemented!()
}
pub fn apply_compaction_result(
&self,
snapshot: &LsmStorageState,
task: &SimpleLeveledCompactionTask,
output: &[usize],
_snapshot: &LsmStorageState,
_task: &SimpleLeveledCompactionTask,
_output: &[usize],
) -> (LsmStorageState, Vec<usize>) {
unimplemented!()
}

View File

@@ -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<TieredCompactionTask> {
unimplemented!()
}
pub fn apply_compaction_result(
&self,
snapshot: &LsmStorageState,
task: &TieredCompactionTask,
output: &[usize],
_snapshot: &LsmStorageState,
_task: &TieredCompactionTask,
_output: &[usize],
) -> (LsmStorageState, Vec<usize>) {
unimplemented!()
}

View File

@@ -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<Block>>;
@@ -108,7 +106,7 @@ impl MiniLsm {
unimplemented!()
}
pub fn open(path: impl AsRef<Path>, options: LsmStorageOptions) -> Result<Arc<Self>> {
pub fn open(_path: impl AsRef<Path>, _options: LsmStorageOptions) -> Result<Arc<Self>> {
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<Path>, options: LsmStorageOptions) -> Result<Self> {
pub(crate) fn open(_path: impl AsRef<Path>, _options: LsmStorageOptions) -> Result<Self> {
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<Option<Bytes>> {
pub fn get(&self, _key: &[u8]) -> Result<Option<Bytes>> {
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<FusedIterator<LsmIterator>> {
unimplemented!()
}

View File

@@ -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<Path>) -> Result<Self> {
pub fn create(_path: impl AsRef<Path>) -> Result<Self> {
unimplemented!()
}
pub fn recover(path: impl AsRef<Path>) -> Result<(Self, Vec<ManifestRecord>)> {
pub fn recover(_path: impl AsRef<Path>) -> Result<(Self, Vec<ManifestRecord>)> {
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!()
}
}

View File

@@ -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<Bytes> {
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<Path>) -> Result<Self> {
pub fn create_with_wal(_id: usize, _path: impl AsRef<Path>) -> Result<Self> {
unimplemented!()
}
/// Create a memtable from WAL
pub 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> {
unimplemented!()
}
/// Get a value by key.
pub fn get(&self, key: &[u8]) -> Option<Bytes> {
pub fn get(&self, _key: &[u8]) -> Option<Bytes> {
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!()
}

View File

@@ -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<Path>) -> Result<Self> {
pub fn create(_path: impl AsRef<Path>) -> Result<Self> {
unimplemented!()
}
pub fn recover(path: impl AsRef<Path>, skiplist: &SkipMap<Bytes, Bytes>) -> Result<Self> {
pub fn recover(_path: impl AsRef<Path>, _skiplist: &SkipMap<Bytes, Bytes>) -> Result<Self> {
unimplemented!()
}
pub fn put(&self, key: &[u8], value: &[u8]) -> Result<()> {
pub fn put(&self, _key: &[u8], _value: &[u8]) -> Result<()> {
unimplemented!()
}

View File

@@ -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 {