Coverage Report

Created: 2026-03-26 13:18

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
3.66M
RowCursor::RowCursor() = default;
42
3.67M
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
2.90M
void RowCursor::_init_schema(const std::shared_ptr<Schema>& shared_schema, uint32_t column_count) {
53
2.90M
    _schema.reset(new Schema(*shared_schema));
54
2.90M
}
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
2.92M
                       const std::shared_ptr<Schema>& shared_schema) {
83
2.92M
    size_t key_size = tuple.size();
84
2.92M
    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
2.92M
    _init_schema(shared_schema, cast_set<uint32_t>(key_size));
91
2.92M
    return from_tuple(tuple);
92
2.92M
}
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
2.91M
Status RowCursor::from_tuple(const OlapTuple& tuple) {
108
2.91M
    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
2.91M
    _fields.resize(tuple.size());
114
8.42M
    for (size_t i = 0; i < tuple.size(); ++i) {
115
5.51M
        _fields[i] = tuple.get_field(i);
116
5.51M
    }
117
2.91M
    return Status::OK();
118
2.91M
}
119
120
749k
RowCursor RowCursor::clone() const {
121
749k
    RowCursor result;
122
749k
    result._schema = std::make_unique<Schema>(*_schema);
123
749k
    result._fields = _fields;
124
749k
    return result;
125
749k
}
126
127
750k
void RowCursor::pad_char_fields() {
128
1.51M
    for (size_t i = 0; i < _fields.size(); ++i) {
129
763k
        const StorageField* col = _schema->column(cast_set<uint32_t>(i));
130
763k
        if (col->type() == FieldType::OLAP_FIELD_TYPE_CHAR && !_fields[i].is_null()) {
131
585
            String padded = _fields[i].get<TYPE_CHAR>();
132
585
            padded.resize(col->length(), '\0');
133
585
            _fields[i] = Field::create_field<TYPE_CHAR>(std::move(padded));
134
585
        }
135
763k
    }
136
750k
}
137
138
8.57M
std::string RowCursor::to_string() const {
139
8.57M
    std::string result;
140
30.3M
    for (size_t i = 0; i < _fields.size(); ++i) {
141
21.8M
        if (i > 0) {
142
13.2M
            result.append("|");
143
13.2M
        }
144
21.8M
        if (_fields[i].is_null()) {
145
425k
            result.append("1&NULL");
146
21.3M
        } else {
147
21.3M
            result.append("0&");
148
21.3M
            result.append(_fields[i].to_debug_string(
149
21.3M
                    _schema->column(cast_set<uint32_t>(i))->get_scale()));
150
21.3M
        }
151
21.8M
    }
152
8.57M
    return result;
153
8.57M
}
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.17M
                                    bool full_encode, std::string* buf) {
161
1.17M
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
1.17M
    if (full_encode) {
163
509k
        storage_field->full_encode_ascending(&storage_val, buf);
164
668k
    } else {
165
668k
        storage_field->encode_ascending(&storage_val, buf);
166
668k
    }
167
1.17M
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE2EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
2.35k
                                    bool full_encode, std::string* buf) {
161
2.35k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
2.35k
    if (full_encode) {
163
232
        storage_field->full_encode_ascending(&storage_val, buf);
164
2.12k
    } else {
165
2.12k
        storage_field->encode_ascending(&storage_val, buf);
166
2.12k
    }
167
2.35k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE3EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
161k
                                    bool full_encode, std::string* buf) {
161
161k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
161k
    if (full_encode) {
163
6.51k
        storage_field->full_encode_ascending(&storage_val, buf);
164
154k
    } else {
165
154k
        storage_field->encode_ascending(&storage_val, buf);
166
154k
    }
167
161k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE4EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
4.24k
                                    bool full_encode, std::string* buf) {
161
4.24k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
4.24k
    if (full_encode) {
163
87
        storage_field->full_encode_ascending(&storage_val, buf);
164
4.16k
    } else {
165
4.16k
        storage_field->encode_ascending(&storage_val, buf);
166
4.16k
    }
167
4.24k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE5EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
660k
                                    bool full_encode, std::string* buf) {
161
660k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
660k
    if (full_encode) {
163
458k
        storage_field->full_encode_ascending(&storage_val, buf);
164
458k
    } else {
165
202k
        storage_field->encode_ascending(&storage_val, buf);
166
202k
    }
167
660k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE6EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
33.0k
                                    bool full_encode, std::string* buf) {
161
33.0k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
33.0k
    if (full_encode) {
163
5.49k
        storage_field->full_encode_ascending(&storage_val, buf);
164
27.5k
    } else {
165
27.5k
        storage_field->encode_ascending(&storage_val, buf);
166
27.5k
    }
167
33.0k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE7EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
12.6k
                                    bool full_encode, std::string* buf) {
161
12.6k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
12.6k
    if (full_encode) {
163
1.51k
        storage_field->full_encode_ascending(&storage_val, buf);
164
11.1k
    } else {
165
11.1k
        storage_field->encode_ascending(&storage_val, buf);
166
11.1k
    }
167
12.6k
}
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
2.00k
                                    bool full_encode, std::string* buf) {
161
2.00k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
2.00k
    if (full_encode) {
163
1
        storage_field->full_encode_ascending(&storage_val, buf);
164
2.00k
    } else {
165
2.00k
        storage_field->encode_ascending(&storage_val, buf);
166
2.00k
    }
167
2.00k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE12EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
114
                                    bool full_encode, std::string* buf) {
161
114
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
114
    if (full_encode) {
163
1
        storage_field->full_encode_ascending(&storage_val, buf);
164
113
    } else {
165
113
        storage_field->encode_ascending(&storage_val, buf);
166
113
    }
167
114
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE25EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
284k
                                    bool full_encode, std::string* buf) {
161
284k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
284k
    if (full_encode) {
163
31.3k
        storage_field->full_encode_ascending(&storage_val, buf);
164
253k
    } else {
165
253k
        storage_field->encode_ascending(&storage_val, buf);
166
253k
    }
167
284k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE26EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
6.63k
                                    bool full_encode, std::string* buf) {
161
6.63k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
6.63k
    if (full_encode) {
163
2.30k
        storage_field->full_encode_ascending(&storage_val, buf);
164
4.33k
    } else {
165
4.33k
        storage_field->encode_ascending(&storage_val, buf);
166
4.33k
    }
167
6.63k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE42EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
7.88k
                                    bool full_encode, std::string* buf) {
161
7.88k
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
7.88k
    if (full_encode) {
163
3.07k
        storage_field->full_encode_ascending(&storage_val, buf);
164
4.80k
    } else {
165
4.80k
        storage_field->encode_ascending(&storage_val, buf);
166
4.80k
    }
167
7.88k
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE20EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
40
                                    bool full_encode, std::string* buf) {
161
40
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
40
    if (full_encode) {
163
11
        storage_field->full_encode_ascending(&storage_val, buf);
164
29
    } else {
165
29
        storage_field->encode_ascending(&storage_val, buf);
166
29
    }
167
40
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE28EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
431
                                    bool full_encode, std::string* buf) {
161
431
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
431
    if (full_encode) {
163
70
        storage_field->full_encode_ascending(&storage_val, buf);
164
361
    } else {
165
361
        storage_field->encode_ascending(&storage_val, buf);
166
361
    }
167
431
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE29EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
351
                                    bool full_encode, std::string* buf) {
161
351
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
351
    if (full_encode) {
163
54
        storage_field->full_encode_ascending(&storage_val, buf);
164
297
    } else {
165
297
        storage_field->encode_ascending(&storage_val, buf);
166
297
    }
167
351
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE30EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
869
                                    bool full_encode, std::string* buf) {
161
869
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
869
    if (full_encode) {
163
99
        storage_field->full_encode_ascending(&storage_val, buf);
164
770
    } else {
165
770
        storage_field->encode_ascending(&storage_val, buf);
166
770
    }
167
869
}
row_cursor.cpp:_ZN5dorisL23encode_non_string_fieldILNS_13PrimitiveTypeE35EEEvPKNS_12StorageFieldERKNS_5FieldEbPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
160
759
                                    bool full_encode, std::string* buf) {
161
759
    auto storage_val = PrimitiveTypeConvertor<PT>::to_storage_field_type(f.get<PT>());
162
759
    if (full_encode) {
163
0
        storage_field->full_encode_ascending(&storage_val, buf);
164
759
    } else {
165
759
        storage_field->encode_ascending(&storage_val, buf);
166
759
    }
167
759
}
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
10.8M
                              std::string* buf) const {
171
10.8M
    FieldType ft = storage_field->type();
172
173
10.8M
    if (field_is_slice_type(ft)) {
174
        // String types: CHAR, VARCHAR, STRING — all stored as String in Field.
175
9.70M
        const String& str = f.get<TYPE_STRING>();
176
177
9.70M
        if (ft == FieldType::OLAP_FIELD_TYPE_CHAR) {
178
            // CHAR type: must pad with \0 to the declared column length
179
637
            size_t col_len = storage_field->length();
180
637
            String padded(col_len, '\0');
181
637
            memcpy(padded.data(), str.data(), std::min(str.size(), col_len));
182
183
637
            Slice slice(padded.data(), col_len);
184
637
            if (full_encode) {
185
50
                storage_field->full_encode_ascending(&slice, buf);
186
587
            } else {
187
587
                storage_field->encode_ascending(&slice, buf);
188
587
            }
189
9.70M
        } else {
190
            // VARCHAR / STRING: use actual length
191
9.70M
            Slice slice(str.data(), str.size());
192
9.70M
            if (full_encode) {
193
9.68M
                storage_field->full_encode_ascending(&slice, buf);
194
9.68M
            } else {
195
16.7k
                storage_field->encode_ascending(&slice, buf);
196
16.7k
            }
197
9.70M
        }
198
9.70M
        return;
199
9.70M
    }
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.17M
    switch (ft) {
204
2.35k
    case FieldType::OLAP_FIELD_TYPE_BOOL:
205
2.35k
        encode_non_string_field<TYPE_BOOLEAN>(storage_field, f, full_encode, buf);
206
2.35k
        break;
207
161k
    case FieldType::OLAP_FIELD_TYPE_TINYINT:
208
161k
        encode_non_string_field<TYPE_TINYINT>(storage_field, f, full_encode, buf);
209
161k
        break;
210
4.24k
    case FieldType::OLAP_FIELD_TYPE_SMALLINT:
211
4.24k
        encode_non_string_field<TYPE_SMALLINT>(storage_field, f, full_encode, buf);
212
4.24k
        break;
213
660k
    case FieldType::OLAP_FIELD_TYPE_INT:
214
660k
        encode_non_string_field<TYPE_INT>(storage_field, f, full_encode, buf);
215
660k
        break;
216
33.0k
    case FieldType::OLAP_FIELD_TYPE_BIGINT:
217
33.0k
        encode_non_string_field<TYPE_BIGINT>(storage_field, f, full_encode, buf);
218
33.0k
        break;
219
12.6k
    case FieldType::OLAP_FIELD_TYPE_LARGEINT:
220
12.6k
        encode_non_string_field<TYPE_LARGEINT>(storage_field, f, full_encode, buf);
221
12.6k
        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
2.00k
    case FieldType::OLAP_FIELD_TYPE_DATE:
229
2.00k
        encode_non_string_field<TYPE_DATE>(storage_field, f, full_encode, buf);
230
2.00k
        break;
231
114
    case FieldType::OLAP_FIELD_TYPE_DATETIME:
232
114
        encode_non_string_field<TYPE_DATETIME>(storage_field, f, full_encode, buf);
233
114
        break;
234
284k
    case FieldType::OLAP_FIELD_TYPE_DATEV2:
235
284k
        encode_non_string_field<TYPE_DATEV2>(storage_field, f, full_encode, buf);
236
284k
        break;
237
6.63k
    case FieldType::OLAP_FIELD_TYPE_DATETIMEV2:
238
6.63k
        encode_non_string_field<TYPE_DATETIMEV2>(storage_field, f, full_encode, buf);
239
6.63k
        break;
240
7.88k
    case FieldType::OLAP_FIELD_TYPE_TIMESTAMPTZ:
241
7.88k
        encode_non_string_field<TYPE_TIMESTAMPTZ>(storage_field, f, full_encode, buf);
242
7.88k
        break;
243
40
    case FieldType::OLAP_FIELD_TYPE_DECIMAL:
244
40
        encode_non_string_field<TYPE_DECIMALV2>(storage_field, f, full_encode, buf);
245
40
        break;
246
431
    case FieldType::OLAP_FIELD_TYPE_DECIMAL32:
247
431
        encode_non_string_field<TYPE_DECIMAL32>(storage_field, f, full_encode, buf);
248
431
        break;
249
351
    case FieldType::OLAP_FIELD_TYPE_DECIMAL64:
250
351
        encode_non_string_field<TYPE_DECIMAL64>(storage_field, f, full_encode, buf);
251
351
        break;
252
869
    case FieldType::OLAP_FIELD_TYPE_DECIMAL128I:
253
869
        encode_non_string_field<TYPE_DECIMAL128I>(storage_field, f, full_encode, buf);
254
869
        break;
255
759
    case FieldType::OLAP_FIELD_TYPE_DECIMAL256:
256
759
        encode_non_string_field<TYPE_DECIMAL256>(storage_field, f, full_encode, buf);
257
759
        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.17M
    }
268
1.17M
}
269
270
template <bool is_mow>
271
void RowCursor::encode_key_with_padding(std::string* buf, size_t num_keys,
272
3.37M
                                        bool padding_minimal) const {
273
14.0M
    for (uint32_t cid = 0; cid < num_keys; cid++) {
274
13.7M
        auto* storage_field = _schema->column(cid);
275
13.7M
        if (storage_field == nullptr) {
276
3.14M
            if (padding_minimal) {
277
1.42M
                buf->push_back(KeyConsts::KEY_MINIMAL_MARKER);
278
1.72M
            } else {
279
1.72M
                if (is_mow) {
280
1.40M
                    buf->push_back(KeyConsts::KEY_NORMAL_NEXT_MARKER);
281
1.40M
                } else {
282
319k
                    buf->push_back(KeyConsts::KEY_MAXIMAL_MARKER);
283
319k
                }
284
1.72M
            }
285
3.14M
            break;
286
3.14M
        }
287
288
10.6M
        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
10.5M
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
294
10.5M
        _encode_field(storage_field, _fields[cid], is_mow, buf);
295
10.5M
    }
296
3.37M
}
_ZNK5doris9RowCursor23encode_key_with_paddingILb0EEEvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb
Line
Count
Source
272
749k
                                        bool padding_minimal) const {
273
1.50M
    for (uint32_t cid = 0; cid < num_keys; cid++) {
274
1.32M
        auto* storage_field = _schema->column(cid);
275
1.32M
        if (storage_field == nullptr) {
276
562k
            if (padding_minimal) {
277
242k
                buf->push_back(KeyConsts::KEY_MINIMAL_MARKER);
278
319k
            } else {
279
319k
                if (is_mow) {
280
0
                    buf->push_back(KeyConsts::KEY_NORMAL_NEXT_MARKER);
281
319k
                } else {
282
319k
                    buf->push_back(KeyConsts::KEY_MAXIMAL_MARKER);
283
319k
                }
284
319k
            }
285
562k
            break;
286
562k
        }
287
288
763k
        if (cid >= _fields.size() || _fields[cid].is_null()) {
289
85.8k
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
290
85.8k
            continue;
291
85.8k
        }
292
293
673k
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
294
673k
        _encode_field(storage_field, _fields[cid], is_mow, buf);
295
673k
    }
296
749k
}
_ZNK5doris9RowCursor23encode_key_with_paddingILb1EEEvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmb
Line
Count
Source
272
2.62M
                                        bool padding_minimal) const {
273
12.5M
    for (uint32_t cid = 0; cid < num_keys; cid++) {
274
12.4M
        auto* storage_field = _schema->column(cid);
275
12.4M
        if (storage_field == nullptr) {
276
2.58M
            if (padding_minimal) {
277
1.18M
                buf->push_back(KeyConsts::KEY_MINIMAL_MARKER);
278
1.40M
            } else {
279
1.40M
                if (is_mow) {
280
1.40M
                    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.40M
            }
285
2.58M
            break;
286
2.58M
        }
287
288
9.89M
        if (cid >= _fields.size() || _fields[cid].is_null()) {
289
15.7k
            buf->push_back(KeyConsts::KEY_NULL_FIRST_MARKER);
290
15.7k
            continue;
291
15.7k
        }
292
293
9.86M
        buf->push_back(KeyConsts::KEY_NORMAL_MARKER);
294
9.86M
        _encode_field(storage_field, _fields[cid], is_mow, buf);
295
9.86M
    }
296
2.62M
}
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