From a80059b47f26b37925d6b44108be3fe7c7156260 Mon Sep 17 00:00:00 2001 From: "Lei, HUANG" <6406592+v0y4g3r@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:20:29 +0800 Subject: [PATCH] fix: recover memtable options when opening physical regions (#4102) * fix: recover memtable options when opening physical regions * chore: fmt * chore: merge data region options --- src/metric-engine/src/engine/create.rs | 11 +++-------- src/metric-engine/src/engine/open.rs | 4 ++-- src/metric-engine/src/engine/options.rs | 11 ++++------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/metric-engine/src/engine/create.rs b/src/metric-engine/src/engine/create.rs index c71375299c..dad22c72f9 100644 --- a/src/metric-engine/src/engine/create.rs +++ b/src/metric-engine/src/engine/create.rs @@ -38,9 +38,7 @@ use store_api::region_request::{AffectedRows, RegionCreateRequest, RegionRequest use store_api::storage::consts::ReservedColumnId; use store_api::storage::RegionId; -use crate::engine::options::{ - set_index_options_for_data_region, set_memtable_options_for_data_region, -}; +use crate::engine::options::set_data_region_options; use crate::engine::MetricEngineInner; use crate::error::{ AddingFieldColumnSnafu, ColumnNotFoundSnafu, ColumnTypeMismatchSnafu, @@ -478,11 +476,8 @@ impl MetricEngineInner { data_region_request.column_metadatas.push(tsid_col); data_region_request.primary_key = primary_key; - // set index options - set_index_options_for_data_region(&mut data_region_request.options); - - // Set memtable options. - set_memtable_options_for_data_region(&mut data_region_request.options); + // set data region options + set_data_region_options(&mut data_region_request.options); data_region_request } diff --git a/src/metric-engine/src/engine/open.rs b/src/metric-engine/src/engine/open.rs index 952c923487..c42e037656 100644 --- a/src/metric-engine/src/engine/open.rs +++ b/src/metric-engine/src/engine/open.rs @@ -26,7 +26,7 @@ use store_api::region_request::{AffectedRows, RegionOpenRequest, RegionRequest}; use store_api::storage::RegionId; use super::MetricEngineInner; -use crate::engine::options::set_index_options_for_data_region; +use crate::engine::options::set_data_region_options; use crate::error::{OpenMitoRegionSnafu, Result}; use crate::metrics::{LOGICAL_REGION_COUNT, PHYSICAL_REGION_COUNT}; use crate::utils; @@ -80,7 +80,7 @@ impl MetricEngineInner { }; let mut data_region_options = request.options; - set_index_options_for_data_region(&mut data_region_options); + set_data_region_options(&mut data_region_options); let open_data_region_request = RegionOpenRequest { region_dir: data_region_dir, options: data_region_options, diff --git a/src/metric-engine/src/engine/options.rs b/src/metric-engine/src/engine/options.rs index 56981329db..f22f39271c 100644 --- a/src/metric-engine/src/engine/options.rs +++ b/src/metric-engine/src/engine/options.rs @@ -30,20 +30,17 @@ const IGNORE_COLUMN_IDS_FOR_DATA_REGION: [ColumnId; 1] = [ReservedColumnId::tsid /// value and appropriately increasing the size of the index, it results in an improved indexing effect. const SEG_ROW_COUNT_FOR_DATA_REGION: u32 = 256; -/// Set the index options for the data region. -pub fn set_index_options_for_data_region(options: &mut HashMap) { +/// Sets data region specific options. +pub fn set_data_region_options(options: &mut HashMap) { + // Set the index options for the data region. options.insert( "index.inverted_index.ignore_column_ids".to_string(), IGNORE_COLUMN_IDS_FOR_DATA_REGION.iter().join(","), ); - options.insert( "index.inverted_index.segment_row_count".to_string(), SEG_ROW_COUNT_FOR_DATA_REGION.to_string(), ); -} - -/// Set memtable options for the data region. -pub fn set_memtable_options_for_data_region(options: &mut HashMap) { + // Set memtable options for the data region. options.insert("memtable.type".to_string(), "partition_tree".to_string()); }