From e97033b09615e9b6831c6ffe50989af402fb230b Mon Sep 17 00:00:00 2001 From: kamille Date: Mon, 27 May 2024 16:29:59 +0800 Subject: [PATCH] update check logic of layered memtable enabling. --- src/analytic_engine/src/memtable/mod.rs | 11 +++++++++-- src/analytic_engine/src/table_options.rs | 8 +------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/analytic_engine/src/memtable/mod.rs b/src/analytic_engine/src/memtable/mod.rs index 913bf13dea..73ef942eb8 100644 --- a/src/analytic_engine/src/memtable/mod.rs +++ b/src/analytic_engine/src/memtable/mod.rs @@ -85,6 +85,13 @@ pub struct LayeredMemtableOptions { pub mutable_segment_switch_threshold: ReadableSize, } +impl LayeredMemtableOptions { + #[inline] + pub fn enable_layered_memtable(&self) -> bool { + self.enable && self.mutable_segment_switch_threshold.0 > 0 + } +} + impl Default for LayeredMemtableOptions { fn default() -> Self { Self { @@ -98,7 +105,7 @@ impl From for LayeredMemtableOptions { fn from(value: manifest::LayeredMemtableOptions) -> Self { let enable = match value.enable { Some(Enable::EnableOpt(enable)) => enable, - // For compatibility(enable field not exist in old horaedb version), + // For compatibility(enable field not exist in old horaedb version), // if this field not exist in pb, set it to true. None => true, }; @@ -114,7 +121,7 @@ impl From for manifest::LayeredMemtableOptions { fn from(value: LayeredMemtableOptions) -> Self { Self { mutable_segment_switch_threshold: value.mutable_segment_switch_threshold.0, - enable: Some(Enable::EnableOpt(value.enable)) + enable: Some(Enable::EnableOpt(value.enable)), } } } diff --git a/src/analytic_engine/src/table_options.rs b/src/analytic_engine/src/table_options.rs index c2dea66208..e8bf958ee5 100644 --- a/src/analytic_engine/src/table_options.rs +++ b/src/analytic_engine/src/table_options.rs @@ -489,13 +489,7 @@ impl TableOptions { /// If valid, None will be returned pub fn check_validity(&self) -> Option { // layered memtable is not support in overwrite mode - if self.need_dedup() - && self - .layered_memtable_opts - .mutable_segment_switch_threshold - .0 - > 0 - { + if self.need_dedup() && self.layered_memtable_opts.enable_layered_memtable() { return Some(format!( "layered memtable is enabled for table needing dedup, layered_memtable_opts:{:?}, update_mode:{:?}", self.layered_memtable_opts, self.update_mode,