Coverage Report

Created: 2026-05-08 18:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/storage/binlog_config.cpp
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
#include "storage/binlog_config.h"
19
20
#include <fmt/format.h>
21
#include <gen_cpp/AgentService_types.h>
22
#include <gen_cpp/olap_file.pb.h>
23
24
#include "common/logging.h"
25
26
namespace doris {
27
6.58k
BinlogConfig& BinlogConfig::operator=(const TBinlogConfig& config) {
28
6.58k
    if (config.__isset.enable) {
29
6.58k
        _enable = config.enable;
30
6.58k
    }
31
6.58k
    if (config.__isset.ttl_seconds) {
32
6.58k
        _ttl_seconds = config.ttl_seconds;
33
6.58k
    }
34
6.58k
    if (config.__isset.max_bytes) {
35
6.58k
        _max_bytes = config.max_bytes;
36
6.58k
    }
37
6.58k
    if (config.__isset.max_history_nums) {
38
6.58k
        _max_history_nums = config.max_history_nums;
39
6.58k
    }
40
6.59k
    if (config.__isset.binlog_format) {
41
6.59k
        if (config.binlog_format == TBinlogFormat::ROW) {
42
1
            _binlog_format = BinlogFormatPB::ROW;
43
6.59k
        } else if (config.binlog_format == TBinlogFormat::STATEMENT_AND_SNAPSHOT) {
44
6.59k
            _binlog_format = BinlogFormatPB::STATEMENT_AND_SNAPSHOT;
45
6.59k
        } else {
46
0
            DCHECK(false) << "can not identify the binlog format " << config.binlog_format;
47
0
        }
48
6.59k
    }
49
6.59k
    if (config.__isset.need_historical_value) {
50
6.59k
        _need_historical_value = config.need_historical_value;
51
6.59k
    }
52
6.58k
    return *this;
53
6.58k
}
54
55
301k
BinlogConfig& BinlogConfig::operator=(const BinlogConfigPB& config) {
56
301k
    if (config.has_enable()) {
57
301k
        _enable = config.enable();
58
301k
    }
59
301k
    if (config.has_ttl_seconds()) {
60
301k
        _ttl_seconds = config.ttl_seconds();
61
301k
    }
62
301k
    if (config.has_max_bytes()) {
63
301k
        _max_bytes = config.max_bytes();
64
301k
    }
65
301k
    if (config.has_max_history_nums()) {
66
301k
        _max_history_nums = config.max_history_nums();
67
301k
    }
68
301k
    if (config.has_binlog_format()) {
69
301k
        _binlog_format = config.binlog_format();
70
301k
    }
71
301k
    if (config.has_need_historical_value()) {
72
301k
        _need_historical_value = config.need_historical_value();
73
301k
    }
74
301k
    return *this;
75
301k
}
76
77
36.5k
void BinlogConfig::to_pb(BinlogConfigPB* config_pb) const {
78
36.5k
    config_pb->set_enable(_enable);
79
36.5k
    config_pb->set_ttl_seconds(_ttl_seconds);
80
36.5k
    config_pb->set_max_bytes(_max_bytes);
81
36.5k
    config_pb->set_max_history_nums(_max_history_nums);
82
36.5k
    config_pb->set_binlog_format(_binlog_format);
83
36.5k
    config_pb->set_need_historical_value(_need_historical_value);
84
36.5k
}
85
86
0
std::string BinlogConfig::to_string() const {
87
0
    return fmt::format(
88
0
            "BinlogConfig enable: {}, ttl_seconds: {}, max_bytes: {}, max_history_nums: {}, "
89
0
            "binlog_format: {}, need_historical_value: {}",
90
0
            _enable, _ttl_seconds, _max_bytes, _max_history_nums, _binlog_format,
91
0
            _need_historical_value);
92
0
}
93
94
} // namespace doris