Coverage Report

Created: 2025-07-28 21:04

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