Coverage Report

Created: 2026-04-18 11: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
3.31M
RowCursor::RowCursor() = default;
41
3.31M
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
2.56M
void RowCursor::_init_schema(const std::shared_ptr<Schema>& shared_schema, uint32_t column_count) {
52
2.56M
    _schema.reset(new Schema(*shared_schema));
53
2.56M
}
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
2.56M
                       const std::shared_ptr<Schema>& shared_schema) {
82
2.56M
    size_t key_size = tuple.size();
83
2.56M
    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
2.56M
    _init_schema(shared_schema, cast_set<uint32_t>(key_size));
90
2.56M
    return from_tuple(tuple);
91
2.56M
}
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
2.56M
Status RowCursor::from_tuple(const OlapTuple& tuple) {
107
2.56M
    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
2.56M
    _fields.resize(tuple.size());
113
7.55M
    for (size_t i = 0; i < tuple.size(); ++i) {
114
4.99M
        _fields[i] = tuple.get_field(i);
115
4.99M
    }
116
2.56M
    return Status::OK();
117
2.56M
}
118
119
746k
RowCursor RowCursor::clone() const {
120
746k
    RowCursor result;
121
746k
    result._schema = std::make_unique<Schema>(*_schema);
122
746k
    result._fields = _fields;
123
746k
    return result;
124
746k
}
125
126
747k
void RowCursor::pad_char_fields() {
127
1.50M
    for (size_t i = 0; i < _fields.size(); ++i) {
128
758k
        const StorageField* col = _schema->column(cast_set<uint32_t>(i));
129
758k
        if (col->type() == FieldType::OLAP_FIELD_TYPE_CHAR && !_fields[i].is_null()) {
130
574
            String padded = _fields[i].get<TYPE_CHAR>();
131
574
            padded.resize(col->length(), '\0');
132
574
            _fields[i] = Field::create_field<TYPE_CHAR>(std::move(padded));
133
574
        }
134
758k
    }
135
747k
}
136
137
7.53M
std::string RowCursor::to_string() const {
138
7.53M
    std::string result;
139
26.5M
    for (size_t i = 0; i < _fields.size(); ++i) {
140
19.0M
        if (i > 0) {
141
11.4M
            result.append("|");
142
11.4M
        }
143
19.0M
        if (_fields[i].is_null()) {
144
448k
            result.append("1&NULL");
145
18.5M
        } else {
146
18.5M
            result.append("0&");
147
18.5M
            result.append(_fields[i].to_debug_string(
148
18.5M
                    _schema->column(cast_set<uint32_t>(i))->get_scale()));
149
18.5M
        }
150
19.0M
    }
151
7.53M
    return result;
152
7.53M
}
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.17M
                                    bool full_encode, std::string* buf) {
160
1.17M
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
1.17M
    if (full_encode) {
162
507k
        storage_field->full_encode_ascending(&storage_val, buf);
163
664k
    } else {
164
664k
        storage_field->encode_ascending(&storage_val, buf);
165
664k
    }
166
1.17M
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE2EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
2.51k
                                    bool full_encode, std::string* buf) {
160
2.51k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
2.51k
    if (full_encode) {
162
232
        storage_field->full_encode_ascending(&storage_val, buf);
163
2.28k
    } else {
164
2.28k
        storage_field->encode_ascending(&storage_val, buf);
165
2.28k
    }
166
2.51k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE3EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
148k
                                    bool full_encode, std::string* buf) {
160
148k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
148k
    if (full_encode) {
162
6.52k
        storage_field->full_encode_ascending(&storage_val, buf);
163
141k
    } else {
164
141k
        storage_field->encode_ascending(&storage_val, buf);
165
141k
    }
166
148k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE4EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
4.11k
                                    bool full_encode, std::string* buf) {
160
4.11k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
4.11k
    if (full_encode) {
162
87
        storage_field->full_encode_ascending(&storage_val, buf);
163
4.02k
    } else {
164
4.02k
        storage_field->encode_ascending(&storage_val, buf);
165
4.02k
    }
166
4.11k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE5EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
682k
                                    bool full_encode, std::string* buf) {
160
682k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
682k
    if (full_encode) {
162
459k
        storage_field->full_encode_ascending(&storage_val, buf);
163
459k
    } else {
164
223k
        storage_field->encode_ascending(&storage_val, buf);
165
223k
    }
166
682k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE6EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
35.1k
                                    bool full_encode, std::string* buf) {
160
35.1k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
35.1k
    if (full_encode) {
162
5.02k
        storage_field->full_encode_ascending(&storage_val, buf);
163
30.1k
    } else {
164
30.1k
        storage_field->encode_ascending(&storage_val, buf);
165
30.1k
    }
166
35.1k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE7EEEvPKNS_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
1.54k
        storage_field->full_encode_ascending(&storage_val, buf);
163
11.2k
    } else {
164
11.2k
        storage_field->encode_ascending(&storage_val, buf);
165
11.2k
    }
166
12.8k
}
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
4.44k
                                    bool full_encode, std::string* buf) {
160
4.44k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
4.44k
    if (full_encode) {
162
1
        storage_field->full_encode_ascending(&storage_val, buf);
163
4.43k
    } else {
164
4.43k
        storage_field->encode_ascending(&storage_val, buf);
165
4.43k
    }
166
4.44k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE12EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
175
                                    bool full_encode, std::string* buf) {
160
175
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
175
    if (full_encode) {
162
13
        storage_field->full_encode_ascending(&storage_val, buf);
163
162
    } else {
164
162
        storage_field->encode_ascending(&storage_val, buf);
165
162
    }
166
175
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE25EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
264k
                                    bool full_encode, std::string* buf) {
160
264k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
264k
    if (full_encode) {
162
29.6k
        storage_field->full_encode_ascending(&storage_val, buf);
163
234k
    } else {
164
234k
        storage_field->encode_ascending(&storage_val, buf);
165
234k
    }
166
264k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE26EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
6.77k
                                    bool full_encode, std::string* buf) {
160
6.77k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
6.77k
    if (full_encode) {
162
2.48k
        storage_field->full_encode_ascending(&storage_val, buf);
163
4.29k
    } else {
164
4.29k
        storage_field->encode_ascending(&storage_val, buf);
165
4.29k
    }
166
6.77k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE42EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
7.89k
                                    bool full_encode, std::string* buf) {
160
7.89k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
7.89k
    if (full_encode) {
162
3.06k
        storage_field->full_encode_ascending(&storage_val, buf);
163
4.82k
    } else {
164
4.82k
        storage_field->encode_ascending(&storage_val, buf);
165
4.82k
    }
166
7.89k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE20EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
112
                                    bool full_encode, std::string* buf) {
160
112
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
112
    if (full_encode) {
162
15
        storage_field->full_encode_ascending(&storage_val, buf);
163
97
    } else {
164
97
        storage_field->encode_ascending(&storage_val, buf);
165
97
    }
166
112
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE28EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
433
                                    bool full_encode, std::string* buf) {
160
433
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
433
    if (full_encode) {
162
70
        storage_field->full_encode_ascending(&storage_val, buf);
163
363
    } else {
164
363
        storage_field->encode_ascending(&storage_val, buf);
165
363
    }
166
433
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE29EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
357
                                    bool full_encode, std::string* buf) {
160
357
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
357
    if (full_encode) {
162
54
        storage_field->full_encode_ascending(&storage_val, buf);
163
303
    } else {
164
303
        storage_field->encode_ascending(&storage_val, buf);
165
303
    }
166
357
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE30EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
839
                                    bool full_encode, std::string* buf) {
160
839
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
839
    if (full_encode) {
162
99
        storage_field->full_encode_ascending(&storage_val, buf);
163
740
    } else {
164
740
        storage_field->encode_ascending(&storage_val, buf);
165
740
    }
166
839
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE35EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
159
757
                                    bool full_encode, std::string* buf) {
160
757
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
161
757
    if (full_encode) {
162
0
        storage_field->full_encode_ascending(&storage_val, buf);
163
757
    } else {
164
757
        storage_field->encode_ascending(&storage_val, buf);
165
757
    }
166
757
}
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
9.32M
                              std::string* buf) const {
170
9.32M
    FieldType ft = storage_field->type();
171
172
9.32M
    if (field_is_slice_type(ft)) {
173
        // String types: CHAR, VARCHAR, STRING — all stored as String in Field.
174
8.15M
        const String& str = f.get<TYPE_STRING>();
175
176
8.15M
        if (ft == FieldType::OLAP_FIELD_TYPE_CHAR) {
177
            // CHAR type: must pad with \0 to the declared column length
178
609
            size_t col_len = storage_field->length();
179
609
            String padded(col_len, '\0');
180
609
            memcpy(padded.data(), str.data(), std::min(str.size(), col_len));
181
182
609
            Slice slice(padded.data(), col_len);
183
609
            if (full_encode) {
184
32
                storage_field->full_encode_ascending(&slice, buf);
185
577
            } else {
186
577
                storage_field->encode_ascending(&slice, buf);
187
577
            }
188
8.15M
        } else {
189
            // VARCHAR / STRING: use actual length
190
8.15M
            Slice slice(str.data(), str.size());
191
8.15M
            if (full_encode) {
192
8.14M
                storage_field->full_encode_ascending(&slice, buf);
193
8.14M
            } else {
194
12.5k
                storage_field->encode_ascending(&slice, buf);
195
12.5k
            }
196
8.15M
        }
197
8.15M
        return;
198
8.15M
    }
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.17M
    switch (ft) {
203
2.51k
    case FieldType::OLAP_FIELD_TYPE_BOOL:
204
2.51k
        encode_non_string_field<TYPE_BOOLEAN>(storage_field, f, full_encode, buf);
205
2.51k
        break;
206
148k
    case FieldType::OLAP_FIELD_TYPE_TINYINT:
207
148k
        encode_non_string_field<TYPE_TINYINT>(storage_field, f, full_encode, buf);
208
148k
        break;
209
4.11k
    case FieldType::OLAP_FIELD_TYPE_SMALLINT:
210
4.11k
        encode_non_string_field<TYPE_SMALLINT>(storage_field, f, full_encode, buf);
211
4.11k
        break;
212
682k
    case FieldType::OLAP_FIELD_TYPE_INT:
213
682k
        encode_non_string_field<TYPE_INT>(storage_field, f, full_encode, buf);
214
682k
        break;
215
35.2k
    case FieldType::OLAP_FIELD_TYPE_BIGINT:
216
35.2k
        encode_non_string_field<TYPE_BIGINT>(storage_field, f, full_encode, buf);
217
35.2k
        break;
218
12.8k
    case FieldType::OLAP_FIELD_TYPE_LARGEINT:
219
12.8k
        encode_non_string_field<TYPE_LARGEINT>(storage_field, f, full_encode, buf);
220
12.8k
        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
4.44k
    case FieldType::OLAP_FIELD_TYPE_DATE:
228
4.44k
        encode_non_string_field<TYPE_DATE>(storage_field, f, full_encode, buf);
229
4.44k
        break;
230
175
    case FieldType::OLAP_FIELD_TYPE_DATETIME:
231
175
        encode_non_string_field<TYPE_DATETIME>(storage_field, f, full_encode, buf);
232
175
        break;
233
264k
    case FieldType::OLAP_FIELD_TYPE_DATEV2:
234
264k
        encode_non_string_field<TYPE_DATEV2>(storage_field, f, full_encode, buf);
235
264k
        break;
236
6.77k
    case FieldType::OLAP_FIELD_TYPE_DATETIMEV2:
237
6.77k
        encode_non_string_field<TYPE_DATETIMEV2>(storage_field, f, full_encode, buf);
238
6.77k
        break;
239
7.89k
    case FieldType::OLAP_FIELD_TYPE_TIMESTAMPTZ:
240
7.89k
        encode_non_string_field<TYPE_TIMESTAMPTZ>(storage_field, f, full_encode, buf);
241
7.89k
        break;
242
112
    case FieldType::OLAP_FIELD_TYPE_DECIMAL:
243
112
        encode_non_string_field<TYPE_DECIMALV2>(storage_field, f, full_encode, buf);
244
112
        break;
245
433
    case FieldType::OLAP_FIELD_TYPE_DECIMAL32:
246
433
        encode_non_string_field<TYPE_DECIMAL32>(storage_field, f, full_encode, buf);
247
433
        break;
248
357
    case FieldType::OLAP_FIELD_TYPE_DECIMAL64:
249
357
        encode_non_string_field<TYPE_DECIMAL64>(storage_field, f, full_encode, buf);
250
357
        break;
251
839
    case FieldType::OLAP_FIELD_TYPE_DECIMAL128I:
252
839
        encode_non_string_field<TYPE_DECIMAL128I>(storage_field, f, full_encode, buf);
253
839
        break;
254
757
    case FieldType::OLAP_FIELD_TYPE_DECIMAL256:
255
757
        encode_non_string_field<TYPE_DECIMAL256>(storage_field, f, full_encode, buf);
256
757
        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.17M
    }
267
1.17M
}
268
269
template <bool is_mow>
270
void RowCursor::encode_key_with_padding(std::string* buf, size_t num_keys,
271
2.98M
                                        bool padding_minimal) const {
272
12.0M
    for (uint32_t cid = 0; cid < num_keys; cid++) {
273
11.8M
        auto* storage_field = _schema->column(cid);
274
11.8M
        if (storage_field == nullptr) {
275
2.75M
            if (padding_minimal) {
276
1.24M
                buf->push_back(KeyConsts::KEY_MINIMAL_MARKER);
277
1.50M
            } else {
278
1.50M
                if (is_mow) {
279
1.19M
                    buf->push_back(KeyConsts::KEY_NORMAL_NEXT_MARKER);
280
1.19M
                } else {
281
314k
                    buf->push_back(KeyConsts::KEY_MAXIMAL_MARKER);
282
314k
                }
283
1.50M
            }
284
2.75M
            break;
285
2.75M
        }
286
287
9.10M
        if (cid >= _fields.size() || _fields[cid].is_null()) {
288
100k
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
289
100k
            continue;
290
100k
        }
291
292
8.99M
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
293
8.99M
        _encode_field(storage_field, _fields[cid], is_mow, buf);
294
8.99M
    }
295
2.98M
}
_ZNK5doris9RowCursor23encode_key_with_paddingILb0EEEvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb
Line
Count
Source
271
746k
                                        bool padding_minimal) const {
272
1.50M
    for (uint32_t cid = 0; cid < num_keys; cid++) {
273
1.31M
        auto* storage_field = _schema->column(cid);
274
1.31M
        if (storage_field == nullptr) {
275
558k
            if (padding_minimal) {
276
243k
                buf->push_back(KeyConsts::KEY_MINIMAL_MARKER);
277
314k
            } else {
278
314k
                if (is_mow) {
279
0
                    buf->push_back(KeyConsts::KEY_NORMAL_NEXT_MARKER);
280
314k
                } else {
281
314k
                    buf->push_back(KeyConsts::KEY_MAXIMAL_MARKER);
282
314k
                }
283
314k
            }
284
558k
            break;
285
558k
        }
286
287
758k
        if (cid >= _fields.size() || _fields[cid].is_null()) {
288
84.1k
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
289
84.1k
            continue;
290
84.1k
        }
291
292
671k
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
293
671k
        _encode_field(storage_field, _fields[cid], is_mow, buf);
294
671k
    }
295
746k
}
_ZNK5doris9RowCursor23encode_key_with_paddingILb1EEEvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb
Line
Count
Source
271
2.23M
                                        bool padding_minimal) const {
272
10.5M
    for (uint32_t cid = 0; cid < num_keys; cid++) {
273
10.5M
        auto* storage_field = _schema->column(cid);
274
10.5M
        if (storage_field == nullptr) {
275
2.19M
            if (padding_minimal) {
276
1.00M
                buf->push_back(KeyConsts::KEY_MINIMAL_MARKER);
277
1.19M
            } else {
278
1.19M
                if (is_mow) {
279
1.19M
                    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.19M
            }
284
2.19M
            break;
285
2.19M
        }
286
287
8.34M
        if (cid >= _fields.size() || _fields[cid].is_null()) {
288
16.0k
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
289
16.0k
            continue;
290
16.0k
        }
291
292
8.32M
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
293
8.32M
        _encode_field(storage_field, _fields[cid], is_mow, buf);
294
8.32M
    }
295
2.23M
}
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