be/src/storage/olap_tuple.h
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 | | #pragma once |
19 | | |
20 | | #include <vector> |
21 | | |
22 | | #include "core/field.h" |
23 | | |
24 | | namespace doris { |
25 | | |
26 | | class OlapTuple { |
27 | | public: |
28 | 2.03M | OlapTuple() {} |
29 | | |
30 | 132k | void add_null() { _fields.emplace_back(PrimitiveType::TYPE_NULL); } |
31 | | |
32 | 1.15M | void add_field(Field f) { _fields.push_back(std::move(f)); } |
33 | | |
34 | 21.7M | size_t size() const { return _fields.size(); } |
35 | | |
36 | | // Return debug string for profile/logging only. |
37 | | // NOTE: this output may be inaccurate for decimal types because OlapTuple |
38 | | // does not carry decimal scale metadata and falls back to scale=0. |
39 | 23.7k | std::string debug_string() const { |
40 | 23.7k | std::string result; |
41 | 48.5k | for (size_t i = 0; i < _fields.size(); ++i) { |
42 | 24.8k | if (i > 0) { |
43 | 1.22k | result.append(","); |
44 | 1.22k | } |
45 | 24.8k | if (_fields[i].is_null()) { |
46 | 1.09k | result.append("null"); |
47 | 23.7k | } else { |
48 | 23.7k | result.append(_fields[i].to_debug_string(0)); |
49 | 23.7k | } |
50 | 24.8k | } |
51 | 23.7k | return result; |
52 | 23.7k | } |
53 | | |
54 | 5.72M | const Field& get_field(size_t i) const { return _fields[i]; } |
55 | 0 | Field& get_field(size_t i) { return _fields[i]; } |
56 | | |
57 | | private: |
58 | | std::vector<Field> _fields; |
59 | | }; |
60 | | |
61 | | } // namespace doris |