be/src/storage/binlog_config.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <gen_cpp/AgentService_types.h> |
21 | | #include <gen_cpp/olap_file.pb.h> |
22 | | |
23 | | #include <cstdint> |
24 | | #include <limits> |
25 | | #include <string> |
26 | | |
27 | | namespace doris { |
28 | | |
29 | | class TBinlogConfig; |
30 | | class BinlogConfigPB; |
31 | | |
32 | | class BinlogConfig { |
33 | | public: |
34 | 604k | BinlogConfig() = default; |
35 | | BinlogConfig(bool enable, int64_t ttl_seconds, int64_t max_bytes, int64_t max_history_nums, |
36 | | BinlogFormatPB binlog_format, bool need_historical_value) |
37 | | : _enable(enable), |
38 | | _ttl_seconds(ttl_seconds), |
39 | | _max_bytes(max_bytes), |
40 | | _max_history_nums(max_history_nums), |
41 | | _binlog_format(binlog_format), |
42 | 0 | _need_historical_value(need_historical_value) {} |
43 | | BinlogConfig(const BinlogConfig&) = default; |
44 | | BinlogConfig& operator=(const BinlogConfig&) = default; |
45 | | BinlogConfig(BinlogConfig&&) = default; |
46 | | BinlogConfig& operator=(BinlogConfig&&) = default; |
47 | | ~BinlogConfig() = default; |
48 | | |
49 | 1.25M | bool is_enable() const { return _enable; } |
50 | 0 | void set_enable(bool enable) { _enable = enable; } |
51 | | |
52 | 0 | int64_t ttl_seconds() const { return _ttl_seconds; } |
53 | 0 | void set_ttl_seconds(int64_t ttl_seconds) { _ttl_seconds = ttl_seconds; } |
54 | | |
55 | 0 | int64_t max_bytes() const { return _max_bytes; } |
56 | 0 | void set_max_bytes(int64_t max_bytes) { _max_bytes = max_bytes; } |
57 | | |
58 | 0 | int64_t max_history_nums() const { return _max_history_nums; } |
59 | 0 | void set_max_history_nums(int64_t max_history_nums) { _max_history_nums = max_history_nums; } |
60 | | |
61 | 0 | int32_t binlog_format() const { return _binlog_format; } |
62 | 0 | void set_binlog_format(BinlogFormatPB binlog_format) { _binlog_format = binlog_format; } |
63 | | |
64 | 2 | bool need_historical_value() const { return _need_historical_value; } |
65 | 0 | void set_need_historical_value(bool need_historical_value) { |
66 | 0 | _need_historical_value = need_historical_value; |
67 | 0 | } |
68 | | |
69 | 0 | bool isCCRBinlogFormat() const { |
70 | 0 | return _binlog_format == BinlogFormatPB::STATEMENT_AND_SNAPSHOT; |
71 | 0 | } |
72 | 2.77k | bool isRowBinlogFormat() const { return _binlog_format == BinlogFormatPB::ROW; } |
73 | | |
74 | | BinlogConfig& operator=(const TBinlogConfig& config); |
75 | | BinlogConfig& operator=(const BinlogConfigPB& config); |
76 | | |
77 | | void to_pb(BinlogConfigPB* config_pb) const; |
78 | | std::string to_string() const; |
79 | | |
80 | | private: |
81 | | bool _enable {false}; |
82 | | int64_t _ttl_seconds {std::numeric_limits<int64_t>::max()}; |
83 | | int64_t _max_bytes {std::numeric_limits<int64_t>::max()}; |
84 | | int64_t _max_history_nums {std::numeric_limits<int64_t>::max()}; |
85 | | BinlogFormatPB _binlog_format = BinlogFormatPB::STATEMENT_AND_SNAPSHOT; |
86 | | bool _need_historical_value {false}; |
87 | | }; |
88 | | |
89 | | } // namespace doris |