Coverage Report

Created: 2026-05-08 13:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/storage/row_cursor.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/row_cursor.h"
19
20
#include <glog/logging.h>
21
22
#include <algorithm>
23
#include <numeric>
24
#include <ostream>
25
26
#include "common/cast_set.h"
27
#include "common/consts.h"
28
#include "core/data_type/primitive_type.h"
29
#include "core/field.h"
30
#include "storage/field.h"
31
#include "storage/olap_common.h"
32
#include "storage/olap_define.h"
33
#include "storage/tablet/tablet_schema.h"
34
#include "storage/types.h"
35
#include "util/slice.h"
36
37
namespace doris {
38
using namespace ErrorCode;
39
40
682k
RowCursor::RowCursor() = default;
41
683k
RowCursor::~RowCursor() = default;
42
0
RowCursor::RowCursor(RowCursor&&) noexcept = default;
43
0
RowCursor& RowCursor::operator=(RowCursor&&) noexcept = default;
44
45
95
void RowCursor::_init_schema(TabletSchemaSPtr schema, uint32_t column_count) {
46
95
    std::vector<uint32_t> columns(column_count);
47
95
    std::iota(columns.begin(), columns.end(), 0);
48
95
    _schema.reset(new Schema(schema->columns(), columns));
49
95
}
50
51
653k
void RowCursor::_init_schema(const std::shared_ptr<Schema>& shared_schema, uint32_t column_count) {
52
653k
    _schema.reset(new Schema(*shared_schema));
53
653k
}
54
55
94
Status RowCursor::init(TabletSchemaSPtr schema, size_t num_columns) {
56
94
    if (num_columns > schema->num_columns()) {
57
0
        return Status::Error<INVALID_ARGUMENT>(
58
0
                "Input param are invalid. Column count is bigger than num_columns of schema. "
59
0
                "column_count={}, schema.num_columns={}",
60
0
                num_columns, schema->num_columns());
61
0
    }
62
94
    _init_schema(schema, cast_set<uint32_t>(num_columns));
63
    // Initialize all fields as null (TYPE_NULL).
64
94
    _fields.resize(num_columns);
65
94
    return Status::OK();
66
94
}
67
68
0
Status RowCursor::init(TabletSchemaSPtr schema, const OlapTuple& tuple) {
69
0
    size_t key_size = tuple.size();
70
0
    if (key_size > schema->num_columns()) {
71
0
        return Status::Error<INVALID_ARGUMENT>(
72
0
                "Input param are invalid. Column count is bigger than num_columns of schema. "
73
0
                "column_count={}, schema.num_columns={}",
74
0
                key_size, schema->num_columns());
75
0
    }
76
0
    _init_schema(schema, cast_set<uint32_t>(key_size));
77
0
    return from_tuple(tuple);
78
0
}
79
80
Status RowCursor::init(TabletSchemaSPtr schema, const OlapTuple& tuple,
81
653k
                       const std::shared_ptr<Schema>& shared_schema) {
82
653k
    size_t key_size = tuple.size();
83
653k
    if (key_size > schema->num_columns()) {
84
0
        return Status::Error<INVALID_ARGUMENT>(
85
0
                "Input param are invalid. Column count is bigger than num_columns of schema. "
86
0
                "column_count={}, schema.num_columns={}",
87
0
                key_size, schema->num_columns());
88
0
    }
89
653k
    _init_schema(shared_schema, cast_set<uint32_t>(key_size));
90
653k
    return from_tuple(tuple);
91
653k
}
92
93
1
Status RowCursor::init_scan_key(TabletSchemaSPtr schema, std::vector<Field> fields) {
94
1
    size_t key_size = fields.size();
95
1
    if (key_size > schema->num_columns()) {
96
0
        return Status::Error<INVALID_ARGUMENT>(
97
0
                "Input param are invalid. Column count is bigger than num_columns of schema. "
98
0
                "column_count={}, schema.num_columns={}",
99
0
                key_size, schema->num_columns());
100
0
    }
101
1
    _init_schema(schema, cast_set<uint32_t>(key_size));
102
1
    _fields = std::move(fields);
103
1
    return Status::OK();
104
1
}
105
106
654k
Status RowCursor::from_tuple(const OlapTuple& tuple) {
107
654k
    if (tuple.size() != _schema->num_column_ids()) {
108
0
        return Status::Error<INVALID_ARGUMENT>(
109
0
                "column count does not match. tuple_size={}, field_count={}", tuple.size(),
110
0
                _schema->num_column_ids());
111
0
    }
112
654k
    _fields.resize(tuple.size());
113
3.14M
    for (size_t i = 0; i < tuple.size(); ++i) {
114
2.48M
        _fields[i] = tuple.get_field(i);
115
2.48M
    }
116
654k
    return Status::OK();
117
654k
}
118
119
29.1k
RowCursor RowCursor::clone() const {
120
29.1k
    RowCursor result;
121
29.1k
    result._schema = std::make_unique<Schema>(*_schema);
122
29.1k
    result._fields = _fields;
123
29.1k
    return result;
124
29.1k
}
125
126
29.2k
void RowCursor::pad_char_fields() {
127
58.5k
    for (size_t i = 0; i < _fields.size(); ++i) {
128
29.3k
        const StorageField* col = _schema->column(cast_set<uint32_t>(i));
129
29.3k
        if (col->type() == FieldType::OLAP_FIELD_TYPE_CHAR && !_fields[i].is_null()) {
130
0
            String padded = _fields[i].get<TYPE_CHAR>();
131
0
            padded.resize(col->length(), '\0');
132
0
            _fields[i] = Field::create_field<TYPE_CHAR>(std::move(padded));
133
0
        }
134
29.3k
    }
135
29.2k
}
136
137
1.02M
std::string RowCursor::to_string() const {
138
1.02M
    std::string result;
139
4.99M
    for (size_t i = 0; i < _fields.size(); ++i) {
140
3.96M
        if (i > 0) {
141
2.94M
            result.append("|");
142
2.94M
        }
143
3.96M
        if (_fields[i].is_null()) {
144
4.62k
            result.append("1&NULL");
145
3.96M
        } else {
146
3.96M
            result.append("0&");
147
3.96M
            result.append(_fields[i].to_debug_string(
148
3.96M
                    _schema->column(cast_set<uint32_t>(i))->get_scale()));
149
3.96M
        }
150
3.96M
    }
151
1.02M
    return result;
152
1.02M
}
153
154
// Convert a Field value to its storage representation via PrimitiveTypeConvertor and encode.
155
// For most types this is an identity conversion; for DATE, DATETIME, DECIMALV2 it does
156
// actual conversion to the olap storage format.
157
template <PrimitiveType PT>
158
static void encode_non_string_field(const StorageField* storage_field, const Field& f,
159
360k
                                    bool full_encode, std::string* buf) {
160
360k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
360k
    if (full_encode) {
162
334k
        storage_field->full_encode_ascending(&storage_val, buf);
163
334k
    } else {
164
26.0k
        storage_field->encode_ascending(&storage_val, buf);
165
26.0k
    }
166
360k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE2EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
232
                                    bool full_encode, std::string* buf) {
160
232
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
232
    if (full_encode) {
162
0
        storage_field->full_encode_ascending(&storage_val, buf);
163
232
    } else {
164
232
        storage_field->encode_ascending(&storage_val, buf);
165
232
    }
166
232
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE3EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
2.59k
                                    bool full_encode, std::string* buf) {
160
2.59k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
2.59k
    if (full_encode) {
162
0
        storage_field->full_encode_ascending(&storage_val, buf);
163
2.59k
    } else {
164
2.59k
        storage_field->encode_ascending(&storage_val, buf);
165
2.59k
    }
166
2.59k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE4EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
5.83k
                                    bool full_encode, std::string* buf) {
160
5.83k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
5.83k
    if (full_encode) {
162
2.18k
        storage_field->full_encode_ascending(&storage_val, buf);
163
3.65k
    } else {
164
3.65k
        storage_field->encode_ascending(&storage_val, buf);
165
3.65k
    }
166
5.83k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE5EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
327k
                                    bool full_encode, std::string* buf) {
160
327k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
327k
    if (full_encode) {
162
323k
        storage_field->full_encode_ascending(&storage_val, buf);
163
323k
    } else {
164
4.15k
        storage_field->encode_ascending(&storage_val, buf);
165
4.15k
    }
166
327k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE6EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
412
                                    bool full_encode, std::string* buf) {
160
412
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
412
    if (full_encode) {
162
133
        storage_field->full_encode_ascending(&storage_val, buf);
163
279
    } else {
164
279
        storage_field->encode_ascending(&storage_val, buf);
165
279
    }
166
412
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE7EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
316
                                    bool full_encode, std::string* buf) {
160
316
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
316
    if (full_encode) {
162
0
        storage_field->full_encode_ascending(&storage_val, buf);
163
316
    } else {
164
316
        storage_field->encode_ascending(&storage_val, buf);
165
316
    }
166
316
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE8EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
8
                                    bool full_encode, std::string* buf) {
160
8
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
8
    if (full_encode) {
162
2
        storage_field->full_encode_ascending(&storage_val, buf);
163
6
    } else {
164
6
        storage_field->encode_ascending(&storage_val, buf);
165
6
    }
166
8
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE9EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
3
                                    bool full_encode, std::string* buf) {
160
3
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
3
    if (full_encode) {
162
1
        storage_field->full_encode_ascending(&storage_val, buf);
163
2
    } else {
164
2
        storage_field->encode_ascending(&storage_val, buf);
165
2
    }
166
3
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE11EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
12.8k
                                    bool full_encode, std::string* buf) {
160
12.8k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
12.8k
    if (full_encode) {
162
7.76k
        storage_field->full_encode_ascending(&storage_val, buf);
163
7.76k
    } else {
164
5.08k
        storage_field->encode_ascending(&storage_val, buf);
165
5.08k
    }
166
12.8k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE12EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
67
                                    bool full_encode, std::string* buf) {
160
67
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
67
    if (full_encode) {
162
13
        storage_field->full_encode_ascending(&storage_val, buf);
163
54
    } else {
164
54
        storage_field->encode_ascending(&storage_val, buf);
165
54
    }
166
67
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE25EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
10.2k
                                    bool full_encode, std::string* buf) {
160
10.2k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
10.2k
    if (full_encode) {
162
1.04k
        storage_field->full_encode_ascending(&storage_val, buf);
163
9.22k
    } else {
164
9.22k
        storage_field->encode_ascending(&storage_val, buf);
165
9.22k
    }
166
10.2k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE26EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
438
                                    bool full_encode, std::string* buf) {
160
438
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
438
    if (full_encode) {
162
40
        storage_field->full_encode_ascending(&storage_val, buf);
163
398
    } else {
164
398
        storage_field->encode_ascending(&storage_val, buf);
165
398
    }
166
438
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE42EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
1
                                    bool full_encode, std::string* buf) {
160
1
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
1
    if (full_encode) {
162
0
        storage_field->full_encode_ascending(&storage_val, buf);
163
1
    } else {
164
1
        storage_field->encode_ascending(&storage_val, buf);
165
1
    }
166
1
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE20EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
85
                                    bool full_encode, std::string* buf) {
160
85
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
85
    if (full_encode) {
162
5
        storage_field->full_encode_ascending(&storage_val, buf);
163
80
    } else {
164
80
        storage_field->encode_ascending(&storage_val, buf);
165
80
    }
166
85
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE28EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
4
                                    bool full_encode, std::string* buf) {
160
4
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
4
    if (full_encode) {
162
0
        storage_field->full_encode_ascending(&storage_val, buf);
163
4
    } else {
164
4
        storage_field->encode_ascending(&storage_val, buf);
165
4
    }
166
4
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE29EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
2
                                    bool full_encode, std::string* buf) {
160
2
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
2
    if (full_encode) {
162
0
        storage_field->full_encode_ascending(&storage_val, buf);
163
2
    } else {
164
2
        storage_field->encode_ascending(&storage_val, buf);
165
2
    }
166
2
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE30EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
3
                                    bool full_encode, std::string* buf) {
160
3
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
3
    if (full_encode) {
162
0
        storage_field->full_encode_ascending(&storage_val, buf);
163
3
    } else {
164
3
        storage_field->encode_ascending(&storage_val, buf);
165
3
    }
166
3
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE35EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
2
                                    bool full_encode, std::string* buf) {
160
2
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
2
    if (full_encode) {
162
0
        storage_field->full_encode_ascending(&storage_val, buf);
163
2
    } else {
164
2
        storage_field->encode_ascending(&storage_val, buf);
165
2
    }
166
2
}
Unexecuted instantiation: row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE36EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Unexecuted instantiation: row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE37EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
167
168
void RowCursor::_encode_field(const StorageField* storage_field, const Field& f, bool full_encode,
169
3.59M
                              std::string* buf) const {
170
3.59M
    FieldType ft = storage_field->type();
171
172
3.59M
    if (field_is_slice_type(ft)) {
173
        // String types: CHAR, VARCHAR, STRING — all stored as String in Field.
174
3.23M
        const String& str = f.get<TYPE_STRING>();
175
176
3.23M
        if (ft == FieldType::OLAP_FIELD_TYPE_CHAR) {
177
            // CHAR type: must pad with \0 to the declared column length
178
5
            size_t col_len = storage_field->length();
179
5
            String padded(col_len, '\0');
180
5
            memcpy(padded.data(), str.data(), std::min(str.size(), col_len));
181
182
5
            Slice slice(padded.data(), col_len);
183
5
            if (full_encode) {
184
2
                storage_field->full_encode_ascending(&slice, buf);
185
3
            } else {
186
3
                storage_field->encode_ascending(&slice, buf);
187
3
            }
188
3.23M
        } else {
189
            // VARCHAR / STRING: use actual length
190
3.23M
            Slice slice(str.data(), str.size());
191
3.23M
            if (full_encode) {
192
3.23M
                storage_field->full_encode_ascending(&slice, buf);
193
3.23M
            } else {
194
1.39k
                storage_field->encode_ascending(&slice, buf);
195
1.39k
            }
196
3.23M
        }
197
3.23M
        return;
198
3.23M
    }
199
200
    // Non-string types: convert Field value to storage format via PrimitiveTypeConvertor,
201
    // then encode. For most types this is an identity conversion.
202
360k
    switch (ft) {
203
232
    case FieldType::OLAP_FIELD_TYPE_BOOL:
204
232
        encode_non_string_field<TYPE_BOOLEAN>(storage_field, f, full_encode, buf);
205
232
        break;
206
2.59k
    case FieldType::OLAP_FIELD_TYPE_TINYINT:
207
2.59k
        encode_non_string_field<TYPE_TINYINT>(storage_field, f, full_encode, buf);
208
2.59k
        break;
209
5.83k
    case FieldType::OLAP_FIELD_TYPE_SMALLINT:
210
5.83k
        encode_non_string_field<TYPE_SMALLINT>(storage_field, f, full_encode, buf);
211
5.83k
        break;
212
327k
    case FieldType::OLAP_FIELD_TYPE_INT:
213
327k
        encode_non_string_field<TYPE_INT>(storage_field, f, full_encode, buf);
214
327k
        break;
215
412
    case FieldType::OLAP_FIELD_TYPE_BIGINT:
216
412
        encode_non_string_field<TYPE_BIGINT>(storage_field, f, full_encode, buf);
217
412
        break;
218
316
    case FieldType::OLAP_FIELD_TYPE_LARGEINT:
219
316
        encode_non_string_field<TYPE_LARGEINT>(storage_field, f, full_encode, buf);
220
316
        break;
221
8
    case FieldType::OLAP_FIELD_TYPE_FLOAT:
222
8
        encode_non_string_field<TYPE_FLOAT>(storage_field, f, full_encode, buf);
223
8
        break;
224
3
    case FieldType::OLAP_FIELD_TYPE_DOUBLE:
225
3
        encode_non_string_field<TYPE_DOUBLE>(storage_field, f, full_encode, buf);
226
3
        break;
227
12.8k
    case FieldType::OLAP_FIELD_TYPE_DATE:
228
12.8k
        encode_non_string_field<TYPE_DATE>(storage_field, f, full_encode, buf);
229
12.8k
        break;
230
67
    case FieldType::OLAP_FIELD_TYPE_DATETIME:
231
67
        encode_non_string_field<TYPE_DATETIME>(storage_field, f, full_encode, buf);
232
67
        break;
233
10.2k
    case FieldType::OLAP_FIELD_TYPE_DATEV2:
234
10.2k
        encode_non_string_field<TYPE_DATEV2>(storage_field, f, full_encode, buf);
235
10.2k
        break;
236
438
    case FieldType::OLAP_FIELD_TYPE_DATETIMEV2:
237
438
        encode_non_string_field<TYPE_DATETIMEV2>(storage_field, f, full_encode, buf);
238
438
        break;
239
1
    case FieldType::OLAP_FIELD_TYPE_TIMESTAMPTZ:
240
1
        encode_non_string_field<TYPE_TIMESTAMPTZ>(storage_field, f, full_encode, buf);
241
1
        break;
242
85
    case FieldType::OLAP_FIELD_TYPE_DECIMAL:
243
85
        encode_non_string_field<TYPE_DECIMALV2>(storage_field, f, full_encode, buf);
244
85
        break;
245
4
    case FieldType::OLAP_FIELD_TYPE_DECIMAL32:
246
4
        encode_non_string_field<TYPE_DECIMAL32>(storage_field, f, full_encode, buf);
247
4
        break;
248
2
    case FieldType::OLAP_FIELD_TYPE_DECIMAL64:
249
2
        encode_non_string_field<TYPE_DECIMAL64>(storage_field, f, full_encode, buf);
250
2
        break;
251
3
    case FieldType::OLAP_FIELD_TYPE_DECIMAL128I:
252
3
        encode_non_string_field<TYPE_DECIMAL128I>(storage_field, f, full_encode, buf);
253
3
        break;
254
2
    case FieldType::OLAP_FIELD_TYPE_DECIMAL256:
255
2
        encode_non_string_field<TYPE_DECIMAL256>(storage_field, f, full_encode, buf);
256
2
        break;
257
0
    case FieldType::OLAP_FIELD_TYPE_IPV4:
258
0
        encode_non_string_field<TYPE_IPV4>(storage_field, f, full_encode, buf);
259
0
        break;
260
0
    case FieldType::OLAP_FIELD_TYPE_IPV6:
261
0
        encode_non_string_field<TYPE_IPV6>(storage_field, f, full_encode, buf);
262
0
        break;
263
0
    default:
264
0
        LOG(FATAL) << "unsupported field type for encoding: " << int(ft);
265
0
        break;
266
360k
    }
267
360k
}
268
269
template <bool is_mow>
270
void RowCursor::encode_key_with_padding(std::string* buf, size_t num_keys,
271
852k
                                        bool padding_minimal) const {
272
4.12M
    for (uint32_t cid = 0; cid < num_keys; cid++) {
273
4.12M
        auto* storage_field = _schema->column(cid);
274
4.12M
        if (storage_field == nullptr) {
275
843k
            if (padding_minimal) {
276
392k
                buf->push_back(KeyConsts::KEY_MINIMAL_MARKER);
277
451k
            } else {
278
451k
                if (is_mow) {
279
437k
                    buf->push_back(KeyConsts::KEY_NORMAL_NEXT_MARKER);
280
437k
                } else {
281
13.2k
                    buf->push_back(KeyConsts::KEY_MAXIMAL_MARKER);
282
13.2k
                }
283
451k
            }
284
843k
            break;
285
843k
        }
286
287
3.27M
        if (cid >= _fields.size() || _fields[cid].is_null()) {
288
3.22k
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
289
3.22k
            continue;
290
3.22k
        }
291
292
3.27M
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
293
3.27M
        _encode_field(storage_field, _fields[cid], is_mow, buf);
294
3.27M
    }
295
852k
}
_ZNK5doris9RowCursor23encode_key_with_paddingILb0EEEvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb
Line
Count
Source
271
29.2k
                                        bool padding_minimal) const {
272
58.5k
    for (uint32_t cid = 0; cid < num_keys; cid++) {
273
53.0k
        auto* storage_field = _schema->column(cid);
274
53.0k
        if (storage_field == nullptr) {
275
23.6k
            if (padding_minimal) {
276
10.3k
                buf->push_back(KeyConsts::KEY_MINIMAL_MARKER);
277
13.3k
            } else {
278
13.3k
                if (is_mow) {
279
0
                    buf->push_back(KeyConsts::KEY_NORMAL_NEXT_MARKER);
280
13.3k
                } else {
281
13.3k
                    buf->push_back(KeyConsts::KEY_MAXIMAL_MARKER);
282
13.3k
                }
283
13.3k
            }
284
23.6k
            break;
285
23.6k
        }
286
287
29.3k
        if (cid >= _fields.size() || _fields[cid].is_null()) {
288
2.80k
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
289
2.80k
            continue;
290
2.80k
        }
291
292
26.5k
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
293
26.5k
        _encode_field(storage_field, _fields[cid], is_mow, buf);
294
26.5k
    }
295
29.2k
}
_ZNK5doris9RowCursor23encode_key_with_paddingILb1EEEvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb
Line
Count
Source
271
823k
                                        bool padding_minimal) const {
272
4.07M
    for (uint32_t cid = 0; cid < num_keys; cid++) {
273
4.06M
        auto* storage_field = _schema->column(cid);
274
4.06M
        if (storage_field == nullptr) {
275
819k
            if (padding_minimal) {
276
381k
                buf->push_back(KeyConsts::KEY_MINIMAL_MARKER);
277
437k
            } else {
278
437k
                if (is_mow) {
279
437k
                    buf->push_back(KeyConsts::KEY_NORMAL_NEXT_MARKER);
280
18.4E
                } else {
281
18.4E
                    buf->push_back(KeyConsts::KEY_MAXIMAL_MARKER);
282
18.4E
                }
283
437k
            }
284
819k
            break;
285
819k
        }
286
287
3.24M
        if (cid >= _fields.size() || _fields[cid].is_null()) {
288
420
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
289
420
            continue;
290
420
        }
291
292
3.24M
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
293
3.24M
        _encode_field(storage_field, _fields[cid], is_mow, buf);
294
3.24M
    }
295
823k
}
296
297
// Explicit template instantiations
298
template void RowCursor::encode_key_with_padding<false>(std::string*, size_t, bool) const;
299
template void RowCursor::encode_key_with_padding<true>(std::string*, size_t, bool) const;
300
301
template <bool full_encode>
302
129k
void RowCursor::encode_key(std::string* buf, size_t num_keys) const {
303
387k
    for (uint32_t cid = 0; cid < num_keys; cid++) {
304
258k
        if (cid >= _fields.size() || _fields[cid].is_null()) {
305
6
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
306
6
            continue;
307
6
        }
308
258k
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
309
258k
        _encode_field(_schema->column(cid), _fields[cid], full_encode, buf);
310
258k
    }
311
129k
}
_ZNK5doris9RowCursor10encode_keyILb0EEEvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm
Line
Count
Source
302
33
void RowCursor::encode_key(std::string* buf, size_t num_keys) const {
303
82
    for (uint32_t cid = 0; cid < num_keys; cid++) {
304
49
        if (cid >= _fields.size() || _fields[cid].is_null()) {
305
6
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
306
6
            continue;
307
6
        }
308
43
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
309
43
        _encode_field(_schema->column(cid), _fields[cid], full_encode, buf);
310
43
    }
311
33
}
_ZNK5doris9RowCursor10encode_keyILb1EEEvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm
Line
Count
Source
302
129k
void RowCursor::encode_key(std::string* buf, size_t num_keys) const {
303
387k
    for (uint32_t cid = 0; cid < num_keys; cid++) {
304
258k
        if (cid >= _fields.size() || _fields[cid].is_null()) {
305
0
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
306
0
            continue;
307
0
        }
308
258k
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
309
258k
        _encode_field(_schema->column(cid), _fields[cid], full_encode, buf);
310
258k
    }
311
129k
}
312
313
template void RowCursor::encode_key<false>(std::string*, size_t) const;
314
template void RowCursor::encode_key<true>(std::string*, size_t) const;
315
316
} // namespace doris