/root/doris/be/src/olap/key_coder.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 <glog/logging.h> |
21 | | #include <limits.h> |
22 | | #include <stdint.h> |
23 | | #include <string.h> |
24 | | |
25 | | #include <algorithm> |
26 | | #include <bit> |
27 | | #include <ostream> |
28 | | #include <string> |
29 | | #include <type_traits> |
30 | | |
31 | | #include "absl/strings/substitute.h" |
32 | | #include "common/status.h" |
33 | | #include "gutil/endian.h" |
34 | | #include "gutil/strings/substitute.h" |
35 | | #include "olap/decimal12.h" |
36 | | #include "olap/olap_common.h" |
37 | | #include "olap/types.h" |
38 | | #include "util/slice.h" |
39 | | #include "vec/core/types.h" |
40 | | |
41 | | namespace doris { |
42 | | |
43 | | using strings::Substitute; |
44 | | |
45 | | using FullEncodeAscendingFunc = void (*)(const void* value, std::string* buf); |
46 | | using EncodeAscendingFunc = void (*)(const void* value, size_t index_size, std::string* buf); |
47 | | using DecodeAscendingFunc = Status (*)(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr); |
48 | | |
49 | | // Order-preserving binary encoding for values of a particular type so that |
50 | | // those values can be compared by memcpy their encoded bytes. |
51 | | // |
52 | | // To obtain instance of this class, use the `get_key_coder(FieldType)` method. |
53 | | class KeyCoder { |
54 | | public: |
55 | | template <typename TraitsType> |
56 | | KeyCoder(TraitsType traits); |
57 | | |
58 | | // encode the provided `value` into `buf`. |
59 | 981k | void full_encode_ascending(const void* value, std::string* buf) const { |
60 | 981k | _full_encode_ascending(value, buf); |
61 | 981k | } |
62 | | |
63 | | // similar to `full_encode_ascending`, but only encode part (the first `index_size` bytes) of the value. |
64 | | // only applicable to string type |
65 | 11.9k | void encode_ascending(const void* value, size_t index_size, std::string* buf) const { |
66 | 11.9k | _encode_ascending(value, index_size, buf); |
67 | 11.9k | } |
68 | | |
69 | | // Only used for test, should delete it in the future |
70 | 19 | Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) const { |
71 | 19 | return _decode_ascending(encoded_key, index_size, cell_ptr); |
72 | 19 | } |
73 | | |
74 | | private: |
75 | | FullEncodeAscendingFunc _full_encode_ascending; |
76 | | EncodeAscendingFunc _encode_ascending; |
77 | | DecodeAscendingFunc _decode_ascending; |
78 | | }; |
79 | | |
80 | | extern const KeyCoder* get_key_coder(FieldType type); |
81 | | |
82 | | template <FieldType field_type, typename Enable = void> |
83 | | class KeyCoderTraits {}; |
84 | | |
85 | | template <FieldType field_type> |
86 | | class KeyCoderTraits< |
87 | | field_type, |
88 | | typename std::enable_if< |
89 | | std::is_integral<typename CppTypeTraits<field_type>::CppType>::value || |
90 | | field_type == FieldType::OLAP_FIELD_TYPE_DECIMAL256 || |
91 | | vectorized::IsDecimalNumber<typename CppTypeTraits<field_type>::CppType>>::type> { |
92 | | public: |
93 | | using CppType = typename CppTypeTraits<field_type>::CppType; |
94 | | using UnsignedCppType = typename CppTypeTraits<field_type>::UnsignedCppType; |
95 | | |
96 | | private: |
97 | | // Swap value's endian from/to big endian |
98 | 1.06M | static UnsignedCppType swap_big_endian(UnsignedCppType val) { |
99 | 1.06M | if constexpr (field_type == FieldType::OLAP_FIELD_TYPE_DECIMAL256) { Branch (99:23): [Folded - Ignored]
Branch (99:23): [Folded - Ignored]
Branch (99:23): [Folded - Ignored]
Branch (99:23): [Folded - Ignored]
Branch (99:23): [Folded - Ignored]
Branch (99:23): [Folded - Ignored]
Branch (99:23): [Folded - Ignored]
Branch (99:23): [Folded - Ignored]
Branch (99:23): [Folded - Ignored]
Branch (99:23): [Folded - Ignored]
Branch (99:23): [Folded - Ignored]
Branch (99:23): [Folded - Ignored]
Branch (99:23): [Folded - Ignored]
Branch (99:23): [Folded - Ignored]
Branch (99:23): [Folded - Ignored]
|
100 | 1.06M | return BigEndian::FromHost256(val); |
101 | 1.06M | } else { |
102 | 1.06M | switch (sizeof(UnsignedCppType)) { |
103 | 16.0k | case 1: Branch (103:13): [True: 0, False: 216]
Branch (103:13): [True: 0, False: 973k]
Branch (103:13): [True: 16.0k, False: 0]
Branch (103:13): [True: 0, False: 242]
Branch (103:13): [True: 0, False: 208]
Branch (103:13): [True: 0, False: 70.9k]
Branch (103:13): [True: 0, False: 207]
Branch (103:13): [True: 0, False: 210]
Branch (103:13): [True: 0, False: 0]
Branch (103:13): [True: 0, False: 0]
Branch (103:13): [True: 0, False: 0]
Branch (103:13): [True: 0, False: 0]
Branch (103:13): [True: 0, False: 0]
Branch (103:13): [True: 0, False: 0]
|
104 | 16.0k | return val; |
105 | 242 | case 2: Branch (105:13): [True: 0, False: 216]
Branch (105:13): [True: 0, False: 973k]
Branch (105:13): [True: 0, False: 16.0k]
Branch (105:13): [True: 242, False: 0]
Branch (105:13): [True: 0, False: 208]
Branch (105:13): [True: 0, False: 70.9k]
Branch (105:13): [True: 0, False: 207]
Branch (105:13): [True: 0, False: 210]
Branch (105:13): [True: 0, False: 0]
Branch (105:13): [True: 0, False: 0]
Branch (105:13): [True: 0, False: 0]
Branch (105:13): [True: 0, False: 0]
Branch (105:13): [True: 0, False: 0]
Branch (105:13): [True: 0, False: 0]
|
106 | 242 | return BigEndian::FromHost16(val); |
107 | 974k | case 4: Branch (107:13): [True: 0, False: 216]
Branch (107:13): [True: 973k, False: 0]
Branch (107:13): [True: 0, False: 16.0k]
Branch (107:13): [True: 0, False: 242]
Branch (107:13): [True: 208, False: 0]
Branch (107:13): [True: 0, False: 70.9k]
Branch (107:13): [True: 0, False: 207]
Branch (107:13): [True: 0, False: 210]
Branch (107:13): [True: 0, False: 0]
Branch (107:13): [True: 0, False: 0]
Branch (107:13): [True: 0, False: 0]
Branch (107:13): [True: 0, False: 0]
Branch (107:13): [True: 0, False: 0]
Branch (107:13): [True: 0, False: 0]
|
108 | 974k | return BigEndian::FromHost32(val); |
109 | 71.3k | case 8: Branch (109:13): [True: 216, False: 0]
Branch (109:13): [True: 0, False: 973k]
Branch (109:13): [True: 0, False: 16.0k]
Branch (109:13): [True: 0, False: 242]
Branch (109:13): [True: 0, False: 208]
Branch (109:13): [True: 70.9k, False: 0]
Branch (109:13): [True: 0, False: 207]
Branch (109:13): [True: 210, False: 0]
Branch (109:13): [True: 0, False: 0]
Branch (109:13): [True: 0, False: 0]
Branch (109:13): [True: 0, False: 0]
Branch (109:13): [True: 0, False: 0]
Branch (109:13): [True: 0, False: 0]
Branch (109:13): [True: 0, False: 0]
|
110 | 71.3k | return BigEndian::FromHost64(val); |
111 | 207 | case 16: Branch (111:13): [True: 0, False: 216]
Branch (111:13): [True: 0, False: 973k]
Branch (111:13): [True: 0, False: 16.0k]
Branch (111:13): [True: 0, False: 242]
Branch (111:13): [True: 0, False: 208]
Branch (111:13): [True: 0, False: 70.9k]
Branch (111:13): [True: 207, False: 0]
Branch (111:13): [True: 0, False: 210]
Branch (111:13): [True: 0, False: 0]
Branch (111:13): [True: 0, False: 0]
Branch (111:13): [True: 0, False: 0]
Branch (111:13): [True: 0, False: 0]
Branch (111:13): [True: 0, False: 0]
Branch (111:13): [True: 0, False: 0]
|
112 | 207 | return BigEndian::FromHost128(val); |
113 | 0 | default: Branch (113:13): [True: 0, False: 216]
Branch (113:13): [True: 0, False: 973k]
Branch (113:13): [True: 0, False: 16.0k]
Branch (113:13): [True: 0, False: 242]
Branch (113:13): [True: 0, False: 208]
Branch (113:13): [True: 0, False: 70.9k]
Branch (113:13): [True: 0, False: 207]
Branch (113:13): [True: 0, False: 210]
Branch (113:13): [True: 0, False: 0]
Branch (113:13): [True: 0, False: 0]
Branch (113:13): [True: 0, False: 0]
Branch (113:13): [True: 0, False: 0]
Branch (113:13): [True: 0, False: 0]
Branch (113:13): [True: 0, False: 0]
|
114 | 0 | LOG(FATAL) << "Invalid type to big endian, type=" << int(field_type) |
115 | 0 | << ", size=" << sizeof(UnsignedCppType); |
116 | 1.06M | } |
117 | 1.06M | } |
118 | 1.06M | } _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE7EvE15swap_big_endianEm Line | Count | Source | 98 | 216 | static UnsignedCppType swap_big_endian(UnsignedCppType val) { | 99 | 216 | if constexpr (field_type == FieldType::OLAP_FIELD_TYPE_DECIMAL256) { Branch (99:23): [Folded - Ignored]
| 100 | 216 | return BigEndian::FromHost256(val); | 101 | 216 | } else { | 102 | 216 | switch (sizeof(UnsignedCppType)) { | 103 | 0 | case 1: Branch (103:13): [True: 0, False: 216]
| 104 | 0 | return val; | 105 | 0 | case 2: Branch (105:13): [True: 0, False: 216]
| 106 | 0 | return BigEndian::FromHost16(val); | 107 | 0 | case 4: Branch (107:13): [True: 0, False: 216]
| 108 | 0 | return BigEndian::FromHost32(val); | 109 | 216 | case 8: Branch (109:13): [True: 216, False: 0]
| 110 | 216 | return BigEndian::FromHost64(val); | 111 | 0 | case 16: Branch (111:13): [True: 0, False: 216]
| 112 | 0 | return BigEndian::FromHost128(val); | 113 | 0 | default: Branch (113:13): [True: 0, False: 216]
| 114 | 0 | LOG(FATAL) << "Invalid type to big endian, type=" << int(field_type) | 115 | 0 | << ", size=" << sizeof(UnsignedCppType); | 116 | 216 | } | 117 | 216 | } | 118 | 216 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE5EvE15swap_big_endianEj Line | Count | Source | 98 | 973k | static UnsignedCppType swap_big_endian(UnsignedCppType val) { | 99 | 973k | if constexpr (field_type == FieldType::OLAP_FIELD_TYPE_DECIMAL256) { Branch (99:23): [Folded - Ignored]
| 100 | 973k | return BigEndian::FromHost256(val); | 101 | 973k | } else { | 102 | 973k | switch (sizeof(UnsignedCppType)) { | 103 | 0 | case 1: Branch (103:13): [True: 0, False: 973k]
| 104 | 0 | return val; | 105 | 0 | case 2: Branch (105:13): [True: 0, False: 973k]
| 106 | 0 | return BigEndian::FromHost16(val); | 107 | 973k | case 4: Branch (107:13): [True: 973k, False: 0]
| 108 | 973k | return BigEndian::FromHost32(val); | 109 | 0 | case 8: Branch (109:13): [True: 0, False: 973k]
| 110 | 0 | return BigEndian::FromHost64(val); | 111 | 0 | case 16: Branch (111:13): [True: 0, False: 973k]
| 112 | 0 | return BigEndian::FromHost128(val); | 113 | 0 | default: Branch (113:13): [True: 0, False: 973k]
| 114 | 0 | LOG(FATAL) << "Invalid type to big endian, type=" << int(field_type) | 115 | 0 | << ", size=" << sizeof(UnsignedCppType); | 116 | 973k | } | 117 | 973k | } | 118 | 973k | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE1EvE15swap_big_endianEh Line | Count | Source | 98 | 16.0k | static UnsignedCppType swap_big_endian(UnsignedCppType val) { | 99 | 16.0k | if constexpr (field_type == FieldType::OLAP_FIELD_TYPE_DECIMAL256) { Branch (99:23): [Folded - Ignored]
| 100 | 16.0k | return BigEndian::FromHost256(val); | 101 | 16.0k | } else { | 102 | 16.0k | switch (sizeof(UnsignedCppType)) { | 103 | 16.0k | case 1: Branch (103:13): [True: 16.0k, False: 0]
| 104 | 16.0k | return val; | 105 | 0 | case 2: Branch (105:13): [True: 0, False: 16.0k]
| 106 | 0 | return BigEndian::FromHost16(val); | 107 | 0 | case 4: Branch (107:13): [True: 0, False: 16.0k]
| 108 | 0 | return BigEndian::FromHost32(val); | 109 | 0 | case 8: Branch (109:13): [True: 0, False: 16.0k]
| 110 | 0 | return BigEndian::FromHost64(val); | 111 | 0 | case 16: Branch (111:13): [True: 0, False: 16.0k]
| 112 | 0 | return BigEndian::FromHost128(val); | 113 | 0 | default: Branch (113:13): [True: 0, False: 16.0k]
| 114 | 0 | LOG(FATAL) << "Invalid type to big endian, type=" << int(field_type) | 115 | 0 | << ", size=" << sizeof(UnsignedCppType); | 116 | 16.0k | } | 117 | 16.0k | } | 118 | 16.0k | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE3EvE15swap_big_endianEt Line | Count | Source | 98 | 242 | static UnsignedCppType swap_big_endian(UnsignedCppType val) { | 99 | 242 | if constexpr (field_type == FieldType::OLAP_FIELD_TYPE_DECIMAL256) { Branch (99:23): [Folded - Ignored]
| 100 | 242 | return BigEndian::FromHost256(val); | 101 | 242 | } else { | 102 | 242 | switch (sizeof(UnsignedCppType)) { | 103 | 0 | case 1: Branch (103:13): [True: 0, False: 242]
| 104 | 0 | return val; | 105 | 242 | case 2: Branch (105:13): [True: 242, False: 0]
| 106 | 242 | return BigEndian::FromHost16(val); | 107 | 0 | case 4: Branch (107:13): [True: 0, False: 242]
| 108 | 0 | return BigEndian::FromHost32(val); | 109 | 0 | case 8: Branch (109:13): [True: 0, False: 242]
| 110 | 0 | return BigEndian::FromHost64(val); | 111 | 0 | case 16: Branch (111:13): [True: 0, False: 242]
| 112 | 0 | return BigEndian::FromHost128(val); | 113 | 0 | default: Branch (113:13): [True: 0, False: 242]
| 114 | 0 | LOG(FATAL) << "Invalid type to big endian, type=" << int(field_type) | 115 | 0 | << ", size=" << sizeof(UnsignedCppType); | 116 | 242 | } | 117 | 242 | } | 118 | 242 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE6EvE15swap_big_endianEj Line | Count | Source | 98 | 208 | static UnsignedCppType swap_big_endian(UnsignedCppType val) { | 99 | 208 | if constexpr (field_type == FieldType::OLAP_FIELD_TYPE_DECIMAL256) { Branch (99:23): [Folded - Ignored]
| 100 | 208 | return BigEndian::FromHost256(val); | 101 | 208 | } else { | 102 | 208 | switch (sizeof(UnsignedCppType)) { | 103 | 0 | case 1: Branch (103:13): [True: 0, False: 208]
| 104 | 0 | return val; | 105 | 0 | case 2: Branch (105:13): [True: 0, False: 208]
| 106 | 0 | return BigEndian::FromHost16(val); | 107 | 208 | case 4: Branch (107:13): [True: 208, False: 0]
| 108 | 208 | return BigEndian::FromHost32(val); | 109 | 0 | case 8: Branch (109:13): [True: 0, False: 208]
| 110 | 0 | return BigEndian::FromHost64(val); | 111 | 0 | case 16: Branch (111:13): [True: 0, False: 208]
| 112 | 0 | return BigEndian::FromHost128(val); | 113 | 0 | default: Branch (113:13): [True: 0, False: 208]
| 114 | 0 | LOG(FATAL) << "Invalid type to big endian, type=" << int(field_type) | 115 | 0 | << ", size=" << sizeof(UnsignedCppType); | 116 | 208 | } | 117 | 208 | } | 118 | 208 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE8EvE15swap_big_endianEm Line | Count | Source | 98 | 70.9k | static UnsignedCppType swap_big_endian(UnsignedCppType val) { | 99 | 70.9k | if constexpr (field_type == FieldType::OLAP_FIELD_TYPE_DECIMAL256) { Branch (99:23): [Folded - Ignored]
| 100 | 70.9k | return BigEndian::FromHost256(val); | 101 | 70.9k | } else { | 102 | 70.9k | switch (sizeof(UnsignedCppType)) { | 103 | 0 | case 1: Branch (103:13): [True: 0, False: 70.9k]
| 104 | 0 | return val; | 105 | 0 | case 2: Branch (105:13): [True: 0, False: 70.9k]
| 106 | 0 | return BigEndian::FromHost16(val); | 107 | 0 | case 4: Branch (107:13): [True: 0, False: 70.9k]
| 108 | 0 | return BigEndian::FromHost32(val); | 109 | 70.9k | case 8: Branch (109:13): [True: 70.9k, False: 0]
| 110 | 70.9k | return BigEndian::FromHost64(val); | 111 | 0 | case 16: Branch (111:13): [True: 0, False: 70.9k]
| 112 | 0 | return BigEndian::FromHost128(val); | 113 | 0 | default: Branch (113:13): [True: 0, False: 70.9k]
| 114 | 0 | LOG(FATAL) << "Invalid type to big endian, type=" << int(field_type) | 115 | 0 | << ", size=" << sizeof(UnsignedCppType); | 116 | 70.9k | } | 117 | 70.9k | } | 118 | 70.9k | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE9EvE15swap_big_endianEo Line | Count | Source | 98 | 207 | static UnsignedCppType swap_big_endian(UnsignedCppType val) { | 99 | 207 | if constexpr (field_type == FieldType::OLAP_FIELD_TYPE_DECIMAL256) { Branch (99:23): [Folded - Ignored]
| 100 | 207 | return BigEndian::FromHost256(val); | 101 | 207 | } else { | 102 | 207 | switch (sizeof(UnsignedCppType)) { | 103 | 0 | case 1: Branch (103:13): [True: 0, False: 207]
| 104 | 0 | return val; | 105 | 0 | case 2: Branch (105:13): [True: 0, False: 207]
| 106 | 0 | return BigEndian::FromHost16(val); | 107 | 0 | case 4: Branch (107:13): [True: 0, False: 207]
| 108 | 0 | return BigEndian::FromHost32(val); | 109 | 0 | case 8: Branch (109:13): [True: 0, False: 207]
| 110 | 0 | return BigEndian::FromHost64(val); | 111 | 207 | case 16: Branch (111:13): [True: 207, False: 0]
| 112 | 207 | return BigEndian::FromHost128(val); | 113 | 0 | default: Branch (113:13): [True: 0, False: 207]
| 114 | 0 | LOG(FATAL) << "Invalid type to big endian, type=" << int(field_type) | 115 | 0 | << ", size=" << sizeof(UnsignedCppType); | 116 | 207 | } | 117 | 207 | } | 118 | 207 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE15EvE15swap_big_endianEm Line | Count | Source | 98 | 210 | static UnsignedCppType swap_big_endian(UnsignedCppType val) { | 99 | 210 | if constexpr (field_type == FieldType::OLAP_FIELD_TYPE_DECIMAL256) { Branch (99:23): [Folded - Ignored]
| 100 | 210 | return BigEndian::FromHost256(val); | 101 | 210 | } else { | 102 | 210 | switch (sizeof(UnsignedCppType)) { | 103 | 0 | case 1: Branch (103:13): [True: 0, False: 210]
| 104 | 0 | return val; | 105 | 0 | case 2: Branch (105:13): [True: 0, False: 210]
| 106 | 0 | return BigEndian::FromHost16(val); | 107 | 0 | case 4: Branch (107:13): [True: 0, False: 210]
| 108 | 0 | return BigEndian::FromHost32(val); | 109 | 210 | case 8: Branch (109:13): [True: 210, False: 0]
| 110 | 210 | return BigEndian::FromHost64(val); | 111 | 0 | case 16: Branch (111:13): [True: 0, False: 210]
| 112 | 0 | return BigEndian::FromHost128(val); | 113 | 0 | default: Branch (113:13): [True: 0, False: 210]
| 114 | 0 | LOG(FATAL) << "Invalid type to big endian, type=" << int(field_type) | 115 | 0 | << ", size=" << sizeof(UnsignedCppType); | 116 | 210 | } | 117 | 210 | } | 118 | 210 | } |
Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE24EvE15swap_big_endianEb Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE31EvE15swap_big_endianEj Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE32EvE15swap_big_endianEm Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE33EvE15swap_big_endianEo Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE37EvE15swap_big_endianEN4wide7integerILm256EjEE Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE38EvE15swap_big_endianEj Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE39EvE15swap_big_endianEo |
119 | | |
120 | | public: |
121 | 1.04M | static void full_encode_ascending(const void* value, std::string* buf) { |
122 | 1.04M | UnsignedCppType unsigned_val; |
123 | 1.04M | memcpy(&unsigned_val, value, sizeof(unsigned_val)); |
124 | | // swap MSB to encode integer |
125 | 1.04M | if (std::is_signed<CppType>::value) { Branch (125:13): [Folded - Ignored]
Branch (125:13): [Folded - Ignored]
Branch (125:13): [Folded - Ignored]
Branch (125:13): [Folded - Ignored]
Branch (125:13): [Folded - Ignored]
Branch (125:13): [Folded - Ignored]
Branch (125:13): [Folded - Ignored]
Branch (125:13): [Folded - Ignored]
Branch (125:13): [Folded - Ignored]
Branch (125:13): [Folded - Ignored]
Branch (125:13): [Folded - Ignored]
Branch (125:13): [Folded - Ignored]
Branch (125:13): [Folded - Ignored]
Branch (125:13): [Folded - Ignored]
Branch (125:13): [Folded - Ignored]
|
126 | 990k | unsigned_val ^= |
127 | 990k | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); |
128 | 990k | } |
129 | | // make it bigendian |
130 | 1.04M | unsigned_val = swap_big_endian(unsigned_val); |
131 | | |
132 | 1.04M | buf->append((char*)&unsigned_val, sizeof(unsigned_val)); |
133 | 1.04M | } _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE7EvE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 121 | 213 | static void full_encode_ascending(const void* value, std::string* buf) { | 122 | 213 | UnsignedCppType unsigned_val; | 123 | 213 | memcpy(&unsigned_val, value, sizeof(unsigned_val)); | 124 | | // swap MSB to encode integer | 125 | 213 | if (std::is_signed<CppType>::value) { Branch (125:13): [Folded - Ignored]
| 126 | 213 | unsigned_val ^= | 127 | 213 | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 128 | 213 | } | 129 | | // make it bigendian | 130 | 213 | unsigned_val = swap_big_endian(unsigned_val); | 131 | | | 132 | 213 | buf->append((char*)&unsigned_val, sizeof(unsigned_val)); | 133 | 213 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE5EvE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 121 | 973k | static void full_encode_ascending(const void* value, std::string* buf) { | 122 | 973k | UnsignedCppType unsigned_val; | 123 | 973k | memcpy(&unsigned_val, value, sizeof(unsigned_val)); | 124 | | // swap MSB to encode integer | 125 | 973k | if (std::is_signed<CppType>::value) { Branch (125:13): [Folded - Ignored]
| 126 | 973k | unsigned_val ^= | 127 | 973k | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 128 | 973k | } | 129 | | // make it bigendian | 130 | 973k | unsigned_val = swap_big_endian(unsigned_val); | 131 | | | 132 | 973k | buf->append((char*)&unsigned_val, sizeof(unsigned_val)); | 133 | 973k | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE1EvE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 121 | 16.0k | static void full_encode_ascending(const void* value, std::string* buf) { | 122 | 16.0k | UnsignedCppType unsigned_val; | 123 | 16.0k | memcpy(&unsigned_val, value, sizeof(unsigned_val)); | 124 | | // swap MSB to encode integer | 125 | 16.0k | if (std::is_signed<CppType>::value) { Branch (125:13): [Folded - Ignored]
| 126 | 16.0k | unsigned_val ^= | 127 | 16.0k | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 128 | 16.0k | } | 129 | | // make it bigendian | 130 | 16.0k | unsigned_val = swap_big_endian(unsigned_val); | 131 | | | 132 | 16.0k | buf->append((char*)&unsigned_val, sizeof(unsigned_val)); | 133 | 16.0k | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE3EvE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 121 | 240 | static void full_encode_ascending(const void* value, std::string* buf) { | 122 | 240 | UnsignedCppType unsigned_val; | 123 | 240 | memcpy(&unsigned_val, value, sizeof(unsigned_val)); | 124 | | // swap MSB to encode integer | 125 | 240 | if (std::is_signed<CppType>::value) { Branch (125:13): [Folded - Ignored]
| 126 | 240 | unsigned_val ^= | 127 | 240 | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 128 | 240 | } | 129 | | // make it bigendian | 130 | 240 | unsigned_val = swap_big_endian(unsigned_val); | 131 | | | 132 | 240 | buf->append((char*)&unsigned_val, sizeof(unsigned_val)); | 133 | 240 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE6EvE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 121 | 206 | static void full_encode_ascending(const void* value, std::string* buf) { | 122 | 206 | UnsignedCppType unsigned_val; | 123 | 206 | memcpy(&unsigned_val, value, sizeof(unsigned_val)); | 124 | | // swap MSB to encode integer | 125 | 206 | if (std::is_signed<CppType>::value) { Branch (125:13): [Folded - Ignored]
| 126 | 0 | unsigned_val ^= | 127 | 0 | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 128 | 0 | } | 129 | | // make it bigendian | 130 | 206 | unsigned_val = swap_big_endian(unsigned_val); | 131 | | | 132 | 206 | buf->append((char*)&unsigned_val, sizeof(unsigned_val)); | 133 | 206 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE8EvE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 121 | 50.5k | static void full_encode_ascending(const void* value, std::string* buf) { | 122 | 50.5k | UnsignedCppType unsigned_val; | 123 | 50.5k | memcpy(&unsigned_val, value, sizeof(unsigned_val)); | 124 | | // swap MSB to encode integer | 125 | 50.5k | if (std::is_signed<CppType>::value) { Branch (125:13): [Folded - Ignored]
| 126 | 0 | unsigned_val ^= | 127 | 0 | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 128 | 0 | } | 129 | | // make it bigendian | 130 | 50.5k | unsigned_val = swap_big_endian(unsigned_val); | 131 | | | 132 | 50.5k | buf->append((char*)&unsigned_val, sizeof(unsigned_val)); | 133 | 50.5k | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE9EvE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 121 | 205 | static void full_encode_ascending(const void* value, std::string* buf) { | 122 | 205 | UnsignedCppType unsigned_val; | 123 | 205 | memcpy(&unsigned_val, value, sizeof(unsigned_val)); | 124 | | // swap MSB to encode integer | 125 | 205 | if (std::is_signed<CppType>::value) { Branch (125:13): [Folded - Ignored]
| 126 | 205 | unsigned_val ^= | 127 | 205 | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 128 | 205 | } | 129 | | // make it bigendian | 130 | 205 | unsigned_val = swap_big_endian(unsigned_val); | 131 | | | 132 | 205 | buf->append((char*)&unsigned_val, sizeof(unsigned_val)); | 133 | 205 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE15EvE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 121 | 208 | static void full_encode_ascending(const void* value, std::string* buf) { | 122 | 208 | UnsignedCppType unsigned_val; | 123 | 208 | memcpy(&unsigned_val, value, sizeof(unsigned_val)); | 124 | | // swap MSB to encode integer | 125 | 208 | if (std::is_signed<CppType>::value) { Branch (125:13): [Folded - Ignored]
| 126 | 208 | unsigned_val ^= | 127 | 208 | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 128 | 208 | } | 129 | | // make it bigendian | 130 | 208 | unsigned_val = swap_big_endian(unsigned_val); | 131 | | | 132 | 208 | buf->append((char*)&unsigned_val, sizeof(unsigned_val)); | 133 | 208 | } |
Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE24EvE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE31EvE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE32EvE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE33EvE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE37EvE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE38EvE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE39EvE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE |
134 | | |
135 | 11.6k | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { |
136 | 11.6k | full_encode_ascending(value, buf); |
137 | 11.6k | } _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE1EvE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 135 | 209 | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { | 136 | 209 | full_encode_ascending(value, buf); | 137 | 209 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE3EvE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 135 | 212 | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { | 136 | 212 | full_encode_ascending(value, buf); | 137 | 212 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE5EvE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 135 | 10.2k | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { | 136 | 10.2k | full_encode_ascending(value, buf); | 137 | 10.2k | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE6EvE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 135 | 202 | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { | 136 | 202 | full_encode_ascending(value, buf); | 137 | 202 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE7EvE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 135 | 203 | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { | 136 | 203 | full_encode_ascending(value, buf); | 137 | 203 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE8EvE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 135 | 202 | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { | 136 | 202 | full_encode_ascending(value, buf); | 137 | 202 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE9EvE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 135 | 203 | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { | 136 | 203 | full_encode_ascending(value, buf); | 137 | 203 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE15EvE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 135 | 202 | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { | 136 | 202 | full_encode_ascending(value, buf); | 137 | 202 | } |
Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE24EvE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE31EvE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE32EvE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE33EvE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE37EvE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE38EvE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE39EvE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE |
138 | | |
139 | 20.3k | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { |
140 | | // decode_ascending only used in orinal index page, maybe should remove it in the future. |
141 | | // currently, we reduce the usage of this method. |
142 | 20.3k | if (encoded_key->size < sizeof(UnsignedCppType)) { Branch (142:13): [True: 0, False: 3]
Branch (142:13): [True: 0, False: 3]
Branch (142:13): [True: 0, False: 2]
Branch (142:13): [True: 0, False: 2]
Branch (142:13): [True: 0, False: 2]
Branch (142:13): [True: 0, False: 20.3k]
Branch (142:13): [True: 0, False: 2]
Branch (142:13): [True: 0, False: 2]
Branch (142:13): [True: 0, False: 0]
Branch (142:13): [True: 0, False: 0]
Branch (142:13): [True: 0, False: 0]
Branch (142:13): [True: 0, False: 0]
Branch (142:13): [True: 0, False: 0]
Branch (142:13): [True: 0, False: 0]
Branch (142:13): [True: 0, False: 0]
|
143 | 0 | return Status::InvalidArgument("Key too short, need={} vs real={}", |
144 | 0 | sizeof(UnsignedCppType), encoded_key->size); |
145 | 0 | } |
146 | 20.3k | UnsignedCppType unsigned_val; |
147 | 20.3k | memcpy(&unsigned_val, encoded_key->data, sizeof(UnsignedCppType)); |
148 | 20.3k | unsigned_val = swap_big_endian(unsigned_val); |
149 | 20.3k | if (std::is_signed<CppType>::value) { Branch (149:13): [Folded - Ignored]
Branch (149:13): [Folded - Ignored]
Branch (149:13): [Folded - Ignored]
Branch (149:13): [Folded - Ignored]
Branch (149:13): [Folded - Ignored]
Branch (149:13): [Folded - Ignored]
Branch (149:13): [Folded - Ignored]
Branch (149:13): [Folded - Ignored]
Branch (149:13): [Folded - Ignored]
Branch (149:13): [Folded - Ignored]
Branch (149:13): [Folded - Ignored]
Branch (149:13): [Folded - Ignored]
Branch (149:13): [Folded - Ignored]
Branch (149:13): [Folded - Ignored]
Branch (149:13): [Folded - Ignored]
|
150 | 14 | unsigned_val ^= |
151 | 14 | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); |
152 | 14 | } |
153 | 20.3k | memcpy(cell_ptr, &unsigned_val, sizeof(UnsignedCppType)); |
154 | 20.3k | encoded_key->remove_prefix(sizeof(UnsignedCppType)); |
155 | 20.3k | return Status::OK(); |
156 | 20.3k | } _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE7EvE16decode_ascendingEPNS_5SliceEmPh Line | Count | Source | 139 | 3 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { | 140 | | // decode_ascending only used in orinal index page, maybe should remove it in the future. | 141 | | // currently, we reduce the usage of this method. | 142 | 3 | if (encoded_key->size < sizeof(UnsignedCppType)) { Branch (142:13): [True: 0, False: 3]
| 143 | 0 | return Status::InvalidArgument("Key too short, need={} vs real={}", | 144 | 0 | sizeof(UnsignedCppType), encoded_key->size); | 145 | 0 | } | 146 | 3 | UnsignedCppType unsigned_val; | 147 | 3 | memcpy(&unsigned_val, encoded_key->data, sizeof(UnsignedCppType)); | 148 | 3 | unsigned_val = swap_big_endian(unsigned_val); | 149 | 3 | if (std::is_signed<CppType>::value) { Branch (149:13): [Folded - Ignored]
| 150 | 3 | unsigned_val ^= | 151 | 3 | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 152 | 3 | } | 153 | 3 | memcpy(cell_ptr, &unsigned_val, sizeof(UnsignedCppType)); | 154 | 3 | encoded_key->remove_prefix(sizeof(UnsignedCppType)); | 155 | 3 | return Status::OK(); | 156 | 3 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE5EvE16decode_ascendingEPNS_5SliceEmPh Line | Count | Source | 139 | 3 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { | 140 | | // decode_ascending only used in orinal index page, maybe should remove it in the future. | 141 | | // currently, we reduce the usage of this method. | 142 | 3 | if (encoded_key->size < sizeof(UnsignedCppType)) { Branch (142:13): [True: 0, False: 3]
| 143 | 0 | return Status::InvalidArgument("Key too short, need={} vs real={}", | 144 | 0 | sizeof(UnsignedCppType), encoded_key->size); | 145 | 0 | } | 146 | 3 | UnsignedCppType unsigned_val; | 147 | 3 | memcpy(&unsigned_val, encoded_key->data, sizeof(UnsignedCppType)); | 148 | 3 | unsigned_val = swap_big_endian(unsigned_val); | 149 | 3 | if (std::is_signed<CppType>::value) { Branch (149:13): [Folded - Ignored]
| 150 | 3 | unsigned_val ^= | 151 | 3 | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 152 | 3 | } | 153 | 3 | memcpy(cell_ptr, &unsigned_val, sizeof(UnsignedCppType)); | 154 | 3 | encoded_key->remove_prefix(sizeof(UnsignedCppType)); | 155 | 3 | return Status::OK(); | 156 | 3 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE1EvE16decode_ascendingEPNS_5SliceEmPh Line | Count | Source | 139 | 2 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { | 140 | | // decode_ascending only used in orinal index page, maybe should remove it in the future. | 141 | | // currently, we reduce the usage of this method. | 142 | 2 | if (encoded_key->size < sizeof(UnsignedCppType)) { Branch (142:13): [True: 0, False: 2]
| 143 | 0 | return Status::InvalidArgument("Key too short, need={} vs real={}", | 144 | 0 | sizeof(UnsignedCppType), encoded_key->size); | 145 | 0 | } | 146 | 2 | UnsignedCppType unsigned_val; | 147 | 2 | memcpy(&unsigned_val, encoded_key->data, sizeof(UnsignedCppType)); | 148 | 2 | unsigned_val = swap_big_endian(unsigned_val); | 149 | 2 | if (std::is_signed<CppType>::value) { Branch (149:13): [Folded - Ignored]
| 150 | 2 | unsigned_val ^= | 151 | 2 | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 152 | 2 | } | 153 | 2 | memcpy(cell_ptr, &unsigned_val, sizeof(UnsignedCppType)); | 154 | 2 | encoded_key->remove_prefix(sizeof(UnsignedCppType)); | 155 | 2 | return Status::OK(); | 156 | 2 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE3EvE16decode_ascendingEPNS_5SliceEmPh Line | Count | Source | 139 | 2 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { | 140 | | // decode_ascending only used in orinal index page, maybe should remove it in the future. | 141 | | // currently, we reduce the usage of this method. | 142 | 2 | if (encoded_key->size < sizeof(UnsignedCppType)) { Branch (142:13): [True: 0, False: 2]
| 143 | 0 | return Status::InvalidArgument("Key too short, need={} vs real={}", | 144 | 0 | sizeof(UnsignedCppType), encoded_key->size); | 145 | 0 | } | 146 | 2 | UnsignedCppType unsigned_val; | 147 | 2 | memcpy(&unsigned_val, encoded_key->data, sizeof(UnsignedCppType)); | 148 | 2 | unsigned_val = swap_big_endian(unsigned_val); | 149 | 2 | if (std::is_signed<CppType>::value) { Branch (149:13): [Folded - Ignored]
| 150 | 2 | unsigned_val ^= | 151 | 2 | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 152 | 2 | } | 153 | 2 | memcpy(cell_ptr, &unsigned_val, sizeof(UnsignedCppType)); | 154 | 2 | encoded_key->remove_prefix(sizeof(UnsignedCppType)); | 155 | 2 | return Status::OK(); | 156 | 2 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE6EvE16decode_ascendingEPNS_5SliceEmPh Line | Count | Source | 139 | 2 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { | 140 | | // decode_ascending only used in orinal index page, maybe should remove it in the future. | 141 | | // currently, we reduce the usage of this method. | 142 | 2 | if (encoded_key->size < sizeof(UnsignedCppType)) { Branch (142:13): [True: 0, False: 2]
| 143 | 0 | return Status::InvalidArgument("Key too short, need={} vs real={}", | 144 | 0 | sizeof(UnsignedCppType), encoded_key->size); | 145 | 0 | } | 146 | 2 | UnsignedCppType unsigned_val; | 147 | 2 | memcpy(&unsigned_val, encoded_key->data, sizeof(UnsignedCppType)); | 148 | 2 | unsigned_val = swap_big_endian(unsigned_val); | 149 | 2 | if (std::is_signed<CppType>::value) { Branch (149:13): [Folded - Ignored]
| 150 | 0 | unsigned_val ^= | 151 | 0 | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 152 | 0 | } | 153 | 2 | memcpy(cell_ptr, &unsigned_val, sizeof(UnsignedCppType)); | 154 | 2 | encoded_key->remove_prefix(sizeof(UnsignedCppType)); | 155 | 2 | return Status::OK(); | 156 | 2 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE8EvE16decode_ascendingEPNS_5SliceEmPh Line | Count | Source | 139 | 20.3k | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { | 140 | | // decode_ascending only used in orinal index page, maybe should remove it in the future. | 141 | | // currently, we reduce the usage of this method. | 142 | 20.3k | if (encoded_key->size < sizeof(UnsignedCppType)) { Branch (142:13): [True: 0, False: 20.3k]
| 143 | 0 | return Status::InvalidArgument("Key too short, need={} vs real={}", | 144 | 0 | sizeof(UnsignedCppType), encoded_key->size); | 145 | 0 | } | 146 | 20.3k | UnsignedCppType unsigned_val; | 147 | 20.3k | memcpy(&unsigned_val, encoded_key->data, sizeof(UnsignedCppType)); | 148 | 20.3k | unsigned_val = swap_big_endian(unsigned_val); | 149 | 20.3k | if (std::is_signed<CppType>::value) { Branch (149:13): [Folded - Ignored]
| 150 | 0 | unsigned_val ^= | 151 | 0 | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 152 | 0 | } | 153 | 20.3k | memcpy(cell_ptr, &unsigned_val, sizeof(UnsignedCppType)); | 154 | 20.3k | encoded_key->remove_prefix(sizeof(UnsignedCppType)); | 155 | 20.3k | return Status::OK(); | 156 | 20.3k | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE9EvE16decode_ascendingEPNS_5SliceEmPh Line | Count | Source | 139 | 2 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { | 140 | | // decode_ascending only used in orinal index page, maybe should remove it in the future. | 141 | | // currently, we reduce the usage of this method. | 142 | 2 | if (encoded_key->size < sizeof(UnsignedCppType)) { Branch (142:13): [True: 0, False: 2]
| 143 | 0 | return Status::InvalidArgument("Key too short, need={} vs real={}", | 144 | 0 | sizeof(UnsignedCppType), encoded_key->size); | 145 | 0 | } | 146 | 2 | UnsignedCppType unsigned_val; | 147 | 2 | memcpy(&unsigned_val, encoded_key->data, sizeof(UnsignedCppType)); | 148 | 2 | unsigned_val = swap_big_endian(unsigned_val); | 149 | 2 | if (std::is_signed<CppType>::value) { Branch (149:13): [Folded - Ignored]
| 150 | 2 | unsigned_val ^= | 151 | 2 | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 152 | 2 | } | 153 | 2 | memcpy(cell_ptr, &unsigned_val, sizeof(UnsignedCppType)); | 154 | 2 | encoded_key->remove_prefix(sizeof(UnsignedCppType)); | 155 | 2 | return Status::OK(); | 156 | 2 | } |
_ZN5doris14KeyCoderTraitsILNS_9FieldTypeE15EvE16decode_ascendingEPNS_5SliceEmPh Line | Count | Source | 139 | 2 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { | 140 | | // decode_ascending only used in orinal index page, maybe should remove it in the future. | 141 | | // currently, we reduce the usage of this method. | 142 | 2 | if (encoded_key->size < sizeof(UnsignedCppType)) { Branch (142:13): [True: 0, False: 2]
| 143 | 0 | return Status::InvalidArgument("Key too short, need={} vs real={}", | 144 | 0 | sizeof(UnsignedCppType), encoded_key->size); | 145 | 0 | } | 146 | 2 | UnsignedCppType unsigned_val; | 147 | 2 | memcpy(&unsigned_val, encoded_key->data, sizeof(UnsignedCppType)); | 148 | 2 | unsigned_val = swap_big_endian(unsigned_val); | 149 | 2 | if (std::is_signed<CppType>::value) { Branch (149:13): [Folded - Ignored]
| 150 | 2 | unsigned_val ^= | 151 | 2 | (static_cast<UnsignedCppType>(1) << (sizeof(UnsignedCppType) * CHAR_BIT - 1)); | 152 | 2 | } | 153 | 2 | memcpy(cell_ptr, &unsigned_val, sizeof(UnsignedCppType)); | 154 | 2 | encoded_key->remove_prefix(sizeof(UnsignedCppType)); | 155 | 2 | return Status::OK(); | 156 | 2 | } |
Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE24EvE16decode_ascendingEPNS_5SliceEmPh Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE31EvE16decode_ascendingEPNS_5SliceEmPh Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE32EvE16decode_ascendingEPNS_5SliceEmPh Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE33EvE16decode_ascendingEPNS_5SliceEmPh Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE37EvE16decode_ascendingEPNS_5SliceEmPh Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE38EvE16decode_ascendingEPNS_5SliceEmPh Unexecuted instantiation: _ZN5doris14KeyCoderTraitsILNS_9FieldTypeE39EvE16decode_ascendingEPNS_5SliceEmPh |
157 | | }; |
158 | | |
159 | | template <> |
160 | | class KeyCoderTraits<FieldType::OLAP_FIELD_TYPE_DATE> { |
161 | | public: |
162 | | using CppType = typename CppTypeTraits<FieldType::OLAP_FIELD_TYPE_DATE>::CppType; |
163 | | using UnsignedCppType = |
164 | | typename CppTypeTraits<FieldType::OLAP_FIELD_TYPE_DATE>::UnsignedCppType; |
165 | | |
166 | | public: |
167 | 209 | static void full_encode_ascending(const void* value, std::string* buf) { |
168 | 209 | UnsignedCppType unsigned_val; |
169 | 209 | memcpy(&unsigned_val, value, sizeof(unsigned_val)); |
170 | | // make it bigendian |
171 | 209 | unsigned_val = BigEndian::FromHost24(unsigned_val); |
172 | 209 | buf->append((char*)&unsigned_val, sizeof(unsigned_val)); |
173 | 209 | } |
174 | | |
175 | 203 | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { |
176 | 203 | full_encode_ascending(value, buf); |
177 | 203 | } |
178 | | |
179 | 2 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { |
180 | 2 | if (encoded_key->size < sizeof(UnsignedCppType)) { Branch (180:13): [True: 0, False: 2]
|
181 | 0 | return Status::InvalidArgument("Key too short, need={} vs real={}", |
182 | 0 | sizeof(UnsignedCppType), encoded_key->size); |
183 | 0 | } |
184 | 2 | UnsignedCppType unsigned_val; |
185 | 2 | memcpy(&unsigned_val, encoded_key->data, sizeof(UnsignedCppType)); |
186 | 2 | unsigned_val = BigEndian::FromHost24(unsigned_val); |
187 | 2 | memcpy(cell_ptr, &unsigned_val, sizeof(UnsignedCppType)); |
188 | 2 | encoded_key->remove_prefix(sizeof(UnsignedCppType)); |
189 | 2 | return Status::OK(); |
190 | 2 | } |
191 | | }; |
192 | | |
193 | | template <> |
194 | | class KeyCoderTraits<FieldType::OLAP_FIELD_TYPE_DATEV2> { |
195 | | public: |
196 | | using CppType = typename CppTypeTraits<FieldType::OLAP_FIELD_TYPE_DATEV2>::CppType; |
197 | | using UnsignedCppType = |
198 | | typename CppTypeTraits<FieldType::OLAP_FIELD_TYPE_DATEV2>::UnsignedCppType; |
199 | | |
200 | | public: |
201 | 2 | static void full_encode_ascending(const void* value, std::string* buf) { |
202 | 2 | UnsignedCppType unsigned_val; |
203 | 2 | memcpy(&unsigned_val, value, sizeof(unsigned_val)); |
204 | | // make it bigendian |
205 | 2 | unsigned_val = BigEndian::FromHost32(unsigned_val); |
206 | 2 | buf->append((char*)&unsigned_val, sizeof(unsigned_val)); |
207 | 2 | } |
208 | | |
209 | 0 | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { |
210 | 0 | full_encode_ascending(value, buf); |
211 | 0 | } |
212 | | |
213 | 0 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { |
214 | 0 | if (encoded_key->size < sizeof(UnsignedCppType)) { Branch (214:13): [True: 0, False: 0]
|
215 | 0 | return Status::InvalidArgument(Substitute("Key too short, need=$0 vs real=$1", |
216 | 0 | sizeof(UnsignedCppType), encoded_key->size)); |
217 | 0 | } |
218 | 0 | UnsignedCppType unsigned_val; |
219 | 0 | memcpy(&unsigned_val, encoded_key->data, sizeof(UnsignedCppType)); |
220 | 0 | unsigned_val = BigEndian::FromHost32(unsigned_val); |
221 | 0 | memcpy(cell_ptr, &unsigned_val, sizeof(UnsignedCppType)); |
222 | 0 | encoded_key->remove_prefix(sizeof(UnsignedCppType)); |
223 | 0 | return Status::OK(); |
224 | 0 | } |
225 | | }; |
226 | | |
227 | | template <> |
228 | | class KeyCoderTraits<FieldType::OLAP_FIELD_TYPE_DATETIMEV2> { |
229 | | public: |
230 | | using CppType = typename CppTypeTraits<FieldType::OLAP_FIELD_TYPE_DATETIMEV2>::CppType; |
231 | | using UnsignedCppType = |
232 | | typename CppTypeTraits<FieldType::OLAP_FIELD_TYPE_DATETIMEV2>::UnsignedCppType; |
233 | | |
234 | | public: |
235 | 0 | static void full_encode_ascending(const void* value, std::string* buf) { |
236 | 0 | UnsignedCppType unsigned_val; |
237 | 0 | memcpy(&unsigned_val, value, sizeof(unsigned_val)); |
238 | | // make it bigendian |
239 | 0 | unsigned_val = BigEndian::FromHost64(unsigned_val); |
240 | 0 | buf->append((char*)&unsigned_val, sizeof(unsigned_val)); |
241 | 0 | } |
242 | | |
243 | 0 | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { |
244 | 0 | full_encode_ascending(value, buf); |
245 | 0 | } |
246 | | |
247 | 0 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { |
248 | 0 | if (encoded_key->size < sizeof(UnsignedCppType)) { Branch (248:13): [True: 0, False: 0]
|
249 | 0 | return Status::InvalidArgument(Substitute("Key too short, need=$0 vs real=$1", |
250 | 0 | sizeof(UnsignedCppType), encoded_key->size)); |
251 | 0 | } |
252 | 0 | UnsignedCppType unsigned_val; |
253 | 0 | memcpy(&unsigned_val, encoded_key->data, sizeof(UnsignedCppType)); |
254 | 0 | unsigned_val = BigEndian::FromHost64(unsigned_val); |
255 | 0 | memcpy(cell_ptr, &unsigned_val, sizeof(UnsignedCppType)); |
256 | 0 | encoded_key->remove_prefix(sizeof(UnsignedCppType)); |
257 | 0 | return Status::OK(); |
258 | 0 | } |
259 | | }; |
260 | | |
261 | | template <> |
262 | | class KeyCoderTraits<FieldType::OLAP_FIELD_TYPE_DECIMAL> { |
263 | | public: |
264 | 6 | static void full_encode_ascending(const void* value, std::string* buf) { |
265 | 6 | decimal12_t decimal_val; |
266 | 6 | memcpy(&decimal_val, value, sizeof(decimal12_t)); |
267 | 6 | KeyCoderTraits<FieldType::OLAP_FIELD_TYPE_BIGINT>::full_encode_ascending( |
268 | 6 | &decimal_val.integer, buf); |
269 | 6 | KeyCoderTraits<FieldType::OLAP_FIELD_TYPE_INT>::full_encode_ascending(&decimal_val.fraction, |
270 | 6 | buf); |
271 | 6 | } // namespace doris |
272 | | |
273 | 4 | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { |
274 | 4 | full_encode_ascending(value, buf); |
275 | 4 | } |
276 | | |
277 | 1 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { |
278 | 1 | decimal12_t decimal_val = {0, 0}; |
279 | 1 | RETURN_IF_ERROR(KeyCoderTraits<FieldType::OLAP_FIELD_TYPE_BIGINT>::decode_ascending( Line | Count | Source | 637 | 1 | do { \ | 638 | 1 | Status _status_ = (stmt); \ | 639 | 1 | if (UNLIKELY(!_status_.ok())) { \ Line | Count | Source | 36 | 1 | #define UNLIKELY(expr) __builtin_expect(!!(expr), 0) Branch (36:24): [True: 0, False: 1]
|
| 640 | 0 | return _status_; \ | 641 | 0 | } \ | 642 | 1 | } while (false) Branch (642:14): [Folded - Ignored]
|
|
280 | 1 | encoded_key, sizeof(decimal_val.integer), (uint8_t*)&decimal_val.integer)); |
281 | 1 | RETURN_IF_ERROR(KeyCoderTraits<FieldType::OLAP_FIELD_TYPE_INT>::decode_ascending( Line | Count | Source | 637 | 1 | do { \ | 638 | 1 | Status _status_ = (stmt); \ | 639 | 1 | if (UNLIKELY(!_status_.ok())) { \ Line | Count | Source | 36 | 1 | #define UNLIKELY(expr) __builtin_expect(!!(expr), 0) Branch (36:24): [True: 0, False: 1]
|
| 640 | 0 | return _status_; \ | 641 | 0 | } \ | 642 | 1 | } while (false) Branch (642:14): [Folded - Ignored]
|
|
282 | 1 | encoded_key, sizeof(decimal_val.fraction), (uint8_t*)&decimal_val.fraction)); |
283 | 1 | memcpy(cell_ptr, &decimal_val, sizeof(decimal12_t)); |
284 | 1 | return Status::OK(); |
285 | 1 | } |
286 | | }; |
287 | | |
288 | | template <> |
289 | | class KeyCoderTraits<FieldType::OLAP_FIELD_TYPE_CHAR> { |
290 | | public: |
291 | 2 | static void full_encode_ascending(const void* value, std::string* buf) { |
292 | 2 | auto slice = reinterpret_cast<const Slice*>(value); |
293 | 2 | buf->append(slice->get_data(), slice->get_size()); |
294 | 2 | } |
295 | | |
296 | 2 | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { |
297 | 2 | const Slice* slice = (const Slice*)value; |
298 | 2 | CHECK(index_size <= slice->size) |
299 | 0 | << "index size is larger than char size, index=" << index_size |
300 | 0 | << ", char=" << slice->size; |
301 | 2 | buf->append(slice->data, index_size); |
302 | 2 | } |
303 | | |
304 | 0 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { |
305 | 0 | LOG(FATAL) << "decode_ascending is not implemented"; |
306 | 0 | return Status::OK(); |
307 | 0 | } |
308 | | }; |
309 | | |
310 | | template <> |
311 | | class KeyCoderTraits<FieldType::OLAP_FIELD_TYPE_VARCHAR> { |
312 | | public: |
313 | 477 | static void full_encode_ascending(const void* value, std::string* buf) { |
314 | 477 | auto slice = reinterpret_cast<const Slice*>(value); |
315 | 477 | buf->append(slice->get_data(), slice->get_size()); |
316 | 477 | } |
317 | | |
318 | 135 | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { |
319 | 135 | const Slice* slice = (const Slice*)value; |
320 | 135 | size_t copy_size = std::min(index_size, slice->size); |
321 | 135 | buf->append(slice->data, copy_size); |
322 | 135 | } |
323 | | |
324 | 0 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { |
325 | 0 | LOG(FATAL) << "decode_ascending is not implemented"; |
326 | 0 | return Status::OK(); |
327 | 0 | } |
328 | | }; |
329 | | |
330 | | template <> |
331 | | class KeyCoderTraits<FieldType::OLAP_FIELD_TYPE_STRING> { |
332 | | public: |
333 | 884 | static void full_encode_ascending(const void* value, std::string* buf) { |
334 | 884 | auto slice = reinterpret_cast<const Slice*>(value); |
335 | 884 | buf->append(slice->get_data(), slice->get_size()); |
336 | 884 | } |
337 | | |
338 | 0 | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { |
339 | 0 | const Slice* slice = (const Slice*)value; |
340 | 0 | size_t copy_size = std::min(index_size, slice->size); |
341 | 0 | buf->append(slice->data, copy_size); |
342 | 0 | } |
343 | | |
344 | 0 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { |
345 | 0 | LOG(FATAL) << "decode_ascending is not implemented"; |
346 | 0 | return Status::OK(); |
347 | 0 | } |
348 | | }; |
349 | | |
350 | | template <FieldType field_type> |
351 | | class KeyCoderTraitsForFloat { |
352 | | public: |
353 | | using CppType = typename CppTypeTraits<field_type>::CppType; |
354 | | using UnsignedCppType = typename CppTypeTraits<field_type>::UnsignedCppType; |
355 | | |
356 | 404 | static UnsignedCppType encode_float(CppType value) { |
357 | 404 | return sortable_float_bits(float_to_int_bits(value)); |
358 | 404 | } _ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE10EE12encode_floatEf Line | Count | Source | 356 | 202 | static UnsignedCppType encode_float(CppType value) { | 357 | 202 | return sortable_float_bits(float_to_int_bits(value)); | 358 | 202 | } |
_ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE11EE12encode_floatEd Line | Count | Source | 356 | 202 | static UnsignedCppType encode_float(CppType value) { | 357 | 202 | return sortable_float_bits(float_to_int_bits(value)); | 358 | 202 | } |
|
359 | | |
360 | 14 | static CppType decode_float(UnsignedCppType sortable_bits) { |
361 | 14 | return int_bits_to_float(unsortable_float_bits(sortable_bits)); |
362 | 14 | } _ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE10EE12decode_floatEj Line | Count | Source | 360 | 7 | static CppType decode_float(UnsignedCppType sortable_bits) { | 361 | 7 | return int_bits_to_float(unsortable_float_bits(sortable_bits)); | 362 | 7 | } |
_ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE11EE12decode_floatEm Line | Count | Source | 360 | 7 | static CppType decode_float(UnsignedCppType sortable_bits) { | 361 | 7 | return int_bits_to_float(unsortable_float_bits(sortable_bits)); | 362 | 7 | } |
|
363 | | |
364 | | // -infinity < -100.0 < -1.0 < -0.0 < 0.0 < 1.0 < 100.0 < infinity < NaN |
365 | 404 | static void full_encode_ascending(const void* value, std::string* buf) { |
366 | 404 | CppType val; |
367 | 404 | std::memcpy(&val, value, sizeof(CppType)); |
368 | 404 | UnsignedCppType sortable_val = encode_float(val); |
369 | 404 | constexpr UnsignedCppType sign_bit = UnsignedCppType(1) |
370 | 404 | << (sizeof(UnsignedCppType) * 8 - 1); |
371 | 404 | sortable_val ^= sign_bit; |
372 | 404 | if constexpr (sizeof(UnsignedCppType) == 4) { Branch (372:23): [Folded - Ignored]
Branch (372:23): [Folded - Ignored]
|
373 | 202 | sortable_val = BigEndian::FromHost32(sortable_val); |
374 | 202 | } else if constexpr (sizeof(UnsignedCppType) == 8) { Branch (374:30): [Folded - Ignored]
|
375 | 202 | sortable_val = BigEndian::FromHost64(sortable_val); |
376 | 202 | } |
377 | 404 | buf->append(reinterpret_cast<const char*>(&sortable_val), sizeof(UnsignedCppType)); |
378 | 404 | } _ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE10EE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 365 | 202 | static void full_encode_ascending(const void* value, std::string* buf) { | 366 | 202 | CppType val; | 367 | 202 | std::memcpy(&val, value, sizeof(CppType)); | 368 | 202 | UnsignedCppType sortable_val = encode_float(val); | 369 | 202 | constexpr UnsignedCppType sign_bit = UnsignedCppType(1) | 370 | 202 | << (sizeof(UnsignedCppType) * 8 - 1); | 371 | 202 | sortable_val ^= sign_bit; | 372 | 202 | if constexpr (sizeof(UnsignedCppType) == 4) { Branch (372:23): [Folded - Ignored]
| 373 | 202 | sortable_val = BigEndian::FromHost32(sortable_val); | 374 | 202 | } else if constexpr (sizeof(UnsignedCppType) == 8) { | 375 | 202 | sortable_val = BigEndian::FromHost64(sortable_val); | 376 | 202 | } | 377 | 202 | buf->append(reinterpret_cast<const char*>(&sortable_val), sizeof(UnsignedCppType)); | 378 | 202 | } |
_ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE11EE21full_encode_ascendingEPKvPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 365 | 202 | static void full_encode_ascending(const void* value, std::string* buf) { | 366 | 202 | CppType val; | 367 | 202 | std::memcpy(&val, value, sizeof(CppType)); | 368 | 202 | UnsignedCppType sortable_val = encode_float(val); | 369 | 202 | constexpr UnsignedCppType sign_bit = UnsignedCppType(1) | 370 | 202 | << (sizeof(UnsignedCppType) * 8 - 1); | 371 | 202 | sortable_val ^= sign_bit; | 372 | 202 | if constexpr (sizeof(UnsignedCppType) == 4) { Branch (372:23): [Folded - Ignored]
| 373 | 202 | sortable_val = BigEndian::FromHost32(sortable_val); | 374 | 202 | } else if constexpr (sizeof(UnsignedCppType) == 8) { Branch (374:30): [Folded - Ignored]
| 375 | 202 | sortable_val = BigEndian::FromHost64(sortable_val); | 376 | 202 | } | 377 | 202 | buf->append(reinterpret_cast<const char*>(&sortable_val), sizeof(UnsignedCppType)); | 378 | 202 | } |
|
379 | | |
380 | 0 | static void encode_ascending(const void* value, size_t index_size, std::string* buf) { |
381 | 0 | full_encode_ascending(value, buf); |
382 | 0 | } Unexecuted instantiation: _ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE10EE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Unexecuted instantiation: _ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE11EE16encode_ascendingEPKvmPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE |
383 | | |
384 | 14 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { |
385 | 14 | if (encoded_key->size < sizeof(UnsignedCppType)) { Branch (385:13): [True: 0, False: 7]
Branch (385:13): [True: 0, False: 7]
|
386 | 0 | return Status::InvalidArgument(absl::Substitute("Key too short, need=$0 vs real=$1", |
387 | 0 | sizeof(UnsignedCppType), |
388 | 0 | encoded_key->size)); |
389 | 0 | } |
390 | 14 | UnsignedCppType sortable_val; |
391 | 14 | std::memcpy(&sortable_val, encoded_key->data, sizeof(UnsignedCppType)); |
392 | 14 | if constexpr (sizeof(UnsignedCppType) == 4) { Branch (392:23): [Folded - Ignored]
Branch (392:23): [Folded - Ignored]
|
393 | 7 | sortable_val = BigEndian::FromHost32(sortable_val); |
394 | 7 | } else if constexpr (sizeof(UnsignedCppType) == 8) { Branch (394:30): [Folded - Ignored]
|
395 | 7 | sortable_val = BigEndian::FromHost64(sortable_val); |
396 | 7 | } |
397 | 14 | constexpr UnsignedCppType sign_bit = UnsignedCppType(1) |
398 | 14 | << (sizeof(UnsignedCppType) * 8 - 1); |
399 | 14 | sortable_val ^= sign_bit; |
400 | 14 | CppType val = decode_float(sortable_val); |
401 | 14 | std::memcpy(cell_ptr, &val, sizeof(CppType)); |
402 | 14 | encoded_key->remove_prefix(sizeof(UnsignedCppType)); |
403 | 14 | return Status::OK(); |
404 | 14 | } _ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE10EE16decode_ascendingEPNS_5SliceEmPh Line | Count | Source | 384 | 7 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { | 385 | 7 | if (encoded_key->size < sizeof(UnsignedCppType)) { Branch (385:13): [True: 0, False: 7]
| 386 | 0 | return Status::InvalidArgument(absl::Substitute("Key too short, need=$0 vs real=$1", | 387 | 0 | sizeof(UnsignedCppType), | 388 | 0 | encoded_key->size)); | 389 | 0 | } | 390 | 7 | UnsignedCppType sortable_val; | 391 | 7 | std::memcpy(&sortable_val, encoded_key->data, sizeof(UnsignedCppType)); | 392 | 7 | if constexpr (sizeof(UnsignedCppType) == 4) { Branch (392:23): [Folded - Ignored]
| 393 | 7 | sortable_val = BigEndian::FromHost32(sortable_val); | 394 | 7 | } else if constexpr (sizeof(UnsignedCppType) == 8) { | 395 | 7 | sortable_val = BigEndian::FromHost64(sortable_val); | 396 | 7 | } | 397 | 7 | constexpr UnsignedCppType sign_bit = UnsignedCppType(1) | 398 | 7 | << (sizeof(UnsignedCppType) * 8 - 1); | 399 | 7 | sortable_val ^= sign_bit; | 400 | 7 | CppType val = decode_float(sortable_val); | 401 | 7 | std::memcpy(cell_ptr, &val, sizeof(CppType)); | 402 | 7 | encoded_key->remove_prefix(sizeof(UnsignedCppType)); | 403 | 7 | return Status::OK(); | 404 | 7 | } |
_ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE11EE16decode_ascendingEPNS_5SliceEmPh Line | Count | Source | 384 | 7 | static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { | 385 | 7 | if (encoded_key->size < sizeof(UnsignedCppType)) { Branch (385:13): [True: 0, False: 7]
| 386 | 0 | return Status::InvalidArgument(absl::Substitute("Key too short, need=$0 vs real=$1", | 387 | 0 | sizeof(UnsignedCppType), | 388 | 0 | encoded_key->size)); | 389 | 0 | } | 390 | 7 | UnsignedCppType sortable_val; | 391 | 7 | std::memcpy(&sortable_val, encoded_key->data, sizeof(UnsignedCppType)); | 392 | 7 | if constexpr (sizeof(UnsignedCppType) == 4) { Branch (392:23): [Folded - Ignored]
| 393 | 7 | sortable_val = BigEndian::FromHost32(sortable_val); | 394 | 7 | } else if constexpr (sizeof(UnsignedCppType) == 8) { Branch (394:30): [Folded - Ignored]
| 395 | 7 | sortable_val = BigEndian::FromHost64(sortable_val); | 396 | 7 | } | 397 | 7 | constexpr UnsignedCppType sign_bit = UnsignedCppType(1) | 398 | 7 | << (sizeof(UnsignedCppType) * 8 - 1); | 399 | 7 | sortable_val ^= sign_bit; | 400 | 7 | CppType val = decode_float(sortable_val); | 401 | 7 | std::memcpy(cell_ptr, &val, sizeof(CppType)); | 402 | 7 | encoded_key->remove_prefix(sizeof(UnsignedCppType)); | 403 | 7 | return Status::OK(); | 404 | 7 | } |
|
405 | | |
406 | | private: |
407 | 404 | static UnsignedCppType float_to_int_bits(CppType value) { |
408 | 404 | if (std::isnan(value)) { Branch (408:13): [True: 22, False: 180]
Branch (408:13): [True: 22, False: 180]
|
409 | 44 | if constexpr (std::is_same_v<CppType, float>) { Branch (409:27): [Folded - Ignored]
Branch (409:27): [Folded - Ignored]
|
410 | 22 | return 0x7FC00000U; |
411 | 22 | } else { |
412 | 22 | return 0x7FF8000000000000ULL; |
413 | 22 | } |
414 | 44 | } |
415 | | |
416 | 360 | UnsignedCppType result; |
417 | 360 | std::memcpy(&result, &value, sizeof(CppType)); |
418 | 360 | return result; |
419 | 404 | } _ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE10EE17float_to_int_bitsEf Line | Count | Source | 407 | 202 | static UnsignedCppType float_to_int_bits(CppType value) { | 408 | 202 | if (std::isnan(value)) { Branch (408:13): [True: 22, False: 180]
| 409 | 22 | if constexpr (std::is_same_v<CppType, float>) { Branch (409:27): [Folded - Ignored]
| 410 | 22 | return 0x7FC00000U; | 411 | 22 | } else { | 412 | 22 | return 0x7FF8000000000000ULL; | 413 | 22 | } | 414 | 22 | } | 415 | | | 416 | 180 | UnsignedCppType result; | 417 | 180 | std::memcpy(&result, &value, sizeof(CppType)); | 418 | 180 | return result; | 419 | 202 | } |
_ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE11EE17float_to_int_bitsEd Line | Count | Source | 407 | 202 | static UnsignedCppType float_to_int_bits(CppType value) { | 408 | 202 | if (std::isnan(value)) { Branch (408:13): [True: 22, False: 180]
| 409 | 22 | if constexpr (std::is_same_v<CppType, float>) { Branch (409:27): [Folded - Ignored]
| 410 | 22 | return 0x7FC00000U; | 411 | 22 | } else { | 412 | 22 | return 0x7FF8000000000000ULL; | 413 | 22 | } | 414 | 22 | } | 415 | | | 416 | 180 | UnsignedCppType result; | 417 | 180 | std::memcpy(&result, &value, sizeof(CppType)); | 418 | 180 | return result; | 419 | 202 | } |
|
420 | | |
421 | 418 | static UnsignedCppType sortable_float_bits(UnsignedCppType bits) { |
422 | 418 | constexpr int32_t shift = sizeof(UnsignedCppType) * 8 - 1; |
423 | 418 | constexpr UnsignedCppType sign_bit = static_cast<UnsignedCppType>(1) << shift; |
424 | 418 | if ((bits & sign_bit) != 0) { Branch (424:13): [True: 91, False: 118]
Branch (424:13): [True: 91, False: 118]
|
425 | 182 | return bits ^ (sign_bit - 1); |
426 | 236 | } else { |
427 | 236 | return bits; |
428 | 236 | } |
429 | 418 | } _ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE10EE19sortable_float_bitsEj Line | Count | Source | 421 | 209 | static UnsignedCppType sortable_float_bits(UnsignedCppType bits) { | 422 | 209 | constexpr int32_t shift = sizeof(UnsignedCppType) * 8 - 1; | 423 | 209 | constexpr UnsignedCppType sign_bit = static_cast<UnsignedCppType>(1) << shift; | 424 | 209 | if ((bits & sign_bit) != 0) { Branch (424:13): [True: 91, False: 118]
| 425 | 91 | return bits ^ (sign_bit - 1); | 426 | 118 | } else { | 427 | 118 | return bits; | 428 | 118 | } | 429 | 209 | } |
_ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE11EE19sortable_float_bitsEm Line | Count | Source | 421 | 209 | static UnsignedCppType sortable_float_bits(UnsignedCppType bits) { | 422 | 209 | constexpr int32_t shift = sizeof(UnsignedCppType) * 8 - 1; | 423 | 209 | constexpr UnsignedCppType sign_bit = static_cast<UnsignedCppType>(1) << shift; | 424 | 209 | if ((bits & sign_bit) != 0) { Branch (424:13): [True: 91, False: 118]
| 425 | 91 | return bits ^ (sign_bit - 1); | 426 | 118 | } else { | 427 | 118 | return bits; | 428 | 118 | } | 429 | 209 | } |
|
430 | | |
431 | 14 | static CppType int_bits_to_float(UnsignedCppType bits) { |
432 | 14 | CppType result; |
433 | 14 | std::memcpy(&result, &bits, sizeof(CppType)); |
434 | 14 | return result; |
435 | 14 | } _ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE10EE17int_bits_to_floatEj Line | Count | Source | 431 | 7 | static CppType int_bits_to_float(UnsignedCppType bits) { | 432 | 7 | CppType result; | 433 | 7 | std::memcpy(&result, &bits, sizeof(CppType)); | 434 | 7 | return result; | 435 | 7 | } |
_ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE11EE17int_bits_to_floatEm Line | Count | Source | 431 | 7 | static CppType int_bits_to_float(UnsignedCppType bits) { | 432 | 7 | CppType result; | 433 | 7 | std::memcpy(&result, &bits, sizeof(CppType)); | 434 | 7 | return result; | 435 | 7 | } |
|
436 | | |
437 | 14 | static UnsignedCppType unsortable_float_bits(UnsignedCppType sortable_bits) { |
438 | 14 | return sortable_float_bits(sortable_bits); |
439 | 14 | } _ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE10EE21unsortable_float_bitsEj Line | Count | Source | 437 | 7 | static UnsignedCppType unsortable_float_bits(UnsignedCppType sortable_bits) { | 438 | 7 | return sortable_float_bits(sortable_bits); | 439 | 7 | } |
_ZN5doris22KeyCoderTraitsForFloatILNS_9FieldTypeE11EE21unsortable_float_bitsEm Line | Count | Source | 437 | 7 | static UnsignedCppType unsortable_float_bits(UnsignedCppType sortable_bits) { | 438 | 7 | return sortable_float_bits(sortable_bits); | 439 | 7 | } |
|
440 | | }; |
441 | | |
442 | | template <> |
443 | | class KeyCoderTraits<FieldType::OLAP_FIELD_TYPE_FLOAT> |
444 | | : public KeyCoderTraitsForFloat<FieldType::OLAP_FIELD_TYPE_FLOAT> {}; |
445 | | |
446 | | template <> |
447 | | class KeyCoderTraits<FieldType::OLAP_FIELD_TYPE_DOUBLE> |
448 | | : public KeyCoderTraitsForFloat<FieldType::OLAP_FIELD_TYPE_DOUBLE> {}; |
449 | | |
450 | | } // namespace doris |