Coverage Report

Created: 2026-03-16 12:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/storage/olap_tuple.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 <string>
21
#include <vector>
22
23
namespace doris {
24
25
class OlapTuple {
26
public:
27
1.96M
    OlapTuple() {}
28
    OlapTuple(const std::vector<std::string>& values)
29
            : _values(values), _nulls(values.size(), false) {}
30
31
6.50k
    void add_null() {
32
6.50k
        _values.push_back("");
33
6.50k
        _nulls.push_back(true);
34
6.50k
    }
35
36
2.30M
    void add_value(const std::string& value, bool is_null = false) {
37
2.30M
        _values.push_back(value);
38
2.30M
        _nulls.push_back(is_null);
39
2.30M
    }
40
41
18.9M
    size_t size() const { return _values.size(); }
42
43
0
    void reserve(size_t size) {
44
0
        _values.reserve(size);
45
0
        _nulls.reserve(size);
46
0
    }
47
48
0
    void set_value(size_t i, const std::string& value, bool is_null = false) {
49
0
        _values[i] = value;
50
0
        _nulls[i] = is_null;
51
0
    }
52
53
5.39M
    bool is_null(size_t i) const { return _nulls[i]; }
54
11.6M
    const std::string& get_value(size_t i) const { return _values[i]; }
55
2.80M
    const std::vector<std::string>& values() const { return _values; }
56
57
0
    void reset() {
58
0
        _values.clear();
59
0
        _nulls.clear();
60
0
    }
61
62
0
    std::string operator[](size_t index) const { return _values[index]; }
63
64
private:
65
    friend std::ostream& operator<<(std::ostream& os, const OlapTuple& tuple);
66
67
    std::vector<std::string> _values;
68
    std::vector<bool> _nulls;
69
};
70
71
23.9k
inline std::ostream& operator<<(std::ostream& os, const OlapTuple& tuple) {
72
49.2k
    for (int i = 0; i < tuple._values.size(); ++i) {
73
25.3k
        if (i > 0) {
74
1.40k
            os << ",";
75
1.40k
        }
76
25.3k
        if (tuple._nulls[i]) {
77
1.14k
            os << "null(";
78
1.14k
        }
79
25.3k
        os << tuple._values[i];
80
25.3k
        if (tuple._nulls[i]) {
81
1.14k
            os << ")";
82
1.14k
        }
83
25.3k
    }
84
23.9k
    return os;
85
23.9k
}
86
87
} // namespace doris