risingwave_meta_model/
hummock_version_stats.rs1use std::collections::HashMap;
16
17use risingwave_pb::hummock::{HummockVersionStats, TableStats as PbTableStats};
18use sea_orm::FromJsonQueryResult;
19use sea_orm::entity::prelude::*;
20use serde::{Deserialize, Serialize};
21
22use crate::HummockVersionId;
23
24#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize, Default)]
25#[sea_orm(table_name = "hummock_version_stats")]
26pub struct Model {
27 #[sea_orm(primary_key, auto_increment = false)]
28 pub id: HummockVersionId,
29 pub stats: TableStats,
30}
31
32#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
33pub enum Relation {}
34
35impl ActiveModelBehavior for ActiveModel {}
36
37#[derive(Clone, Debug, PartialEq, Eq, FromJsonQueryResult, Serialize, Deserialize, Default)]
38pub struct TableStats(pub HashMap<u32, PbTableStats>);
39
40impl From<Model> for HummockVersionStats {
41 fn from(value: Model) -> Self {
42 Self {
43 hummock_version_id: value.id as _,
44 table_stats: value.stats.0,
45 }
46 }
47}