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