From d8b51cfaba5118ce06e239e97d16e4b68d736dbf Mon Sep 17 00:00:00 2001 From: cjw Date: Sat, 8 Jun 2024 07:34:03 +0800 Subject: [PATCH] refactor: remove double checks of memtable size (#4117) * refactor: remove unnecessary unwrap * Update src/mito2/src/region/version.rs Co-authored-by: dennis zhuang --------- Co-authored-by: Kermit Co-authored-by: dennis zhuang --- src/mito2/src/region/version.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/mito2/src/region/version.rs b/src/mito2/src/region/version.rs index fa95255c1a5c..15928e1e22c2 100644 --- a/src/mito2/src/region/version.rs +++ b/src/mito2/src/region/version.rs @@ -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)