risingwave_common/
constants.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright 2024 RisingWave Labs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

pub mod hummock {

    use bitflags::bitflags;
    bitflags! {

        #[derive(Default)]
        pub struct CompactionFilterFlag: u32 {
            const NONE = 0b00000000;
            const STATE_CLEAN = 0b00000010;
            const TTL = 0b00000100;
        }
    }

    impl From<CompactionFilterFlag> for u32 {
        fn from(flag: CompactionFilterFlag) -> Self {
            flag.bits()
        }
    }
}

pub mod log_store {
    use crate::types::DataType;
    use crate::util::sort_util::OrderType;

    pub const EPOCH_COLUMN_NAME: &str = "kv_log_store_epoch";
    pub const SEQ_ID_COLUMN_NAME: &str = "kv_log_store_seq_id";
    pub const ROW_OP_COLUMN_NAME: &str = "kv_log_store_row_op";
    pub const VNODE_COLUMN_NAME: &str = "kv_log_store_vnode";

    pub const EPOCH_COLUMN_TYPE: DataType = DataType::Int64;
    pub const SEQ_ID_COLUMN_TYPE: DataType = DataType::Int32;
    pub const ROW_OP_COLUMN_TYPE: DataType = DataType::Int16;
    pub const VNODE_COLUMN_TYPE: DataType = DataType::Int16;

    pub mod v1 {
        use std::sync::LazyLock;

        use super::*;

        /// `epoch`, `seq_id`, `row_op`
        pub const KV_LOG_STORE_PREDEFINED_COLUMNS: [(&str, DataType); 3] = [
            (EPOCH_COLUMN_NAME, EPOCH_COLUMN_TYPE),
            (SEQ_ID_COLUMN_NAME, SEQ_ID_COLUMN_TYPE),
            (ROW_OP_COLUMN_NAME, ROW_OP_COLUMN_TYPE),
        ];

        pub const EPOCH_COLUMN_INDEX: usize = 0;
        pub const SEQ_ID_COLUMN_INDEX: usize = 1;
        pub const ROW_OP_COLUMN_INDEX: usize = 2;

        /// `epoch`, `seq_id`
        pub static PK_ORDERING: LazyLock<[OrderType; 2]> =
            LazyLock::new(|| [OrderType::ascending(), OrderType::ascending_nulls_last()]);
    }

    pub mod v2 {
        use std::sync::LazyLock;

        use super::*;

        /// `epoch`, `seq_id`, `vnode`, `row_op`
        pub const KV_LOG_STORE_PREDEFINED_COLUMNS: [(&str, DataType); 4] = [
            (EPOCH_COLUMN_NAME, EPOCH_COLUMN_TYPE),
            (SEQ_ID_COLUMN_NAME, SEQ_ID_COLUMN_TYPE),
            (VNODE_COLUMN_NAME, VNODE_COLUMN_TYPE),
            (ROW_OP_COLUMN_NAME, ROW_OP_COLUMN_TYPE),
        ];

        pub const EPOCH_COLUMN_INDEX: usize = 0;
        pub const SEQ_ID_COLUMN_INDEX: usize = 1;
        pub const VNODE_COLUMN_INDEX: usize = 2;
        pub const ROW_OP_COLUMN_INDEX: usize = 3;

        pub static PK_ORDERING: LazyLock<[OrderType; 3]> = LazyLock::new(|| {
            [
                OrderType::ascending(),
                OrderType::ascending_nulls_last(),
                OrderType::ascending(),
            ]
        });
    }
}