From 451726fb7ce2f4e9a99953fc9636a2053306e92b Mon Sep 17 00:00:00 2001 From: zwang28 <84491488@qq.com> Date: Wed, 1 Nov 2023 14:45:14 +0800 Subject: [PATCH] use derive_from_json_struct --- src/meta/model_v2/src/compaction_config.rs | 3 +-- src/meta/model_v2/src/compaction_status.rs | 3 +-- src/meta/model_v2/src/compaction_task.rs | 3 +-- src/meta/model_v2/src/hummock_version_delta.rs | 6 ++---- src/meta/model_v2/src/lib.rs | 2 ++ src/meta/src/backup_restore/meta_snapshot_builder_v2.rs | 3 +-- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/meta/model_v2/src/compaction_config.rs b/src/meta/model_v2/src/compaction_config.rs index b9d89371de530..5236934411d95 100644 --- a/src/meta/model_v2/src/compaction_config.rs +++ b/src/meta/model_v2/src/compaction_config.rs @@ -32,5 +32,4 @@ pub enum Relation {} impl ActiveModelBehavior for ActiveModel {} -#[derive(Clone, Debug, PartialEq, Eq, FromJsonQueryResult, Serialize, Deserialize, Default)] -pub struct CompactionConfig(pub PbCompactionConfig); +crate::derive_from_json_struct!(CompactionConfig, PbCompactionConfig); diff --git a/src/meta/model_v2/src/compaction_status.rs b/src/meta/model_v2/src/compaction_status.rs index 5e62937fed24d..da3f47ac8713b 100644 --- a/src/meta/model_v2/src/compaction_status.rs +++ b/src/meta/model_v2/src/compaction_status.rs @@ -32,5 +32,4 @@ pub enum Relation {} impl ActiveModelBehavior for ActiveModel {} -#[derive(Clone, Debug, PartialEq, Eq, FromJsonQueryResult, Serialize, Deserialize, Default)] -pub struct LevelHandlers(pub Vec); +crate::derive_from_json_struct!(LevelHandlers, Vec); diff --git a/src/meta/model_v2/src/compaction_task.rs b/src/meta/model_v2/src/compaction_task.rs index c75ac921d8623..ede8ad8cfde33 100644 --- a/src/meta/model_v2/src/compaction_task.rs +++ b/src/meta/model_v2/src/compaction_task.rs @@ -33,8 +33,7 @@ pub enum Relation {} impl ActiveModelBehavior for ActiveModel {} -#[derive(Clone, Debug, PartialEq, Eq, FromJsonQueryResult, Serialize, Deserialize, Default)] -pub struct CompactionTask(pub PbCompactTask); +crate::derive_from_json_struct!(CompactionTask, PbCompactTask); impl From for CompactTaskAssignment { fn from(value: Model) -> Self { diff --git a/src/meta/model_v2/src/hummock_version_delta.rs b/src/meta/model_v2/src/hummock_version_delta.rs index 5771b3bb0dfb3..4ce516f175343 100644 --- a/src/meta/model_v2/src/hummock_version_delta.rs +++ b/src/meta/model_v2/src/hummock_version_delta.rs @@ -39,11 +39,9 @@ pub enum Relation {} impl ActiveModelBehavior for ActiveModel {} -#[derive(Clone, Debug, PartialEq, Eq, FromJsonQueryResult, Serialize, Deserialize, Default)] -pub struct SstableObjectIds(pub Vec); +crate::derive_from_json_struct!(SstableObjectIds, Vec); -#[derive(Clone, Debug, PartialEq, Eq, FromJsonQueryResult, Serialize, Deserialize, Default)] -pub struct GroupDeltas(pub HashMap>); +crate::derive_from_json_struct!(GroupDeltas, HashMap>); impl From for HummockVersionDelta { fn from(value: Model) -> Self { diff --git a/src/meta/model_v2/src/lib.rs b/src/meta/model_v2/src/lib.rs index 64ef18d67a4e7..ba2e114d5060d 100644 --- a/src/meta/model_v2/src/lib.rs +++ b/src/meta/model_v2/src/lib.rs @@ -126,6 +126,8 @@ macro_rules! derive_from_json_struct { }; } +pub(crate) use derive_from_json_struct; + derive_from_json_struct!(I32Array, Vec); derive_from_json_struct!(U32Array, Vec); diff --git a/src/meta/src/backup_restore/meta_snapshot_builder_v2.rs b/src/meta/src/backup_restore/meta_snapshot_builder_v2.rs index 4b0c737dab849..95a9acac1fdb6 100644 --- a/src/meta/src/backup_restore/meta_snapshot_builder_v2.rs +++ b/src/meta/src/backup_restore/meta_snapshot_builder_v2.rs @@ -12,8 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![allow(dead_code)] -#![allow(unused_variables)] +#![expect(dead_code, reason = "WIP")] use std::future::Future;