Coverage Report

Created: 2026-04-15 15:52

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
4.25M
RowCursor::RowCursor() = default;
41
4.25M
RowCursor::~RowCursor() = default;
42
0
RowCursor::RowCursor(RowCursor&&) noexcept = default;
43
0
RowCursor& RowCursor::operator=(RowCursor&&) noexcept = default;
44
45
358
void RowCursor::_init_schema(TabletSchemaSPtr schema, uint32_t column_count) {
46
358
    std::vector<uint32_t> columns(column_count);
47
358
    std::iota(columns.begin(), columns.end(), 0);
48
358
    _schema.reset(new Schema(schema->columns(), columns));
49
358
}
50
51
3.54M
void RowCursor::_init_schema(const std::shared_ptr<Schema>& shared_schema, uint32_t column_count) {
52
3.54M
    _schema.reset(new Schema(*shared_schema));
53
3.54M
}
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
3.55M
                       const std::shared_ptr<Schema>& shared_schema) {
82
3.55M
    size_t key_size = tuple.size();
83
3.55M
    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
3.55M
    _init_schema(shared_schema, cast_set<uint32_t>(key_size));
90
3.55M
    return from_tuple(tuple);
91
3.55M
}
92
93
264
Status RowCursor::init_scan_key(TabletSchemaSPtr schema, std::vector<Field> fields) {
94
264
    size_t key_size = fields.size();
95
264
    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
264
    _init_schema(schema, cast_set<uint32_t>(key_size));
102
264
    _fields = std::move(fields);
103
264
    return Status::OK();
104
264
}
105
106
3.55M
Status RowCursor::from_tuple(const OlapTuple& tuple) {
107
3.55M
    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
3.55M
    _fields.resize(tuple.size());
113
11.3M
    for (size_t i = 0; i < tuple.size(); ++i) {
114
7.82M
        _fields[i] = tuple.get_field(i);
115
7.82M
    }
116
3.55M
    return Status::OK();
117
3.55M
}
118
119
695k
RowCursor RowCursor::clone() const {
120
695k
    RowCursor result;
121
695k
    result._schema = std::make_unique<Schema>(*_schema);
122
695k
    result._fields = _fields;
123
695k
    return result;
124
695k
}
125
126
696k
void RowCursor::pad_char_fields() {
127
1.40M
    for (size_t i = 0; i < _fields.size(); ++i) {
128
712k
        const StorageField* col = _schema->column(cast_set<uint32_t>(i));
129
712k
        if (col->type() == FieldType::OLAP_FIELD_TYPE_CHAR && !_fields[i].is_null()) {
130
684
            String padded = _fields[i].get<TYPE_CHAR>();
131
684
            padded.resize(col->length(), '\0');
132
684
            _fields[i] = Field::create_field<TYPE_CHAR>(std::move(padded));
133
684
        }
134
712k
    }
135
696k
}
136
137
9.01M
std::string RowCursor::to_string() const {
138
9.01M
    std::string result;
139
32.3M
    for (size_t i = 0; i < _fields.size(); ++i) {
140
23.3M
        if (i > 0) {
141
14.3M
            result.append("|");
142
14.3M
        }
143
23.3M
        if (_fields[i].is_null()) {
144
351k
            result.append("1&NULL");
145
22.9M
        } else {
146
22.9M
            result.append("0&");
147
22.9M
            result.append(_fields[i].to_debug_string(
148
22.9M
                    _schema->column(cast_set<uint32_t>(i))->get_scale()));
149
22.9M
        }
150
23.3M
    }
151
9.01M
    return result;
152
9.01M
}
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
1.14M
                                    bool full_encode, std::string* buf) {
160
1.14M
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
1.14M
    if (full_encode) {
162
534k
        storage_field->full_encode_ascending(&storage_val, buf);
163
613k
    } else {
164
613k
        storage_field->encode_ascending(&storage_val, buf);
165
613k
    }
166
1.14M
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE2EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
2.46k
                                    bool full_encode, std::string* buf) {
160
2.46k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
2.46k
    if (full_encode) {
162
232
        storage_field->full_encode_ascending(&storage_val, buf);
163
2.23k
    } else {
164
2.23k
        storage_field->encode_ascending(&storage_val, buf);
165
2.23k
    }
166
2.46k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE3EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
153k
                                    bool full_encode, std::string* buf) {
160
153k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
153k
    if (full_encode) {
162
6.52k
        storage_field->full_encode_ascending(&storage_val, buf);
163
146k
    } else {
164
146k
        storage_field->encode_ascending(&storage_val, buf);
165
146k
    }
166
153k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE4EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
9.99k
                                    bool full_encode, std::string* buf) {
160
9.99k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
9.99k
    if (full_encode) {
162
2.27k
        storage_field->full_encode_ascending(&storage_val, buf);
163
7.72k
    } else {
164
7.72k
        storage_field->encode_ascending(&storage_val, buf);
165
7.72k
    }
166
9.99k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE5EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
645k
                                    bool full_encode, std::string* buf) {
160
645k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
645k
    if (full_encode) {
162
477k
        storage_field->full_encode_ascending(&storage_val, buf);
163
477k
    } else {
164
168k
        storage_field->encode_ascending(&storage_val, buf);
165
168k
    }
166
645k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE6EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
33.9k
                                    bool full_encode, std::string* buf) {
160
33.9k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
33.9k
    if (full_encode) {
162
5.17k
        storage_field->full_encode_ascending(&storage_val, buf);
163
28.7k
    } else {
164
28.7k
        storage_field->encode_ascending(&storage_val, buf);
165
28.7k
    }
166
33.9k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE7EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
13.2k
                                    bool full_encode, std::string* buf) {
160
13.2k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
13.2k
    if (full_encode) {
162
1.38k
        storage_field->full_encode_ascending(&storage_val, buf);
163
11.8k
    } else {
164
11.8k
        storage_field->encode_ascending(&storage_val, buf);
165
11.8k
    }
166
13.2k
}
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
5.50k
        storage_field->full_encode_ascending(&storage_val, buf);
163
7.36k
    } else {
164
7.36k
        storage_field->encode_ascending(&storage_val, buf);
165
7.36k
    }
166
12.8k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE12EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
159
                                    bool full_encode, std::string* buf) {
160
159
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
159
    if (full_encode) {
162
13
        storage_field->full_encode_ascending(&storage_val, buf);
163
146
    } else {
164
146
        storage_field->encode_ascending(&storage_val, buf);
165
146
    }
166
159
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE25EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
259k
                                    bool full_encode, std::string* buf) {
160
259k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
259k
    if (full_encode) {
162
30.1k
        storage_field->full_encode_ascending(&storage_val, buf);
163
229k
    } else {
164
229k
        storage_field->encode_ascending(&storage_val, buf);
165
229k
    }
166
259k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE26EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
7.17k
                                    bool full_encode, std::string* buf) {
160
7.17k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
7.17k
    if (full_encode) {
162
2.27k
        storage_field->full_encode_ascending(&storage_val, buf);
163
4.89k
    } else {
164
4.89k
        storage_field->encode_ascending(&storage_val, buf);
165
4.89k
    }
166
7.17k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE42EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
8.00k
                                    bool full_encode, std::string* buf) {
160
8.00k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
8.00k
    if (full_encode) {
162
3.12k
        storage_field->full_encode_ascending(&storage_val, buf);
163
4.87k
    } else {
164
4.87k
        storage_field->encode_ascending(&storage_val, buf);
165
4.87k
    }
166
8.00k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE20EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
122
                                    bool full_encode, std::string* buf) {
160
122
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
122
    if (full_encode) {
162
15
        storage_field->full_encode_ascending(&storage_val, buf);
163
107
    } else {
164
107
        storage_field->encode_ascending(&storage_val, buf);
165
107
    }
166
122
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE28EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
429
                                    bool full_encode, std::string* buf) {
160
429
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
429
    if (full_encode) {
162
70
        storage_field->full_encode_ascending(&storage_val, buf);
163
359
    } else {
164
359
        storage_field->encode_ascending(&storage_val, buf);
165
359
    }
166
429
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE29EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
349
                                    bool full_encode, std::string* buf) {
160
349
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
349
    if (full_encode) {
162
54
        storage_field->full_encode_ascending(&storage_val, buf);
163
295
    } else {
164
295
        storage_field->encode_ascending(&storage_val, buf);
165
295
    }
166
349
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE30EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
828
                                    bool full_encode, std::string* buf) {
160
828
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
828
    if (full_encode) {
162
99
        storage_field->full_encode_ascending(&storage_val, buf);
163
729
    } else {
164
729
        storage_field->encode_ascending(&storage_val, buf);
165
729
    }
166
828
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE35EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
756
                                    bool full_encode, std::string* buf) {
160
756
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
756
    if (full_encode) {
162
0
        storage_field->full_encode_ascending(&storage_val, buf);
163
756
    } else {
164
756
        storage_field->encode_ascending(&storage_val, buf);
165
756
    }
166
756
}
Unexecuted instantiation: row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE36EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE37EEEvPKNS_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
}
167
168
void RowCursor::_encode_field(const StorageField* storage_field, const Field& f, bool full_encode,
169
12.3M
                              std::string* buf) const {
170
12.3M
    FieldType ft = storage_field->type();
171
172
12.3M
    if (field_is_slice_type(ft)) {
173
        // String types: CHAR, VARCHAR, STRING — all stored as String in Field.
174
11.2M
        const String& str = f.get<TYPE_STRING>();
175
176
11.2M
        if (ft == FieldType::OLAP_FIELD_TYPE_CHAR) {
177
            // CHAR type: must pad with \0 to the declared column length
178
719
            size_t col_len = storage_field->length();
179
719
            String padded(col_len, '\0');
180
719
            memcpy(padded.data(), str.data(), std::min(str.size(), col_len));
181
182
719
            Slice slice(padded.data(), col_len);
183
719
            if (full_encode) {
184
32
                storage_field->full_encode_ascending(&slice, buf);
185
687
            } else {
186
687
                storage_field->encode_ascending(&slice, buf);
187
687
            }
188
11.2M
        } else {
189
            // VARCHAR / STRING: use actual length
190
11.2M
            Slice slice(str.data(), str.size());
191
11.2M
            if (full_encode) {
192
11.2M
                storage_field->full_encode_ascending(&slice, buf);
193
11.2M
            } else {
194
14.8k
                storage_field->encode_ascending(&slice, buf);
195
14.8k
            }
196
11.2M
        }
197
11.2M
        return;
198
11.2M
    }
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
1.14M
    switch (ft) {
203
2.46k
    case FieldType::OLAP_FIELD_TYPE_BOOL:
204
2.46k
        encode_non_string_field<TYPE_BOOLEAN>(storage_field, f, full_encode, buf);
205
2.46k
        break;
206
153k
    case FieldType::OLAP_FIELD_TYPE_TINYINT:
207
153k
        encode_non_string_field<TYPE_TINYINT>(storage_field, f, full_encode, buf);
208
153k
        break;
209
9.99k
    case FieldType::OLAP_FIELD_TYPE_SMALLINT:
210
9.99k
        encode_non_string_field<TYPE_SMALLINT>(storage_field, f, full_encode, buf);
211
9.99k
        break;
212
645k
    case FieldType::OLAP_FIELD_TYPE_INT:
213
645k
        encode_non_string_field<TYPE_INT>(storage_field, f, full_encode, buf);
214
645k
        break;
215
33.9k
    case FieldType::OLAP_FIELD_TYPE_BIGINT:
216
33.9k
        encode_non_string_field<TYPE_BIGINT>(storage_field, f, full_encode, buf);
217
33.9k
        break;
218
13.2k
    case FieldType::OLAP_FIELD_TYPE_LARGEINT:
219
13.2k
        encode_non_string_field<TYPE_LARGEINT>(storage_field, f, full_encode, buf);
220
13.2k
        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
159
    case FieldType::OLAP_FIELD_TYPE_DATETIME:
231
159
        encode_non_string_field<TYPE_DATETIME>(storage_field, f, full_encode, buf);
232
159
        break;
233
259k
    case FieldType::OLAP_FIELD_TYPE_DATEV2:
234
259k
        encode_non_string_field<TYPE_DATEV2>(storage_field, f, full_encode, buf);
235
259k
        break;
236
7.17k
    case FieldType::OLAP_FIELD_TYPE_DATETIMEV2:
237
7.17k
        encode_non_string_field<TYPE_DATETIMEV2>(storage_field, f, full_encode, buf);
238
7.17k
        break;
239
8.00k
    case FieldType::OLAP_FIELD_TYPE_TIMESTAMPTZ:
240
8.00k
        encode_non_string_field<TYPE_TIMESTAMPTZ>(storage_field, f, full_encode, buf);
241
8.00k
        break;
242
122
    case FieldType::OLAP_FIELD_TYPE_DECIMAL:
243
122
        encode_non_string_field<TYPE_DECIMALV2>(storage_field, f, full_encode, buf);
244
122
        break;
245
429
    case FieldType::OLAP_FIELD_TYPE_DECIMAL32:
246
429
        encode_non_string_field<TYPE_DECIMAL32>(storage_field, f, full_encode, buf);
247
429
        break;
248
349
    case FieldType::OLAP_FIELD_TYPE_DECIMAL64:
249
349
        encode_non_string_field<TYPE_DECIMAL64>(storage_field, f, full_encode, buf);
250
349
        break;
251
828
    case FieldType::OLAP_FIELD_TYPE_DECIMAL128I:
252
828
        encode_non_string_field<TYPE_DECIMAL128I>(storage_field, f, full_encode, buf);
253
828
        break;
254
756
    case FieldType::OLAP_FIELD_TYPE_DECIMAL256:
255
756
        encode_non_string_field<TYPE_DECIMAL256>(storage_field, f, full_encode, buf);
256
756
        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
2
    case FieldType::OLAP_FIELD_TYPE_IPV6:
261
2
        encode_non_string_field<TYPE_IPV6>(storage_field, f, full_encode, buf);
262
2
        break;
263
0
    default:
264
0
        LOG(FATAL) << "unsupported field type for encoding: " << int(ft);
265
0
        break;
266
1.14M
    }
267
1.14M
}
268
269
template <bool is_mow>
270
void RowCursor::encode_key_with_padding(std::string* buf, size_t num_keys,
271
3.73M
                                        bool padding_minimal) const {
272
15.8M
    for (uint32_t cid = 0; cid < num_keys; cid++) {
273
15.6M
        auto* storage_field = _schema->column(cid);
274
15.6M
        if (storage_field == nullptr) {
275
3.48M
            if (padding_minimal) {
276
1.57M
                buf->push_back(KeyConsts::KEY_MINIMAL_MARKER);
277
1.90M
            } else {
278
1.90M
                if (is_mow) {
279
1.62M
                    buf->push_back(KeyConsts::KEY_NORMAL_NEXT_MARKER);
280
1.62M
                } else {
281
283k
                    buf->push_back(KeyConsts::KEY_MAXIMAL_MARKER);
282
283k
                }
283
1.90M
            }
284
3.48M
            break;
285
3.48M
        }
286
287
12.1M
        if (cid >= _fields.size() || _fields[cid].is_null()) {
288
104k
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
289
104k
            continue;
290
104k
        }
291
292
12.0M
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
293
12.0M
        _encode_field(storage_field, _fields[cid], is_mow, buf);
294
12.0M
    }
295
3.73M
}
_ZNK5doris9RowCursor23encode_key_with_paddingILb0EEEvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb
Line
Count
Source
271
696k
                                        bool padding_minimal) const {
272
1.40M
    for (uint32_t cid = 0; cid < num_keys; cid++) {
273
1.20M
        auto* storage_field = _schema->column(cid);
274
1.20M
        if (storage_field == nullptr) {
275
495k
            if (padding_minimal) {
276
211k
                buf->push_back(KeyConsts::KEY_MINIMAL_MARKER);
277
284k
            } else {
278
284k
                if (is_mow) {
279
0
                    buf->push_back(KeyConsts::KEY_NORMAL_NEXT_MARKER);
280
284k
                } else {
281
284k
                    buf->push_back(KeyConsts::KEY_MAXIMAL_MARKER);
282
284k
                }
283
284k
            }
284
495k
            break;
285
495k
        }
286
287
711k
        if (cid >= _fields.size() || _fields[cid].is_null()) {
288
88.2k
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
289
88.2k
            continue;
290
88.2k
        }
291
292
622k
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
293
622k
        _encode_field(storage_field, _fields[cid], is_mow, buf);
294
622k
    }
295
696k
}
_ZNK5doris9RowCursor23encode_key_with_paddingILb1EEEvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb
Line
Count
Source
271
3.03M
                                        bool padding_minimal) const {
272
14.4M
    for (uint32_t cid = 0; cid < num_keys; cid++) {
273
14.4M
        auto* storage_field = _schema->column(cid);
274
14.4M
        if (storage_field == nullptr) {
275
2.98M
            if (padding_minimal) {
276
1.36M
                buf->push_back(KeyConsts::KEY_MINIMAL_MARKER);
277
1.62M
            } else {
278
1.62M
                if (is_mow) {
279
1.62M
                    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
1.62M
            }
284
2.98M
            break;
285
2.98M
        }
286
287
11.4M
        if (cid >= _fields.size() || _fields[cid].is_null()) {
288
15.9k
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
289
15.9k
            continue;
290
15.9k
        }
291
292
11.4M
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
293
11.4M
        _encode_field(storage_field, _fields[cid], is_mow, buf);
294
11.4M
    }
295
3.03M
}
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