risingwave_hummock_sdk/
state_table_info.rs

1// Copyright 2024 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use risingwave_pb::hummock::PbStateTableInfo;
16use risingwave_pb::id::CompactionGroupId;
17use serde::{Deserialize, Serialize};
18
19#[derive(Serialize, Deserialize, Clone)]
20pub struct StateTableInfo {
21    #[serde(default)]
22    pub committed_epoch: u64,
23    #[serde(default)]
24    pub compaction_group_id: CompactionGroupId,
25}
26
27impl From<StateTableInfo> for PbStateTableInfo {
28    fn from(i: StateTableInfo) -> Self {
29        (&i).into()
30    }
31}
32
33impl From<&StateTableInfo> for PbStateTableInfo {
34    fn from(i: &StateTableInfo) -> Self {
35        Self {
36            committed_epoch: i.committed_epoch,
37            compaction_group_id: i.compaction_group_id,
38        }
39    }
40}
41
42impl From<PbStateTableInfo> for StateTableInfo {
43    fn from(i: PbStateTableInfo) -> Self {
44        (&i).into()
45    }
46}
47
48impl From<&PbStateTableInfo> for StateTableInfo {
49    fn from(i: &PbStateTableInfo) -> Self {
50        Self {
51            committed_epoch: i.committed_epoch,
52            compaction_group_id: i.compaction_group_id,
53        }
54    }
55}