/root/doris/be/src/runtime/collection_value.h
Line | Count | Source (jump to first uncovered line) |
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 <stdint.h> |
21 | | |
22 | | #include <functional> |
23 | | #include <utility> |
24 | | |
25 | | namespace doris { |
26 | | |
27 | | using MemFootprint = std::pair<int64_t, uint8_t*>; |
28 | | using GenMemFootprintFunc = std::function<MemFootprint(int64_t size)>; |
29 | | |
30 | | /** |
31 | | * The format of array-typed slot. |
32 | | * A new array needs to be initialized before using it. |
33 | | */ |
34 | | class CollectionValue { |
35 | | public: |
36 | 15 | CollectionValue() = default; |
37 | | |
38 | | explicit CollectionValue(uint64_t length) |
39 | 0 | : _data(nullptr), _length(length), _has_null(false), _null_signs(nullptr) {} |
40 | | |
41 | | CollectionValue(void* data, uint64_t length) |
42 | 0 | : _data(data), _length(length), _has_null(false), _null_signs(nullptr) {} |
43 | | |
44 | | CollectionValue(void* data, uint64_t length, bool* null_signs) |
45 | 30 | : _data(data), _length(length), _has_null(true), _null_signs(null_signs) {} |
46 | | |
47 | | CollectionValue(void* data, uint64_t length, bool has_null, bool* null_signs) |
48 | 0 | : _data(data), _length(length), _has_null(has_null), _null_signs(null_signs) {} |
49 | | |
50 | 270 | bool is_null_at(uint64_t index) const { return this->_has_null && this->_null_signs[index]; } |
51 | | |
52 | 15 | uint64_t size() const { return _length; } |
53 | | |
54 | 315 | uint64_t length() const { return _length; } |
55 | | |
56 | | void shallow_copy(const CollectionValue* other); |
57 | | |
58 | | void copy_null_signs(const CollectionValue* other); |
59 | | |
60 | 0 | const void* data() const { return _data; } |
61 | 135 | bool has_null() const { return _has_null; } |
62 | 15 | const bool* null_signs() const { return _null_signs; } |
63 | 15 | void* mutable_data() { return _data; } |
64 | 30 | bool* mutable_null_signs() { return _null_signs; } |
65 | 30 | void set_length(uint64_t length) { _length = length; } |
66 | 30 | void set_has_null(bool has_null) { _has_null = has_null; } |
67 | 30 | void set_data(void* data) { _data = data; } |
68 | 30 | void set_null_signs(bool* null_signs) { _null_signs = null_signs; } |
69 | | |
70 | | private: |
71 | | // child column data |
72 | | void* _data = nullptr; |
73 | | uint64_t _length; |
74 | | // item has no null value if has_null is false. |
75 | | // item ```may``` has null value if has_null is true. |
76 | | bool _has_null; |
77 | | // null bitmap |
78 | | bool* _null_signs = nullptr; |
79 | | }; |
80 | | } // namespace doris |