Coverage Report

Created: 2026-04-10 08:10

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
#include "common/compile_check_begin.h"
39
using namespace ErrorCode;
40
41
4.06M
RowCursor::RowCursor() = default;
42
4.06M
RowCursor::~RowCursor() = default;
43
0
RowCursor::RowCursor(RowCursor&&) noexcept = default;
44
0
RowCursor& RowCursor::operator=(RowCursor&&) noexcept = default;
45
46
358
void RowCursor::_init_schema(TabletSchemaSPtr schema, uint32_t column_count) {
47
358
    std::vector<uint32_t> columns(column_count);
48
358
    std::iota(columns.begin(), columns.end(), 0);
49
358
    _schema.reset(new Schema(schema->columns(), columns));
50
358
}
51
52
3.34M
void RowCursor::_init_schema(const std::shared_ptr<Schema>& shared_schema, uint32_t column_count) {
53
3.34M
    _schema.reset(new Schema(*shared_schema));
54
3.34M
}
55
56
94
Status RowCursor::init(TabletSchemaSPtr schema, size_t num_columns) {
57
94
    if (num_columns > schema->num_columns()) {
58
0
        return Status::Error<INVALID_ARGUMENT>(
59
0
                "Input param are invalid. Column count is bigger than num_columns of schema. "
60
0
                "column_count={}, schema.num_columns={}",
61
0
                num_columns, schema->num_columns());
62
0
    }
63
94
    _init_schema(schema, cast_set<uint32_t>(num_columns));
64
    // Initialize all fields as null (TYPE_NULL).
65
94
    _fields.resize(num_columns);
66
94
    return Status::OK();
67
94
}
68
69
0
Status RowCursor::init(TabletSchemaSPtr schema, const OlapTuple& tuple) {
70
0
    size_t key_size = tuple.size();
71
0
    if (key_size > schema->num_columns()) {
72
0
        return Status::Error<INVALID_ARGUMENT>(
73
0
                "Input param are invalid. Column count is bigger than num_columns of schema. "
74
0
                "column_count={}, schema.num_columns={}",
75
0
                key_size, schema->num_columns());
76
0
    }
77
0
    _init_schema(schema, cast_set<uint32_t>(key_size));
78
0
    return from_tuple(tuple);
79
0
}
80
81
Status RowCursor::init(TabletSchemaSPtr schema, const OlapTuple& tuple,
82
3.35M
                       const std::shared_ptr<Schema>& shared_schema) {
83
3.35M
    size_t key_size = tuple.size();
84
3.35M
    if (key_size > schema->num_columns()) {
85
0
        return Status::Error<INVALID_ARGUMENT>(
86
0
                "Input param are invalid. Column count is bigger than num_columns of schema. "
87
0
                "column_count={}, schema.num_columns={}",
88
0
                key_size, schema->num_columns());
89
0
    }
90
3.35M
    _init_schema(shared_schema, cast_set<uint32_t>(key_size));
91
3.35M
    return from_tuple(tuple);
92
3.35M
}
93
94
264
Status RowCursor::init_scan_key(TabletSchemaSPtr schema, std::vector<Field> fields) {
95
264
    size_t key_size = fields.size();
96
264
    if (key_size > schema->num_columns()) {
97
0
        return Status::Error<INVALID_ARGUMENT>(
98
0
                "Input param are invalid. Column count is bigger than num_columns of schema. "
99
0
                "column_count={}, schema.num_columns={}",
100
0
                key_size, schema->num_columns());
101
0
    }
102
264
    _init_schema(schema, cast_set<uint32_t>(key_size));
103
264
    _fields = std::move(fields);
104
264
    return Status::OK();
105
264
}
106
107
3.34M
Status RowCursor::from_tuple(const OlapTuple& tuple) {
108
3.34M
    if (tuple.size() != _schema->num_column_ids()) {
109
0
        return Status::Error<INVALID_ARGUMENT>(
110
0
                "column count does not match. tuple_size={}, field_count={}", tuple.size(),
111
0
                _schema->num_column_ids());
112
0
    }
113
3.34M
    _fields.resize(tuple.size());
114
11.0M
    for (size_t i = 0; i < tuple.size(); ++i) {
115
7.66M
        _fields[i] = tuple.get_field(i);
116
7.66M
    }
117
3.34M
    return Status::OK();
118
3.34M
}
119
120
715k
RowCursor RowCursor::clone() const {
121
715k
    RowCursor result;
122
715k
    result._schema = std::make_unique<Schema>(*_schema);
123
715k
    result._fields = _fields;
124
715k
    return result;
125
715k
}
126
127
716k
void RowCursor::pad_char_fields() {
128
1.45M
    for (size_t i = 0; i < _fields.size(); ++i) {
129
741k
        const StorageField* col = _schema->column(cast_set<uint32_t>(i));
130
741k
        if (col->type() == FieldType::OLAP_FIELD_TYPE_CHAR && !_fields[i].is_null()) {
131
569
            String padded = _fields[i].get<TYPE_CHAR>();
132
569
            padded.resize(col->length(), '\0');
133
569
            _fields[i] = Field::create_field<TYPE_CHAR>(std::move(padded));
134
569
        }
135
741k
    }
136
716k
}
137
138
8.91M
std::string RowCursor::to_string() const {
139
8.91M
    std::string result;
140
32.6M
    for (size_t i = 0; i < _fields.size(); ++i) {
141
23.6M
        if (i > 0) {
142
14.7M
            result.append("|");
143
14.7M
        }
144
23.6M
        if (_fields[i].is_null()) {
145
463k
            result.append("1&NULL");
146
23.2M
        } else {
147
23.2M
            result.append("0&");
148
23.2M
            result.append(_fields[i].to_debug_string(
149
23.2M
                    _schema->column(cast_set<uint32_t>(i))->get_scale()));
150
23.2M
        }
151
23.6M
    }
152
8.91M
    return result;
153
8.91M
}
154
155
// Convert a Field value to its storage representation via PrimitiveTypeConvertor and encode.
156
// For most types this is an identity conversion; for DATE, DATETIME, DECIMALV2 it does
157
// actual conversion to the olap storage format.
158
template <PrimitiveType PT>
159
static void encode_non_string_field(const StorageField* storage_field, const Field& f,
160
1.15M
                                    bool full_encode, std::string* buf) {
161
1.15M
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
1.15M
    if (full_encode) {
163
520k
        storage_field->full_encode_ascending(&storage_val, buf);
164
630k
    } else {
165
630k
        storage_field->encode_ascending(&storage_val, buf);
166
630k
    }
167
1.15M
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE2EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
2.46k
                                    bool full_encode, std::string* buf) {
161
2.46k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
2.46k
    if (full_encode) {
163
232
        storage_field->full_encode_ascending(&storage_val, buf);
164
2.23k
    } else {
165
2.23k
        storage_field->encode_ascending(&storage_val, buf);
166
2.23k
    }
167
2.46k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE3EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
151k
                                    bool full_encode, std::string* buf) {
161
151k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
151k
    if (full_encode) {
163
6.51k
        storage_field->full_encode_ascending(&storage_val, buf);
164
145k
    } else {
165
145k
        storage_field->encode_ascending(&storage_val, buf);
166
145k
    }
167
151k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE4EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
10.4k
                                    bool full_encode, std::string* buf) {
161
10.4k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
10.4k
    if (full_encode) {
163
2.56k
        storage_field->full_encode_ascending(&storage_val, buf);
164
7.84k
    } else {
165
7.84k
        storage_field->encode_ascending(&storage_val, buf);
166
7.84k
    }
167
10.4k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE5EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
657k
                                    bool full_encode, std::string* buf) {
161
657k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
657k
    if (full_encode) {
163
459k
        storage_field->full_encode_ascending(&storage_val, buf);
164
459k
    } else {
165
197k
        storage_field->encode_ascending(&storage_val, buf);
166
197k
    }
167
657k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE6EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
30.9k
                                    bool full_encode, std::string* buf) {
161
30.9k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
30.9k
    if (full_encode) {
163
5.16k
        storage_field->full_encode_ascending(&storage_val, buf);
164
25.7k
    } else {
165
25.7k
        storage_field->encode_ascending(&storage_val, buf);
166
25.7k
    }
167
30.9k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE7EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
13.2k
                                    bool full_encode, std::string* buf) {
161
13.2k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
13.2k
    if (full_encode) {
163
1.55k
        storage_field->full_encode_ascending(&storage_val, buf);
164
11.6k
    } else {
165
11.6k
        storage_field->encode_ascending(&storage_val, buf);
166
11.6k
    }
167
13.2k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE8EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
8
                                    bool full_encode, std::string* buf) {
161
8
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
8
    if (full_encode) {
163
2
        storage_field->full_encode_ascending(&storage_val, buf);
164
6
    } else {
165
6
        storage_field->encode_ascending(&storage_val, buf);
166
6
    }
167
8
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE9EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
3
                                    bool full_encode, std::string* buf) {
161
3
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
3
    if (full_encode) {
163
1
        storage_field->full_encode_ascending(&storage_val, buf);
164
2
    } else {
165
2
        storage_field->encode_ascending(&storage_val, buf);
166
2
    }
167
3
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE11EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
16.8k
                                    bool full_encode, std::string* buf) {
161
16.8k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
16.8k
    if (full_encode) {
163
7.76k
        storage_field->full_encode_ascending(&storage_val, buf);
164
9.07k
    } else {
165
9.07k
        storage_field->encode_ascending(&storage_val, buf);
166
9.07k
    }
167
16.8k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE12EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
171
                                    bool full_encode, std::string* buf) {
161
171
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
171
    if (full_encode) {
163
13
        storage_field->full_encode_ascending(&storage_val, buf);
164
158
    } else {
165
158
        storage_field->encode_ascending(&storage_val, buf);
166
158
    }
167
171
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE25EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
250k
                                    bool full_encode, std::string* buf) {
161
250k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
250k
    if (full_encode) {
163
31.1k
        storage_field->full_encode_ascending(&storage_val, buf);
164
218k
    } else {
165
218k
        storage_field->encode_ascending(&storage_val, buf);
166
218k
    }
167
250k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE26EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
6.91k
                                    bool full_encode, std::string* buf) {
161
6.91k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
6.91k
    if (full_encode) {
163
2.34k
        storage_field->full_encode_ascending(&storage_val, buf);
164
4.56k
    } else {
165
4.56k
        storage_field->encode_ascending(&storage_val, buf);
166
4.56k
    }
167
6.91k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE42EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
8.05k
                                    bool full_encode, std::string* buf) {
161
8.05k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
8.05k
    if (full_encode) {
163
3.27k
        storage_field->full_encode_ascending(&storage_val, buf);
164
4.78k
    } else {
165
4.78k
        storage_field->encode_ascending(&storage_val, buf);
166
4.78k
    }
167
8.05k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE20EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
122
                                    bool full_encode, std::string* buf) {
161
122
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
122
    if (full_encode) {
163
15
        storage_field->full_encode_ascending(&storage_val, buf);
164
107
    } else {
165
107
        storage_field->encode_ascending(&storage_val, buf);
166
107
    }
167
122
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE28EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
437
                                    bool full_encode, std::string* buf) {
161
437
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
437
    if (full_encode) {
163
70
        storage_field->full_encode_ascending(&storage_val, buf);
164
367
    } else {
165
367
        storage_field->encode_ascending(&storage_val, buf);
166
367
    }
167
437
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE29EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
349
                                    bool full_encode, std::string* buf) {
161
349
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
349
    if (full_encode) {
163
54
        storage_field->full_encode_ascending(&storage_val, buf);
164
295
    } else {
165
295
        storage_field->encode_ascending(&storage_val, buf);
166
295
    }
167
349
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE30EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
830
                                    bool full_encode, std::string* buf) {
161
830
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
830
    if (full_encode) {
163
99
        storage_field->full_encode_ascending(&storage_val, buf);
164
731
    } else {
165
731
        storage_field->encode_ascending(&storage_val, buf);
166
731
    }
167
830
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE35EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
755
                                    bool full_encode, std::string* buf) {
161
755
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
755
    if (full_encode) {
163
0
        storage_field->full_encode_ascending(&storage_val, buf);
164
755
    } else {
165
755
        storage_field->encode_ascending(&storage_val, buf);
166
755
    }
167
755
}
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
160
2
                                    bool full_encode, std::string* buf) {
161
2
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
2
    if (full_encode) {
163
0
        storage_field->full_encode_ascending(&storage_val, buf);
164
2
    } else {
165
2
        storage_field->encode_ascending(&storage_val, buf);
166
2
    }
167
2
}
168
169
void RowCursor::_encode_field(const StorageField* storage_field, const Field& f, bool full_encode,
170
12.3M
                              std::string* buf) const {
171
12.3M
    FieldType ft = storage_field->type();
172
173
12.3M
    if (field_is_slice_type(ft)) {
174
        // String types: CHAR, VARCHAR, STRING — all stored as String in Field.
175
11.2M
        const String& str = f.get<TYPE_STRING>();
176
177
11.2M
        if (ft == FieldType::OLAP_FIELD_TYPE_CHAR) {
178
            // CHAR type: must pad with \0 to the declared column length
179
604
            size_t col_len = storage_field->length();
180
604
            String padded(col_len, '\0');
181
604
            memcpy(padded.data(), str.data(), std::min(str.size(), col_len));
182
183
604
            Slice slice(padded.data(), col_len);
184
604
            if (full_encode) {
185
32
                storage_field->full_encode_ascending(&slice, buf);
186
572
            } else {
187
572
                storage_field->encode_ascending(&slice, buf);
188
572
            }
189
11.2M
        } else {
190
            // VARCHAR / STRING: use actual length
191
11.2M
            Slice slice(str.data(), str.size());
192
11.2M
            if (full_encode) {
193
11.2M
                storage_field->full_encode_ascending(&slice, buf);
194
11.2M
            } else {
195
16.7k
                storage_field->encode_ascending(&slice, buf);
196
16.7k
            }
197
11.2M
        }
198
11.2M
        return;
199
11.2M
    }
200
201
    // Non-string types: convert Field value to storage format via PrimitiveTypeConvertor,
202
    // then encode. For most types this is an identity conversion.
203
1.15M
    switch (ft) {
204
2.46k
    case FieldType::OLAP_FIELD_TYPE_BOOL:
205
2.46k
        encode_non_string_field<TYPE_BOOLEAN>(storage_field, f, full_encode, buf);
206
2.46k
        break;
207
151k
    case FieldType::OLAP_FIELD_TYPE_TINYINT:
208
151k
        encode_non_string_field<TYPE_TINYINT>(storage_field, f, full_encode, buf);
209
151k
        break;
210
10.4k
    case FieldType::OLAP_FIELD_TYPE_SMALLINT:
211
10.4k
        encode_non_string_field<TYPE_SMALLINT>(storage_field, f, full_encode, buf);
212
10.4k
        break;
213
657k
    case FieldType::OLAP_FIELD_TYPE_INT:
214
657k
        encode_non_string_field<TYPE_INT>(storage_field, f, full_encode, buf);
215
657k
        break;
216
30.9k
    case FieldType::OLAP_FIELD_TYPE_BIGINT:
217
30.9k
        encode_non_string_field<TYPE_BIGINT>(storage_field, f, full_encode, buf);
218
30.9k
        break;
219
13.2k
    case FieldType::OLAP_FIELD_TYPE_LARGEINT:
220
13.2k
        encode_non_string_field<TYPE_LARGEINT>(storage_field, f, full_encode, buf);
221
13.2k
        break;
222
8
    case FieldType::OLAP_FIELD_TYPE_FLOAT:
223
8
        encode_non_string_field<TYPE_FLOAT>(storage_field, f, full_encode, buf);
224
8
        break;
225
3
    case FieldType::OLAP_FIELD_TYPE_DOUBLE:
226
3
        encode_non_string_field<TYPE_DOUBLE>(storage_field, f, full_encode, buf);
227
3
        break;
228
16.8k
    case FieldType::OLAP_FIELD_TYPE_DATE:
229
16.8k
        encode_non_string_field<TYPE_DATE>(storage_field, f, full_encode, buf);
230
16.8k
        break;
231
171
    case FieldType::OLAP_FIELD_TYPE_DATETIME:
232
171
        encode_non_string_field<TYPE_DATETIME>(storage_field, f, full_encode, buf);
233
171
        break;
234
250k
    case FieldType::OLAP_FIELD_TYPE_DATEV2:
235
250k
        encode_non_string_field<TYPE_DATEV2>(storage_field, f, full_encode, buf);
236
250k
        break;
237
6.91k
    case FieldType::OLAP_FIELD_TYPE_DATETIMEV2:
238
6.91k
        encode_non_string_field<TYPE_DATETIMEV2>(storage_field, f, full_encode, buf);
239
6.91k
        break;
240
8.05k
    case FieldType::OLAP_FIELD_TYPE_TIMESTAMPTZ:
241
8.05k
        encode_non_string_field<TYPE_TIMESTAMPTZ>(storage_field, f, full_encode, buf);
242
8.05k
        break;
243
122
    case FieldType::OLAP_FIELD_TYPE_DECIMAL:
244
122
        encode_non_string_field<TYPE_DECIMALV2>(storage_field, f, full_encode, buf);
245
122
        break;
246
437
    case FieldType::OLAP_FIELD_TYPE_DECIMAL32:
247
437
        encode_non_string_field<TYPE_DECIMAL32>(storage_field, f, full_encode, buf);
248
437
        break;
249
349
    case FieldType::OLAP_FIELD_TYPE_DECIMAL64:
250
349
        encode_non_string_field<TYPE_DECIMAL64>(storage_field, f, full_encode, buf);
251
349
        break;
252
830
    case FieldType::OLAP_FIELD_TYPE_DECIMAL128I:
253
830
        encode_non_string_field<TYPE_DECIMAL128I>(storage_field, f, full_encode, buf);
254
830
        break;
255
755
    case FieldType::OLAP_FIELD_TYPE_DECIMAL256:
256
755
        encode_non_string_field<TYPE_DECIMAL256>(storage_field, f, full_encode, buf);
257
755
        break;
258
0
    case FieldType::OLAP_FIELD_TYPE_IPV4:
259
0
        encode_non_string_field<TYPE_IPV4>(storage_field, f, full_encode, buf);
260
0
        break;
261
2
    case FieldType::OLAP_FIELD_TYPE_IPV6:
262
2
        encode_non_string_field<TYPE_IPV6>(storage_field, f, full_encode, buf);
263
2
        break;
264
0
    default:
265
0
        LOG(FATAL) << "unsupported field type for encoding: " << int(ft);
266
0
        break;
267
1.15M
    }
268
1.15M
}
269
270
template <bool is_mow>
271
void RowCursor::encode_key_with_padding(std::string* buf, size_t num_keys,
272
3.73M
                                        bool padding_minimal) const {
273
15.8M
    for (uint32_t cid = 0; cid < num_keys; cid++) {
274
15.6M
        auto* storage_field = _schema->column(cid);
275
15.6M
        if (storage_field == nullptr) {
276
3.48M
            if (padding_minimal) {
277
1.58M
                buf->push_back(KeyConsts::KEY_MINIMAL_MARKER);
278
1.89M
            } else {
279
1.89M
                if (is_mow) {
280
1.60M
                    buf->push_back(KeyConsts::KEY_NORMAL_NEXT_MARKER);
281
1.60M
                } else {
282
289k
                    buf->push_back(KeyConsts::KEY_MAXIMAL_MARKER);
283
289k
                }
284
1.89M
            }
285
3.48M
            break;
286
3.48M
        }
287
288
12.1M
        if (cid >= _fields.size() || _fields[cid].is_null()) {
289
117k
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
290
117k
            continue;
291
117k
        }
292
293
12.0M
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
294
12.0M
        _encode_field(storage_field, _fields[cid], is_mow, buf);
295
12.0M
    }
296
3.73M
}
_ZNK5doris9RowCursor23encode_key_with_paddingILb0EEEvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb
Line
Count
Source
272
715k
                                        bool padding_minimal) const {
273
1.45M
    for (uint32_t cid = 0; cid < num_keys; cid++) {
274
1.25M
        auto* storage_field = _schema->column(cid);
275
1.25M
        if (storage_field == nullptr) {
276
510k
            if (padding_minimal) {
277
219k
                buf->push_back(KeyConsts::KEY_MINIMAL_MARKER);
278
290k
            } else {
279
290k
                if (is_mow) {
280
0
                    buf->push_back(KeyConsts::KEY_NORMAL_NEXT_MARKER);
281
290k
                } else {
282
290k
                    buf->push_back(KeyConsts::KEY_MAXIMAL_MARKER);
283
290k
                }
284
290k
            }
285
510k
            break;
286
510k
        }
287
288
741k
        if (cid >= _fields.size() || _fields[cid].is_null()) {
289
101k
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
290
101k
            continue;
291
101k
        }
292
293
638k
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
294
638k
        _encode_field(storage_field, _fields[cid], is_mow, buf);
295
638k
    }
296
715k
}
_ZNK5doris9RowCursor23encode_key_with_paddingILb1EEEvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb
Line
Count
Source
272
3.01M
                                        bool padding_minimal) const {
273
14.4M
    for (uint32_t cid = 0; cid < num_keys; cid++) {
274
14.3M
        auto* storage_field = _schema->column(cid);
275
14.3M
        if (storage_field == nullptr) {
276
2.97M
            if (padding_minimal) {
277
1.36M
                buf->push_back(KeyConsts::KEY_MINIMAL_MARKER);
278
1.60M
            } else {
279
1.60M
                if (is_mow) {
280
1.60M
                    buf->push_back(KeyConsts::KEY_NORMAL_NEXT_MARKER);
281
18.4E
                } else {
282
18.4E
                    buf->push_back(KeyConsts::KEY_MAXIMAL_MARKER);
283
18.4E
                }
284
1.60M
            }
285
2.97M
            break;
286
2.97M
        }
287
288
11.4M
        if (cid >= _fields.size() || _fields[cid].is_null()) {
289
16.2k
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
290
16.2k
            continue;
291
16.2k
        }
292
293
11.4M
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
294
11.4M
        _encode_field(storage_field, _fields[cid], is_mow, buf);
295
11.4M
    }
296
3.01M
}
297
298
// Explicit template instantiations
299
template void RowCursor::encode_key_with_padding<false>(std::string*, size_t, bool) const;
300
template void RowCursor::encode_key_with_padding<true>(std::string*, size_t, bool) const;
301
302
template <bool full_encode>
303
129k
void RowCursor::encode_key(std::string* buf, size_t num_keys) const {
304
387k
    for (uint32_t cid = 0; cid < num_keys; cid++) {
305
258k
        if (cid >= _fields.size() || _fields[cid].is_null()) {
306
6
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
307
6
            continue;
308
6
        }
309
258k
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
310
258k
        _encode_field(_schema->column(cid), _fields[cid], full_encode, buf);
311
258k
    }
312
129k
}
_ZNK5doris9RowCursor10encode_keyILb0EEEvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm
Line
Count
Source
303
33
void RowCursor::encode_key(std::string* buf, size_t num_keys) const {
304
82
    for (uint32_t cid = 0; cid < num_keys; cid++) {
305
49
        if (cid >= _fields.size() || _fields[cid].is_null()) {
306
6
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
307
6
            continue;
308
6
        }
309
43
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
310
43
        _encode_field(_schema->column(cid), _fields[cid], full_encode, buf);
311
43
    }
312
33
}
_ZNK5doris9RowCursor10encode_keyILb1EEEvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm
Line
Count
Source
303
129k
void RowCursor::encode_key(std::string* buf, size_t num_keys) const {
304
387k
    for (uint32_t cid = 0; cid < num_keys; cid++) {
305
258k
        if (cid >= _fields.size() || _fields[cid].is_null()) {
306
0
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
307
0
            continue;
308
0
        }
309
258k
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
310
258k
        _encode_field(_schema->column(cid), _fields[cid], full_encode, buf);
311
258k
    }
312
129k
}
313
314
template void RowCursor::encode_key<false>(std::string*, size_t) const;
315
template void RowCursor::encode_key<true>(std::string*, size_t) const;
316
317
#include "common/compile_check_end.h"
318
} // namespace doris