Skip to content

Commit

Permalink
fix: recover memtable options when opening physical regions (#4102)
Browse files Browse the repository at this point in the history
* fix: recover memtable options when opening physical regions

* chore: fmt

* chore: merge data region options
  • Loading branch information
v0y4g3r authored Jun 4, 2024
1 parent b3a4362 commit a80059b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
11 changes: 3 additions & 8 deletions src/metric-engine/src/engine/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions src/metric-engine/src/engine/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 4 additions & 7 deletions src/metric-engine/src/engine/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String>) {
/// Sets data region specific options.
pub fn set_data_region_options(options: &mut HashMap<String, String>) {
// 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<String, String>) {
// Set memtable options for the data region.
options.insert("memtable.type".to_string(), "partition_tree".to_string());
}

0 comments on commit a80059b

Please sign in to comment.