Skip to content

Commit

Permalink
refactor: make RegionOptions and MergeOutput serializable (#4180)
Browse files Browse the repository at this point in the history
* chore: make RegionOptions serializable and add region_dir in CompactionRegion

* refactor: make `PickerOutput` and `MergeOutput` serializable and deserializable

* refactor: remove Serialize and Deserialize from PickerOutput

* chore: revert changes for file.rs

* chore: revert changes for compactor.rs and compaction.rs

---------

Co-authored-by: tison <[email protected]>
  • Loading branch information
zyy17 and tisonkun authored Jun 24, 2024
1 parent 5566dd7 commit 0139a70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/mito2/src/compaction/compactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::time::Duration;
use api::v1::region::compact_request;
use common_telemetry::info;
use object_store::manager::ObjectStoreManager;
use serde::{Deserialize, Serialize};
use smallvec::SmallVec;
use snafu::{OptionExt, ResultExt};
use store_api::metadata::RegionMetadataRef;
Expand Down Expand Up @@ -174,7 +175,7 @@ pub async fn open_compaction_region(
}

/// `[MergeOutput]` represents the output of merging SST files.
#[derive(Default, Clone, Debug)]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct MergeOutput {
pub files_to_add: Vec<FileMeta>,
pub files_to_remove: Vec<FileMeta>,
Expand Down
16 changes: 8 additions & 8 deletions src/mito2/src/region/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::time::Duration;
use common_base::readable_size::ReadableSize;
use common_wal::options::{WalOptions, WAL_OPTIONS_KEY};
use serde::de::Error as _;
use serde::{Deserialize, Deserializer};
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::Value;
use serde_with::{serde_as, with_prefix, DisplayFromStr};
use snafu::{ensure, ResultExt};
Expand All @@ -36,7 +36,7 @@ const DEFAULT_INDEX_SEGMENT_ROW_COUNT: usize = 1024;
/// Options that affect the entire region.
///
/// Users need to specify the options while creating/opening a region.
#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize)]
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default)]
pub struct RegionOptions {
/// Region SST files TTL.
Expand Down Expand Up @@ -102,7 +102,7 @@ impl TryFrom<&HashMap<String, String>> for RegionOptions {
}

/// Options for compactions
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "compaction.type")]
#[serde(rename_all = "snake_case")]
pub enum CompactionOptions {
Expand All @@ -127,7 +127,7 @@ impl Default for CompactionOptions {

/// Time window compaction options.
#[serde_as]
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default)]
pub struct TwcsOptions {
/// Max num of files that can be kept in active writing time window.
Expand Down Expand Up @@ -195,7 +195,7 @@ impl Default for RegionOptionsWithoutEnum {
with_prefix!(prefix_inverted_index "index.inverted_index.");

/// Options for index.
#[derive(Debug, Clone, PartialEq, Eq, Default, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct IndexOptions {
/// Options for the inverted index.
Expand All @@ -205,7 +205,7 @@ pub struct IndexOptions {

/// Options for the inverted index.
#[serde_as]
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default)]
pub struct InvertedIndexOptions {
/// The column ids that should be ignored when building the inverted index.
Expand All @@ -228,7 +228,7 @@ impl Default for InvertedIndexOptions {
}

/// Options for region level memtable.
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "memtable.type", rename_all = "snake_case")]
pub enum MemtableOptions {
TimeSeries,
Expand All @@ -240,7 +240,7 @@ with_prefix!(prefix_partition_tree "memtable.partition_tree.");

/// Partition tree memtable options.
#[serde_as]
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default)]
pub struct PartitionTreeOptions {
/// Max keys in an index shard.
Expand Down

0 comments on commit 0139a70

Please sign in to comment.