Skip to content

Commit

Permalink
update check logic of layered memtable enabling.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachelint committed May 27, 2024
1 parent 9cadf32 commit e97033b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 9 additions & 2 deletions src/analytic_engine/src/memtable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -98,7 +105,7 @@ impl From<manifest::LayeredMemtableOptions> 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,
};
Expand All @@ -114,7 +121,7 @@ impl From<LayeredMemtableOptions> 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)),
}
}
}
Expand Down
8 changes: 1 addition & 7 deletions src/analytic_engine/src/table_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,7 @@ impl TableOptions {
/// If valid, None will be returned
pub fn check_validity(&self) -> Option<String> {
// 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,
Expand Down

0 comments on commit e97033b

Please sign in to comment.