Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
AbnerZheng committed May 29, 2024
1 parent c94924b commit d790a0a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
10 changes: 5 additions & 5 deletions mini-lsm-starter/src/compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,16 @@ impl LsmStorageInner {
CompactionTask::Leveled(LeveledCompactionTask {
upper_level,
upper_level_sst_ids,
lower_level,
lower_level: _,
lower_level_sst_ids,
is_lower_level_bottom_level,
is_lower_level_bottom_level: _,
})
| CompactionTask::Simple(SimpleLeveledCompactionTask {
upper_level,
upper_level_sst_ids,
lower_level,
lower_level: _,
lower_level_sst_ids,
is_lower_level_bottom_level,
is_lower_level_bottom_level: _,
}) => {
let lower_tables = lower_level_sst_ids
.iter()
Expand Down Expand Up @@ -314,7 +314,7 @@ impl LsmStorageInner {
fs::remove_file(self.path_of_sst(*sst_id))?;
}

return Ok(());
Ok(())
}

fn trigger_compaction(&self) -> Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion mini-lsm-starter/src/iterators/concat_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl SstConcatIterator {

pub fn create_and_seek_to_first(sstables: Vec<Arc<SsTable>>) -> Result<Self> {
Self::check_sst_valid(&sstables);
let current = match sstables.get(0) {
let current = match sstables.first() {
None => None,
Some(sst) => Some(SsTableIterator::create_and_seek_to_first(sst.clone())?),
};
Expand Down
5 changes: 3 additions & 2 deletions mini-lsm-starter/src/lsm_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ pub(crate) struct LsmStorageInner {
pub(crate) options: Arc<LsmStorageOptions>,
pub(crate) compaction_controller: CompactionController,
pub(crate) manifest: Option<Manifest>,
#[allow(dead_code)]
pub(crate) mvcc: Option<LsmMvccInner>,
pub(crate) compaction_filters: Arc<Mutex<Vec<CompactionFilter>>>,
}
Expand Down Expand Up @@ -389,7 +390,7 @@ impl LsmStorageInner {
let ss_table = SsTable::open(
sst_id,
Some(block_cache.clone()),
FileObject::open(Self::path_of_sst_static(&path, sst_id).as_path())?,
FileObject::open(Self::path_of_sst_static(path, sst_id).as_path())?,
)?;
state.sstables.insert(sst_id, Arc::new(ss_table));
}
Expand Down Expand Up @@ -488,7 +489,7 @@ impl LsmStorageInner {
}
}

for (level, idxs) in &snapshot.levels {
for (_level, idxs) in &snapshot.levels {
// println!("try fetching key from l{level}");
for idx in idxs {
// those sstable in each levels are sorted
Expand Down
6 changes: 5 additions & 1 deletion mini-lsm-starter/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ pub enum ManifestRecord {

impl Manifest {
pub fn create(path: impl AsRef<Path>) -> Result<Self> {
let file = fs::OpenOptions::new().create(true).write(true).open(path)?;
let file = fs::OpenOptions::new()
.create(true)
.truncate(false)
.write(true)
.open(path)?;
Ok(Self {
file: Arc::new(Mutex::new(file)),
})
Expand Down
6 changes: 5 additions & 1 deletion mini-lsm-starter/src/wal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ pub struct Wal {

impl Wal {
pub fn create(path: impl AsRef<Path>) -> Result<Self> {
let file = OpenOptions::new().write(true).create(true).open(path)?;
let file = OpenOptions::new()
.write(true)
.create(true)
.truncate(false)
.open(path)?;
let writer = BufWriter::new(file);
Ok(Self {
file: Arc::new(Mutex::new(writer)),
Expand Down

0 comments on commit d790a0a

Please sign in to comment.