Skip to content

Commit b1458a6

Browse files
committed
fix warnings
Signed-off-by: Alex Chi <iskyzh@gmail.com>
1 parent 9fd30f6 commit b1458a6

10 files changed

Lines changed: 62 additions & 56 deletions

File tree

mini-lsm-starter/src/compact.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality
2+
13
mod leveled;
24
mod simple_leveled;
35
mod tiered;
@@ -13,11 +15,8 @@ pub use simple_leveled::{
1315
};
1416
pub use tiered::{TieredCompactionController, TieredCompactionOptions, TieredCompactionTask};
1517

16-
use crate::iterators::merge_iterator::MergeIterator;
17-
use crate::iterators::StorageIterator;
1818
use crate::lsm_storage::{LsmStorageInner, LsmStorageState};
19-
use crate::manifest::ManifestRecord;
20-
use crate::table::{SsTable, SsTableBuilder, SsTableIterator};
19+
use crate::table::SsTable;
2120

2221
#[derive(Debug, Serialize, Deserialize)]
2322
pub enum CompactionTask {
@@ -105,7 +104,7 @@ pub enum CompactionOptions {
105104
}
106105

107106
impl LsmStorageInner {
108-
fn compact(&self, task: &CompactionTask) -> Result<Vec<Arc<SsTable>>> {
107+
fn compact(&self, _task: &CompactionTask) -> Result<Vec<Arc<SsTable>>> {
109108
unimplemented!()
110109
}
111110

mini-lsm-starter/src/compact/leveled.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::collections::HashSet;
2-
31
use serde::{Deserialize, Serialize};
42

53
use crate::lsm_storage::LsmStorageState;
@@ -33,25 +31,25 @@ impl LeveledCompactionController {
3331

3432
fn find_overlapping_ssts(
3533
&self,
36-
snapshot: &LsmStorageState,
37-
sst_ids: &[usize],
38-
in_level: usize,
34+
_snapshot: &LsmStorageState,
35+
_sst_ids: &[usize],
36+
_in_level: usize,
3937
) -> Vec<usize> {
4038
unimplemented!()
4139
}
4240

4341
pub fn generate_compaction_task(
4442
&self,
45-
snapshot: &LsmStorageState,
43+
_snapshot: &LsmStorageState,
4644
) -> Option<LeveledCompactionTask> {
4745
unimplemented!()
4846
}
4947

5048
pub fn apply_compaction_result(
5149
&self,
52-
snapshot: &LsmStorageState,
53-
task: &LeveledCompactionTask,
54-
output: &[usize],
50+
_snapshot: &LsmStorageState,
51+
_task: &LeveledCompactionTask,
52+
_output: &[usize],
5553
) -> (LsmStorageState, Vec<usize>) {
5654
unimplemented!()
5755
}

mini-lsm-starter/src/compact/simple_leveled.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ impl SimpleLeveledCompactionController {
3030

3131
pub fn generate_compaction_task(
3232
&self,
33-
snapshot: &LsmStorageState,
33+
_snapshot: &LsmStorageState,
3434
) -> Option<SimpleLeveledCompactionTask> {
3535
unimplemented!()
3636
}
3737

3838
pub fn apply_compaction_result(
3939
&self,
40-
snapshot: &LsmStorageState,
41-
task: &SimpleLeveledCompactionTask,
42-
output: &[usize],
40+
_snapshot: &LsmStorageState,
41+
_task: &SimpleLeveledCompactionTask,
42+
_output: &[usize],
4343
) -> (LsmStorageState, Vec<usize>) {
4444
unimplemented!()
4545
}

mini-lsm-starter/src/compact/tiered.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::collections::HashMap;
2-
31
use serde::{Deserialize, Serialize};
42

53
use crate::lsm_storage::LsmStorageState;
@@ -29,16 +27,16 @@ impl TieredCompactionController {
2927

3028
pub fn generate_compaction_task(
3129
&self,
32-
snapshot: &LsmStorageState,
30+
_snapshot: &LsmStorageState,
3331
) -> Option<TieredCompactionTask> {
3432
unimplemented!()
3533
}
3634

3735
pub fn apply_compaction_result(
3836
&self,
39-
snapshot: &LsmStorageState,
40-
task: &TieredCompactionTask,
41-
output: &[usize],
37+
_snapshot: &LsmStorageState,
38+
_task: &TieredCompactionTask,
39+
_output: &[usize],
4240
) -> (LsmStorageState, Vec<usize>) {
4341
unimplemented!()
4442
}

mini-lsm-starter/src/lsm_storage.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
use std::collections::{BTreeSet, HashMap};
2-
use std::fs::File;
1+
#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality
2+
3+
use std::collections::HashMap;
34
use std::ops::Bound;
45
use std::path::{Path, PathBuf};
56
use std::sync::atomic::AtomicUsize;
67
use std::sync::Arc;
78

8-
use anyhow::{Context, Result};
9+
use anyhow::Result;
910
use bytes::Bytes;
1011
use parking_lot::{Mutex, RwLock};
1112

1213
use crate::block::Block;
1314
use crate::compact::{
14-
CompactionController, CompactionOptions, LeveledCompactionController, LeveledCompactionOptions,
15-
SimpleLeveledCompactionController, SimpleLeveledCompactionOptions, TieredCompactionController,
15+
CompactionController, CompactionOptions, LeveledCompactionOptions,
16+
SimpleLeveledCompactionOptions,
1617
};
17-
use crate::iterators::merge_iterator::MergeIterator;
18-
use crate::iterators::two_merge_iterator::TwoMergeIterator;
19-
use crate::iterators::StorageIterator;
2018
use crate::lsm_iterator::{FusedIterator, LsmIterator};
21-
use crate::manifest::{Manifest, ManifestRecord};
22-
use crate::mem_table::{map_bound, MemTable};
23-
use crate::table::{FileObject, SsTable, SsTableBuilder, SsTableIterator};
19+
use crate::manifest::Manifest;
20+
use crate::mem_table::MemTable;
21+
use crate::table::SsTable;
2422

2523
pub type BlockCache = moka::sync::Cache<(usize, usize), Arc<Block>>;
2624

@@ -108,7 +106,7 @@ impl MiniLsm {
108106
unimplemented!()
109107
}
110108

111-
pub fn open(path: impl AsRef<Path>, options: LsmStorageOptions) -> Result<Arc<Self>> {
109+
pub fn open(_path: impl AsRef<Path>, _options: LsmStorageOptions) -> Result<Arc<Self>> {
112110
unimplemented!()
113111
}
114112

@@ -136,6 +134,10 @@ impl MiniLsm {
136134
self.inner.force_freeze_memtable()?;
137135
self.inner.force_flush_next_imm_memtable()
138136
}
137+
138+
pub fn force_full_compaction(&self) -> Result<()> {
139+
self.inner.force_full_compaction()
140+
}
139141
}
140142

141143
impl LsmStorageInner {
@@ -144,22 +146,22 @@ impl LsmStorageInner {
144146
.fetch_add(1, std::sync::atomic::Ordering::SeqCst)
145147
}
146148

147-
pub(crate) fn open(path: impl AsRef<Path>, options: LsmStorageOptions) -> Result<Self> {
149+
pub(crate) fn open(_path: impl AsRef<Path>, _options: LsmStorageOptions) -> Result<Self> {
148150
unimplemented!()
149151
}
150152

151153
/// Get a key from the storage. In day 7, this can be further optimized by using a bloom filter.
152-
pub fn get(&self, key: &[u8]) -> Result<Option<Bytes>> {
154+
pub fn get(&self, _key: &[u8]) -> Result<Option<Bytes>> {
153155
unimplemented!()
154156
}
155157

156158
/// Put a key-value pair into the storage by writing into the current memtable.
157-
pub fn put(&self, key: &[u8], value: &[u8]) -> Result<()> {
159+
pub fn put(&self, _key: &[u8], _value: &[u8]) -> Result<()> {
158160
unimplemented!()
159161
}
160162

161163
/// Remove a key from the storage by writing an empty value.
162-
pub fn delete(&self, key: &[u8]) -> Result<()> {
164+
pub fn delete(&self, _key: &[u8]) -> Result<()> {
163165
unimplemented!()
164166
}
165167

@@ -196,8 +198,8 @@ impl LsmStorageInner {
196198
/// Create an iterator over a range of keys.
197199
pub fn scan(
198200
&self,
199-
lower: Bound<&[u8]>,
200-
upper: Bound<&[u8]>,
201+
_lower: Bound<&[u8]>,
202+
_upper: Bound<&[u8]>,
201203
) -> Result<FusedIterator<LsmIterator>> {
202204
unimplemented!()
203205
}

mini-lsm-starter/src/manifest.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality
2+
13
use std::fs::File;
24
use std::path::Path;
35
use std::sync::Arc;
@@ -20,11 +22,11 @@ pub enum ManifestRecord {
2022
}
2123

2224
impl Manifest {
23-
pub fn create(path: impl AsRef<Path>) -> Result<Self> {
25+
pub fn create(_path: impl AsRef<Path>) -> Result<Self> {
2426
unimplemented!()
2527
}
2628

27-
pub fn recover(path: impl AsRef<Path>) -> Result<(Self, Vec<ManifestRecord>)> {
29+
pub fn recover(_path: impl AsRef<Path>) -> Result<(Self, Vec<ManifestRecord>)> {
2830
unimplemented!()
2931
}
3032

@@ -36,7 +38,7 @@ impl Manifest {
3638
self.add_record_when_init(record)
3739
}
3840

39-
pub fn add_record_when_init(&self, record: ManifestRecord) -> Result<()> {
41+
pub fn add_record_when_init(&self, _record: ManifestRecord) -> Result<()> {
4042
unimplemented!()
4143
}
4244
}

mini-lsm-starter/src/mem_table.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality
2+
13
use std::ops::Bound;
24
use std::path::Path;
35
use std::sync::Arc;
46

57
use anyhow::Result;
68
use bytes::Bytes;
7-
use crossbeam_skiplist::map::Entry;
89
use crossbeam_skiplist::SkipMap;
910
use ouroboros::self_referencing;
1011

@@ -29,27 +30,27 @@ pub(crate) fn map_bound(bound: Bound<&[u8]>) -> Bound<Bytes> {
2930

3031
impl MemTable {
3132
/// Create a new mem-table.
32-
pub fn create(id: usize) -> Self {
33+
pub fn create(_id: usize) -> Self {
3334
unimplemented!()
3435
}
3536

3637
/// Create a new mem-table with WAL
37-
pub fn create_with_wal(id: usize, path: impl AsRef<Path>) -> Result<Self> {
38+
pub fn create_with_wal(_id: usize, _path: impl AsRef<Path>) -> Result<Self> {
3839
unimplemented!()
3940
}
4041

4142
/// Create a memtable from WAL
42-
pub fn recover_from_wal(id: usize, path: impl AsRef<Path>) -> Result<Self> {
43+
pub fn recover_from_wal(_id: usize, _path: impl AsRef<Path>) -> Result<Self> {
4344
unimplemented!()
4445
}
4546

4647
/// Get a value by key.
47-
pub fn get(&self, key: &[u8]) -> Option<Bytes> {
48+
pub fn get(&self, _key: &[u8]) -> Option<Bytes> {
4849
unimplemented!()
4950
}
5051

5152
/// Put a key-value pair into the mem-table.
52-
pub fn put(&self, key: &[u8], value: &[u8]) -> Result<()> {
53+
pub fn put(&self, _key: &[u8], _value: &[u8]) -> Result<()> {
5354
unimplemented!()
5455
}
5556

@@ -61,12 +62,12 @@ impl MemTable {
6162
}
6263

6364
/// Get an iterator over a range of keys.
64-
pub fn scan(&self, lower: Bound<&[u8]>, upper: Bound<&[u8]>) -> MemTableIterator {
65+
pub fn scan(&self, _lower: Bound<&[u8]>, _upper: Bound<&[u8]>) -> MemTableIterator {
6566
unimplemented!()
6667
}
6768

6869
/// Flush the mem-table to SSTable.
69-
pub fn flush(&self, builder: &mut SsTableBuilder) -> Result<()> {
70+
pub fn flush(&self, _builder: &mut SsTableBuilder) -> Result<()> {
7071
unimplemented!()
7172
}
7273

mini-lsm-starter/src/wal.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality
2+
13
use std::fs::File;
24
use std::path::Path;
35
use std::sync::Arc;
@@ -12,15 +14,15 @@ pub struct Wal {
1214
}
1315

1416
impl Wal {
15-
pub fn create(path: impl AsRef<Path>) -> Result<Self> {
17+
pub fn create(_path: impl AsRef<Path>) -> Result<Self> {
1618
unimplemented!()
1719
}
1820

19-
pub fn recover(path: impl AsRef<Path>, skiplist: &SkipMap<Bytes, Bytes>) -> Result<Self> {
21+
pub fn recover(_path: impl AsRef<Path>, _skiplist: &SkipMap<Bytes, Bytes>) -> Result<Self> {
2022
unimplemented!()
2123
}
2224

23-
pub fn put(&self, key: &[u8], value: &[u8]) -> Result<()> {
25+
pub fn put(&self, _key: &[u8], _value: &[u8]) -> Result<()> {
2426
unimplemented!()
2527
}
2628

mini-lsm/src/lsm_storage.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ impl MiniLsm {
151151
self.inner.force_freeze_memtable()?;
152152
self.inner.force_flush_next_imm_memtable()
153153
}
154+
155+
pub fn force_full_compaction(&self) -> Result<()> {
156+
self.inner.force_full_compaction()
157+
}
154158
}
155159

156160
impl LsmStorageInner {
File renamed without changes.

0 commit comments

Comments
 (0)