Coverage Report

Created: 2026-10-11 04:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
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
class RowsetMeta;
32
33
bool row_binlog_rowset_expired(const RowsetMeta& meta, int64_t cutoff);
34
35
class BinlogConfig {
36
public:
37
811k
    BinlogConfig() = default;
38
    BinlogConfig(bool enable, int64_t ttl_seconds, int64_t max_bytes, int64_t max_history_nums,
39
                 BinlogFormatPB binlog_format, bool need_historical_value)
40
            : _enable(enable),
41
              _ttl_seconds(ttl_seconds),
42
              _max_bytes(max_bytes),
43
              _max_history_nums(max_history_nums),
44
              _binlog_format(binlog_format),
45
              _need_historical_value(need_historical_value) {}
46
    BinlogConfig(const BinlogConfig&) = default;
47
    BinlogConfig& operator=(const BinlogConfig&) = default;
48
    BinlogConfig(BinlogConfig&&) = default;
49
    BinlogConfig& operator=(BinlogConfig&&) = default;
50
    ~BinlogConfig() = default;
51
52
1.17M
    bool operator==(const BinlogConfig&) const = default;
53
54
417
    bool is_enable() const { return _enable; }
55
0
    void set_enable(bool enable) { _enable = enable; }
56
57
38.6k
    int64_t ttl_seconds() const { return _ttl_seconds; }
58
0
    void set_ttl_seconds(int64_t ttl_seconds) { _ttl_seconds = ttl_seconds; }
59
60
15
    int64_t config_version() const { return _config_version; }
61
62
    int64_t max_bytes() const { return _max_bytes; }
63
0
    void set_max_bytes(int64_t max_bytes) { _max_bytes = max_bytes; }
64
65
    int64_t max_history_nums() const { return _max_history_nums; }
66
0
    void set_max_history_nums(int64_t max_history_nums) { _max_history_nums = max_history_nums; }
67
68
    int32_t binlog_format() const { return _binlog_format; }
69
0
    void set_binlog_format(BinlogFormatPB binlog_format) { _binlog_format = binlog_format; }
70
71
2.92k
    bool need_historical_value() const { return _need_historical_value; }
72
0
    void set_need_historical_value(bool need_historical_value) {
73
0
        _need_historical_value = need_historical_value;
74
0
    }
75
201k
    bool has_row_ttl() const { return _enable && is_row_binlog_format() && _ttl_seconds > 0; }
76
    int64_t row_ttl_cutoff_tso(int64_t reference_tso) const;
77
78
0
    bool is_ccr_binlog_format() const {
79
0
        return _binlog_format == BinlogFormatPB::STATEMENT_AND_SNAPSHOT;
80
0
    }
81
201k
    bool is_row_binlog_format() const { return _binlog_format == BinlogFormatPB::ROW; }
82
83
    BinlogConfig& operator=(const TBinlogConfig& config);
84
    BinlogConfig& operator=(const BinlogConfigPB& config);
85
86
    void to_pb(BinlogConfigPB* config_pb) const;
87
    std::string to_string() const;
88
89
private:
90
    int64_t _config_version {0};
91
    bool _enable {false};
92
    int64_t _ttl_seconds {std::numeric_limits<int64_t>::max()};
93
    int64_t _max_bytes {std::numeric_limits<int64_t>::max()};
94
    int64_t _max_history_nums {std::numeric_limits<int64_t>::max()};
95
    BinlogFormatPB _binlog_format = BinlogFormatPB::STATEMENT_AND_SNAPSHOT;
96
    bool _need_historical_value {false};
97
};
98
99
} // namespace doris