Skip to content

Commit

Permalink
refactor: remove double checks of memtable size (#4117)
Browse files Browse the repository at this point in the history
* refactor: remove unnecessary unwrap

* Update src/mito2/src/region/version.rs

Co-authored-by: dennis zhuang <[email protected]>

---------

Co-authored-by: Kermit <[email protected]>
Co-authored-by: dennis zhuang <[email protected]>
  • Loading branch information
3 people authored Jun 7, 2024
1 parent e142ca4 commit d8b51cf
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/mito2/src/region/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,11 @@ impl VersionControl {
/// Freezes the mutable memtable if it is not empty.
pub(crate) fn freeze_mutable(&self) -> Result<()> {
let version = self.current().version;
if version.memtables.mutable.is_empty() {

let Some(new_memtables) = version.memtables.freeze_mutable(&version.metadata)? else {
return Ok(());
}
// Safety: Immutable memtable is None.
let new_memtables = version
.memtables
.freeze_mutable(&version.metadata)?
.unwrap();
};

// Create a new version with memtable switched.
let new_version = Arc::new(
VersionBuilder::from_version(version)
Expand Down

0 comments on commit d8b51cf

Please sign in to comment.