YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/common/key_encoder.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
// The following only applies to changes made to this file as part of YugaByte development.
19
//
20
// Portions Copyright (c) YugaByte, Inc.
21
//
22
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
23
// in compliance with the License.  You may obtain a copy of the License at
24
//
25
// http://www.apache.org/licenses/LICENSE-2.0
26
//
27
// Unless required by applicable law or agreed to in writing, software distributed under the License
28
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
29
// or implied.  See the License for the specific language governing permissions and limitations
30
// under the License.
31
//
32
33
#ifndef YB_COMMON_KEY_ENCODER_H
34
#define YB_COMMON_KEY_ENCODER_H
35
36
#include <arpa/inet.h>
37
38
#ifndef __aarch64__
39
#include <nmmintrin.h>
40
#endif
41
42
#include <string.h>
43
44
#include <climits>
45
46
#include "yb/common/types.h"
47
#include "yb/gutil/endian.h"
48
#include "yb/gutil/macros.h"
49
#include "yb/gutil/mathlimits.h"
50
#include "yb/gutil/strings/memutil.h"
51
#include "yb/gutil/type_traits.h"
52
#include "yb/util/memory/arena.h"
53
#include "yb/util/status.h"
54
55
// The SSE-based encoding is not yet working. Don't define this!
56
#undef KEY_ENCODER_USE_SSE
57
58
namespace yb {
59
60
template<DataType Type, typename Buffer, class Enable = void>
61
struct KeyEncoderTraits {
62
};
63
64
// This complicated-looking template magic defines a specialization of the
65
// KeyEncoderTraits struct for any integral type. This avoids a bunch of
66
// code duplication for all of our different size/signed-ness variants.
67
template<DataType Type, typename Buffer>
68
struct KeyEncoderTraits<Type,
69
                        Buffer,
70
                        typename base::enable_if<
71
                          base::is_integral<
72
                            typename DataTypeTraits<Type>::cpp_type
73
                          >::value
74
                        >::type
75
                       > {
76
  static const DataType key_type = Type;
77
78
 private:
79
  typedef typename DataTypeTraits<Type>::cpp_type cpp_type;
80
  typedef typename MathLimits<cpp_type>::UnsignedType unsigned_cpp_type;
81
82
1
  static unsigned_cpp_type SwapEndian(unsigned_cpp_type x) {
83
1
    switch (sizeof(x)) {
84
0
      case 1: return x;
85
0
      case 2: return BigEndian::FromHost16(x);
86
1
      case 4: return BigEndian::FromHost32(*reinterpret_cast<uint32*>(&x));
87
0
      case 8: return BigEndian::FromHost64(*reinterpret_cast<uint64*>(&x));
88
0
      default: LOG(FATAL) << "bad type: " << x;
89
1
    }
90
0
    return 0;
91
1
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE100ENS_10faststringEvE10SwapEndianEh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE1ENS_10faststringEvE10SwapEndianEh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE101ENS_10faststringEvE10SwapEndianEt
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE2ENS_10faststringEvE10SwapEndianEt
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE102ENS_10faststringEvE10SwapEndianEj
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE3ENS_10faststringEvE10SwapEndianEj
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE103ENS_10faststringEvE10SwapEndianEy
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE4ENS_10faststringEvE10SwapEndianEy
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE7ENS_10faststringEvE10SwapEndianEf
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE8ENS_10faststringEvE10SwapEndianEd
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE100ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE10SwapEndianEh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE1ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE10SwapEndianEh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE101ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE10SwapEndianEt
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE2ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE10SwapEndianEt
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE102ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE10SwapEndianEj
_ZN2yb16KeyEncoderTraitsILNS_8DataTypeE3ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE10SwapEndianEj
Line
Count
Source
82
1
  static unsigned_cpp_type SwapEndian(unsigned_cpp_type x) {
83
1
    switch (sizeof(x)) {
84
0
      case 1: return x;
85
0
      case 2: return BigEndian::FromHost16(x);
86
1
      case 4: return BigEndian::FromHost32(*reinterpret_cast<uint32*>(&x));
87
0
      case 8: return BigEndian::FromHost64(*reinterpret_cast<uint64*>(&x));
88
0
      default: LOG(FATAL) << "bad type: " << x;
89
1
    }
90
0
    return 0;
91
1
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE103ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE10SwapEndianEy
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE4ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE10SwapEndianEy
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE7ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE10SwapEndianEf
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE8ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE10SwapEndianEd
92
93
 public:
94
  static void Encode(cpp_type key, Buffer* dst) {
95
    Encode(&key, dst);
96
  }
97
98
1
  static void Encode(const void* key_ptr, Buffer* dst) {
99
1
    unsigned_cpp_type key_unsigned;
100
1
    memcpy(&key_unsigned, key_ptr, sizeof(key_unsigned));
101
    // To encode signed integers, swap the MSB.
102
1
    if (MathLimits<cpp_type>::kIsSigned) {
103
1
      switch (sizeof(key_unsigned)) {
104
        // Since integral types now include floats and doubles, we need to always cast to
105
        // the appropriate intx_t before doing any bitwise operations. Cases for 1 and 2
106
        // are to make the compiler happy.
107
0
        case 1: {
108
0
          int8_t& key = reinterpret_cast<int8_t&> (key_unsigned);
109
0
          key ^= 1UL << (sizeof(key_unsigned) * CHAR_BIT - 1);
110
0
          break;
111
0
        }
112
0
        case 2: {
113
0
          int16_t& key = reinterpret_cast<int16_t&> (key_unsigned);
114
0
          key ^= 1UL << (sizeof(key_unsigned) * CHAR_BIT - 1);
115
0
          break;
116
0
        }
117
1
        case 4: {
118
1
          int32_t& key = reinterpret_cast<int32_t&> (key_unsigned);
119
1
          key ^= 1UL << (sizeof(key_unsigned) * CHAR_BIT - 1);
120
1
          break;
121
0
        }
122
0
        case 8: {
123
0
          int64_t& key = reinterpret_cast<int64_t&> (key_unsigned);
124
0
          key ^= 1UL << (sizeof(key_unsigned) * CHAR_BIT - 1);
125
0
          break;
126
0
        }
127
0
        default: {
128
0
          LOG(FATAL) << "bad type " << key_unsigned;
129
0
        }
130
1
      }
131
1
    }
132
1
    key_unsigned = SwapEndian(key_unsigned);
133
1
    dst->append(reinterpret_cast<const char*>(&key_unsigned), sizeof(key_unsigned));
134
1
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE100ENS_10faststringEvE6EncodeEPKvPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE1ENS_10faststringEvE6EncodeEPKvPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE101ENS_10faststringEvE6EncodeEPKvPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE2ENS_10faststringEvE6EncodeEPKvPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE102ENS_10faststringEvE6EncodeEPKvPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE3ENS_10faststringEvE6EncodeEPKvPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE103ENS_10faststringEvE6EncodeEPKvPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE4ENS_10faststringEvE6EncodeEPKvPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE7ENS_10faststringEvE6EncodeEPKvPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE8ENS_10faststringEvE6EncodeEPKvPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE100ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE6EncodeEPKvPS8_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE1ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE6EncodeEPKvPS8_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE101ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE6EncodeEPKvPS8_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE2ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE6EncodeEPKvPS8_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE102ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE6EncodeEPKvPS8_
_ZN2yb16KeyEncoderTraitsILNS_8DataTypeE3ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE6EncodeEPKvPS8_
Line
Count
Source
98
1
  static void Encode(const void* key_ptr, Buffer* dst) {
99
1
    unsigned_cpp_type key_unsigned;
100
1
    memcpy(&key_unsigned, key_ptr, sizeof(key_unsigned));
101
    // To encode signed integers, swap the MSB.
102
1
    if (MathLimits<cpp_type>::kIsSigned) {
103
1
      switch (sizeof(key_unsigned)) {
104
        // Since integral types now include floats and doubles, we need to always cast to
105
        // the appropriate intx_t before doing any bitwise operations. Cases for 1 and 2
106
        // are to make the compiler happy.
107
0
        case 1: {
108
0
          int8_t& key = reinterpret_cast<int8_t&> (key_unsigned);
109
0
          key ^= 1UL << (sizeof(key_unsigned) * CHAR_BIT - 1);
110
0
          break;
111
0
        }
112
0
        case 2: {
113
0
          int16_t& key = reinterpret_cast<int16_t&> (key_unsigned);
114
0
          key ^= 1UL << (sizeof(key_unsigned) * CHAR_BIT - 1);
115
0
          break;
116
0
        }
117
1
        case 4: {
118
1
          int32_t& key = reinterpret_cast<int32_t&> (key_unsigned);
119
1
          key ^= 1UL << (sizeof(key_unsigned) * CHAR_BIT - 1);
120
1
          break;
121
0
        }
122
0
        case 8: {
123
0
          int64_t& key = reinterpret_cast<int64_t&> (key_unsigned);
124
0
          key ^= 1UL << (sizeof(key_unsigned) * CHAR_BIT - 1);
125
0
          break;
126
0
        }
127
0
        default: {
128
0
          LOG(FATAL) << "bad type " << key_unsigned;
129
0
        }
130
1
      }
131
1
    }
132
1
    key_unsigned = SwapEndian(key_unsigned);
133
1
    dst->append(reinterpret_cast<const char*>(&key_unsigned), sizeof(key_unsigned));
134
1
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE103ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE6EncodeEPKvPS8_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE4ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE6EncodeEPKvPS8_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE7ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE6EncodeEPKvPS8_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE8ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE6EncodeEPKvPS8_
135
136
1
  static void EncodeWithSeparators(const void* key, bool is_last, Buffer* dst) {
137
1
    Encode(key, dst);
138
1
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE100ENS_10faststringEvE20EncodeWithSeparatorsEPKvbPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE1ENS_10faststringEvE20EncodeWithSeparatorsEPKvbPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE101ENS_10faststringEvE20EncodeWithSeparatorsEPKvbPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE2ENS_10faststringEvE20EncodeWithSeparatorsEPKvbPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE102ENS_10faststringEvE20EncodeWithSeparatorsEPKvbPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE3ENS_10faststringEvE20EncodeWithSeparatorsEPKvbPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE103ENS_10faststringEvE20EncodeWithSeparatorsEPKvbPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE4ENS_10faststringEvE20EncodeWithSeparatorsEPKvbPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE7ENS_10faststringEvE20EncodeWithSeparatorsEPKvbPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE8ENS_10faststringEvE20EncodeWithSeparatorsEPKvbPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE100ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE20EncodeWithSeparatorsEPKvbPS8_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE1ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE20EncodeWithSeparatorsEPKvbPS8_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE101ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE20EncodeWithSeparatorsEPKvbPS8_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE2ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE20EncodeWithSeparatorsEPKvbPS8_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE102ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE20EncodeWithSeparatorsEPKvbPS8_
_ZN2yb16KeyEncoderTraitsILNS_8DataTypeE3ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE20EncodeWithSeparatorsEPKvbPS8_
Line
Count
Source
136
1
  static void EncodeWithSeparators(const void* key, bool is_last, Buffer* dst) {
137
1
    Encode(key, dst);
138
1
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE103ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE20EncodeWithSeparatorsEPKvbPS8_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE4ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE20EncodeWithSeparatorsEPKvbPS8_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE7ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE20EncodeWithSeparatorsEPKvbPS8_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE8ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE20EncodeWithSeparatorsEPKvbPS8_
139
140
  static CHECKED_STATUS DecodeKeyPortion(Slice* encoded_key,
141
                                         bool is_last,
142
                                         Arena* arena,
143
2
                                         uint8_t* cell_ptr) {
144
2
    if (PREDICT_FALSE(encoded_key->size() < sizeof(cpp_type))) {
145
2
      return STATUS(InvalidArgument, "key too short", encoded_key->ToDebugString());
146
2
    }
147
148
0
    unsigned_cpp_type val;
149
0
    memcpy(&val,  encoded_key->data(), sizeof(cpp_type));
150
0
    val = SwapEndian(val);
151
0
    if (MathLimits<cpp_type>::kIsSigned) {
152
0
      switch (sizeof(val)) {
153
0
        case 1: {
154
0
          int8_t& key = reinterpret_cast<int8_t&> (val);
155
0
          key ^= 1UL << (sizeof(key) * CHAR_BIT - 1);
156
0
          break;
157
0
        }
158
0
        case 2: {
159
0
          int16_t& key = reinterpret_cast<int16_t&> (val);
160
0
          key ^= 1UL << (sizeof(key) * CHAR_BIT - 1);
161
0
          break;
162
0
        }
163
0
        case 4: {
164
0
          int32_t& key = reinterpret_cast<int32_t&> (val);
165
0
          key ^= 1UL << (sizeof(key) * CHAR_BIT - 1);
166
0
          break;
167
0
        }
168
0
        case 8: {
169
0
          int64_t& key = reinterpret_cast<int64_t&> (val);
170
0
          key ^= 1UL << (sizeof(key) * CHAR_BIT - 1);
171
0
          break;
172
0
        }
173
0
        default: {
174
0
          LOG(FATAL) << "bad type " << val;
175
0
        }
176
0
      }
177
0
    }
178
0
    memcpy(cell_ptr, &val, sizeof(val));
179
0
    encoded_key->remove_prefix(sizeof(cpp_type));
180
0
    return Status::OK();
181
0
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE100ENS_10faststringEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINS6_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE1ENS_10faststringEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINS6_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE101ENS_10faststringEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINS6_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE2ENS_10faststringEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINS6_11ArenaTraitsEEEPh
_ZN2yb16KeyEncoderTraitsILNS_8DataTypeE102ENS_10faststringEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINS6_11ArenaTraitsEEEPh
Line
Count
Source
143
2
                                         uint8_t* cell_ptr) {
144
2
    if (PREDICT_FALSE(encoded_key->size() < sizeof(cpp_type))) {
145
2
      return STATUS(InvalidArgument, "key too short", encoded_key->ToDebugString());
146
2
    }
147
148
0
    unsigned_cpp_type val;
149
0
    memcpy(&val,  encoded_key->data(), sizeof(cpp_type));
150
0
    val = SwapEndian(val);
151
0
    if (MathLimits<cpp_type>::kIsSigned) {
152
0
      switch (sizeof(val)) {
153
0
        case 1: {
154
0
          int8_t& key = reinterpret_cast<int8_t&> (val);
155
0
          key ^= 1UL << (sizeof(key) * CHAR_BIT - 1);
156
0
          break;
157
0
        }
158
0
        case 2: {
159
0
          int16_t& key = reinterpret_cast<int16_t&> (val);
160
0
          key ^= 1UL << (sizeof(key) * CHAR_BIT - 1);
161
0
          break;
162
0
        }
163
0
        case 4: {
164
0
          int32_t& key = reinterpret_cast<int32_t&> (val);
165
0
          key ^= 1UL << (sizeof(key) * CHAR_BIT - 1);
166
0
          break;
167
0
        }
168
0
        case 8: {
169
0
          int64_t& key = reinterpret_cast<int64_t&> (val);
170
0
          key ^= 1UL << (sizeof(key) * CHAR_BIT - 1);
171
0
          break;
172
0
        }
173
0
        default: {
174
0
          LOG(FATAL) << "bad type " << val;
175
0
        }
176
0
      }
177
0
    }
178
0
    memcpy(cell_ptr, &val, sizeof(val));
179
0
    encoded_key->remove_prefix(sizeof(cpp_type));
180
0
    return Status::OK();
181
0
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE3ENS_10faststringEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINS6_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE103ENS_10faststringEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINS6_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE4ENS_10faststringEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINS6_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE7ENS_10faststringEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINS6_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE8ENS_10faststringEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINS6_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE100ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINSC_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE1ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINSC_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE101ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINSC_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE2ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINSC_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE102ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINSC_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE3ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINSC_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE103ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINSC_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE4ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINSC_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE7ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINSC_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE8ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINSC_11ArenaTraitsEEEPh
182
};
183
184
template<typename Buffer>
185
struct KeyEncoderTraits<BINARY, Buffer> {
186
187
  static const DataType key_type = BINARY;
188
189
0
  static void Encode(const void* key, Buffer* dst) {
190
0
    Encode(*reinterpret_cast<const Slice*>(key), dst);
191
0
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENS_10faststringEvE6EncodeEPKvPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE6EncodeEPKvPS8_
192
193
  // simple slice encoding that just adds to the buffer
194
0
  inline static void Encode(const Slice& s, Buffer* dst) {
195
0
    dst->append(reinterpret_cast<const char*>(s.data()), s.size());
196
0
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENS_10faststringEvE6EncodeERKNS_5SliceEPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE6EncodeERKNS_5SliceEPS8_
197
0
  static void EncodeWithSeparators(const void* key, bool is_last, Buffer* dst) {
198
0
    EncodeWithSeparators(*reinterpret_cast<const Slice*>(key), is_last, dst);
199
0
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENS_10faststringEvE20EncodeWithSeparatorsEPKvbPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE20EncodeWithSeparatorsEPKvbPS8_
200
201
  // slice encoding that uses a separator to retain lexicographic
202
  // comparability.
203
  //
204
  // This implementation is heavily optimized for the case where the input
205
  // slice has no '\0' bytes. We assume this is common in most user-generated
206
  // compound keys.
207
0
  inline static void EncodeWithSeparators(const Slice& s, bool is_last, Buffer* dst) {
208
0
    if (is_last) {
209
0
      dst->append(reinterpret_cast<const char*>(s.data()), s.size());
210
0
    } else {
211
      // If we're a middle component of a composite key, we need to add a \x00
212
      // at the end in order to separate this component from the next one. However,
213
      // if we just did that, we'd have issues where a key that actually has
214
      // \x00 in it would compare wrong, so we have to instead add \x00\x00, and
215
      // encode \x00 as \x00\x01.
216
0
      auto old_size = dst->size();
217
0
      dst->resize(old_size + s.size() * 2 + 2);
218
219
0
      const uint8_t* srcp = s.data();
220
0
      uint8_t* dstp = reinterpret_cast<uint8_t*>(&(*dst)[old_size]);
221
0
      auto len = s.size();
222
0
      auto rem = len;
223
224
0
      while (rem >= 16) {
225
0
        if (!SSEEncodeChunk<16>(&srcp, &dstp)) {
226
0
          goto slow_path;
227
0
        }
228
0
        rem -= 16;
229
0
      }
230
0
      while (rem >= 8) {
231
0
        if (!SSEEncodeChunk<8>(&srcp, &dstp)) {
232
0
          goto slow_path;
233
0
        }
234
0
        rem -= 8;
235
0
      }
236
      // Roll back to operate in 8 bytes at a time.
237
0
      if (len > 8 && rem > 0) {
238
0
        dstp -= 8 - rem;
239
0
        srcp -= 8 - rem;
240
0
        if (!SSEEncodeChunk<8>(&srcp, &dstp)) {
241
          // TODO: optimize for the case where the input slice has '\0'
242
          // bytes. (e.g. move the pointer to the first zero byte.)
243
0
          dstp += 8 - rem;
244
0
          srcp += 8 - rem;
245
0
          goto slow_path;
246
0
        }
247
0
        rem = 0;
248
0
        goto done;
249
0
      }
250
251
0
      slow_path:
252
0
      EncodeChunkLoop(&srcp, &dstp, rem);
253
254
0
      done:
255
0
      *dstp++ = 0;
256
0
      *dstp++ = 0;
257
0
      dst->resize(dstp - reinterpret_cast<uint8_t*>(&(*dst)[0]));
258
0
    }
259
0
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENS_10faststringEvE20EncodeWithSeparatorsERKNS_5SliceEbPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE20EncodeWithSeparatorsERKNS_5SliceEbPS8_
260
261
  static CHECKED_STATUS DecodeKeyPortion(Slice* encoded_key,
262
                                         bool is_last,
263
                                         Arena* arena,
264
9
                                         uint8_t* cell_ptr) {
265
9
    if (is_last) {
266
3
      Slice* dst_slice = reinterpret_cast<Slice *>(cell_ptr);
267
3
      if (PREDICT_FALSE(!arena->RelocateSlice(*encoded_key, dst_slice))) {
268
0
        return STATUS(RuntimeError, "OOM");
269
0
      }
270
3
      encoded_key->remove_prefix(encoded_key->size());
271
3
      return Status::OK();
272
3
    }
273
274
6
    uint8_t* separator = static_cast<uint8_t*>(memmem(encoded_key->data(), encoded_key->size(),
275
6
                                                      "\0\0", 2));
276
6
    if (PREDICT_FALSE(separator == NULL)) {
277
1
      return STATUS(InvalidArgument, "Missing separator after composite key string component",
278
1
                                     encoded_key->ToDebugString());
279
1
    }
280
281
5
    uint8_t* src = encoded_key->mutable_data();
282
5
    auto max_len = separator - src;
283
5
    uint8_t* dst_start = static_cast<uint8_t*>(arena->AllocateBytes(max_len));
284
5
    uint8_t* dst = dst_start;
285
286
24
    for (int i = 0; i < max_len; i++) {
287
19
      if (i >= 1 && src[i - 1] == '\0' && src[i] == '\1') {
288
2
        continue;
289
2
      }
290
17
      *dst++ = src[i];
291
17
    }
292
293
5
    auto real_len = dst - dst_start;
294
5
    Slice slice(dst_start, real_len);
295
5
    memcpy(cell_ptr, &slice, sizeof(Slice));
296
5
    encoded_key->remove_prefix(max_len + 2);
297
5
    return Status::OK();
298
5
  }
_ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENS_10faststringEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINS6_11ArenaTraitsEEEPh
Line
Count
Source
264
9
                                         uint8_t* cell_ptr) {
265
9
    if (is_last) {
266
3
      Slice* dst_slice = reinterpret_cast<Slice *>(cell_ptr);
267
3
      if (PREDICT_FALSE(!arena->RelocateSlice(*encoded_key, dst_slice))) {
268
0
        return STATUS(RuntimeError, "OOM");
269
0
      }
270
3
      encoded_key->remove_prefix(encoded_key->size());
271
3
      return Status::OK();
272
3
    }
273
274
6
    uint8_t* separator = static_cast<uint8_t*>(memmem(encoded_key->data(), encoded_key->size(),
275
6
                                                      "\0\0", 2));
276
6
    if (PREDICT_FALSE(separator == NULL)) {
277
1
      return STATUS(InvalidArgument, "Missing separator after composite key string component",
278
1
                                     encoded_key->ToDebugString());
279
1
    }
280
281
5
    uint8_t* src = encoded_key->mutable_data();
282
5
    auto max_len = separator - src;
283
5
    uint8_t* dst_start = static_cast<uint8_t*>(arena->AllocateBytes(max_len));
284
5
    uint8_t* dst = dst_start;
285
286
24
    for (int i = 0; i < max_len; i++) {
287
19
      if (i >= 1 && src[i - 1] == '\0' && src[i] == '\1') {
288
2
        continue;
289
2
      }
290
17
      *dst++ = src[i];
291
17
    }
292
293
5
    auto real_len = dst - dst_start;
294
5
    Slice slice(dst_start, real_len);
295
5
    memcpy(cell_ptr, &slice, sizeof(Slice));
296
5
    encoded_key->remove_prefix(max_len + 2);
297
5
    return Status::OK();
298
5
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINSC_11ArenaTraitsEEEPh
299
300
 private:
301
  // Encode a chunk of 'len' bytes from '*srcp' into '*dstp', incrementing
302
  // the pointers upon return.
303
  //
304
  // This uses SSE2 operations to operate in 8 or 16 bytes at a time, fast-pathing
305
  // the case where there are no '\x00' bytes in the source.
306
  //
307
  // Returns true if the chunk was successfully processed, false if there was one
308
  // or more '\0' bytes requiring the slow path.
309
  //
310
  // REQUIRES: len == 16 or 8
311
  template<int LEN>
312
0
  static bool SSEEncodeChunk(const uint8_t** srcp, uint8_t** dstp) {
313
0
#ifdef __aarch64__
314
0
    return false;
315
#else
316
    COMPILE_ASSERT(LEN == 16 || LEN == 8, invalid_length);
317
    __m128i data;
318
    if (LEN == 16) {
319
      // Load 16 bytes (unaligned) into the XMM register.
320
      data = _mm_loadu_si128(reinterpret_cast<const __m128i*>(*srcp));
321
    } else if (LEN == 8) {
322
      // Load 8 bytes (unaligned) into the XMM register
323
      data = reinterpret_cast<__m128i>(_mm_load_sd(reinterpret_cast<const double*>(*srcp)));
324
    }
325
    // Compare each byte of the input with '\0'. This results in a vector
326
    // where each byte is either \x00 or \xFF, depending on whether the
327
    // input had a '\x00' in the corresponding position.
328
    __m128i zeros = reinterpret_cast<__m128i>(_mm_setzero_pd());
329
    __m128i zero_bytes = _mm_cmpeq_epi8(data, zeros);
330
331
    // Check whether the resulting vector is all-zero.
332
    bool all_zeros;
333
    if (LEN == 16) {
334
      all_zeros = _mm_testz_si128(zero_bytes, zero_bytes);
335
    } else { // LEN == 8
336
      all_zeros = _mm_cvtsi128_si64(zero_bytes) == 0;
337
    }
338
339
    // If it's all zero, we can just store the entire chunk.
340
    if (PREDICT_FALSE(!all_zeros)) {
341
      return false;
342
    }
343
344
    if (LEN == 16) {
345
      _mm_storeu_si128(reinterpret_cast<__m128i*>(*dstp), data);
346
    } else {
347
      _mm_storel_epi64(reinterpret_cast<__m128i*>(*dstp), data);  // movq m64, xmm
348
    }
349
    *dstp += LEN;
350
    *srcp += LEN;
351
    return true;
352
#endif
353
0
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENS_10faststringEvE14SSEEncodeChunkILi16EEEbPPKhPPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENS_10faststringEvE14SSEEncodeChunkILi8EEEbPPKhPPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE14SSEEncodeChunkILi16EEEbPPKhPPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE14SSEEncodeChunkILi8EEEbPPKhPPh
354
355
  // Non-SSE loop which encodes 'len' bytes from 'srcp' into 'dst'.
356
0
  static void EncodeChunkLoop(const uint8_t** srcp, uint8_t** dstp, size_t len) {
357
0
    while (len > 0) {
358
0
      --len;
359
0
      if (PREDICT_FALSE(**srcp == '\0')) {
360
0
        *(*dstp)++ = 0;
361
0
        *(*dstp)++ = 1;
362
0
      } else {
363
0
        *(*dstp)++ = **srcp;
364
0
      }
365
0
      (*srcp)++;
366
0
    }
367
0
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENS_10faststringEvE15EncodeChunkLoopEPPKhPPhm
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE9ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE15EncodeChunkLoopEPPKhPPhm
368
};
369
370
template<typename Buffer>
371
struct KeyEncoderTraits<BOOL, Buffer> {
372
373
  static const DataType key_type = BOOL;
374
375
0
  static void Encode(const void* key, Buffer* dst) {
376
0
    dst->push_back(*reinterpret_cast<const bool*>(key) ? 1 : 0);
377
0
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE6ENS_10faststringEvE6EncodeEPKvPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE6ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE6EncodeEPKvPS8_
378
379
0
  static void EncodeWithSeparators(const void* key, bool is_last, Buffer* dst) {
380
0
    Encode(key, dst);
381
0
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE6ENS_10faststringEvE20EncodeWithSeparatorsEPKvbPS2_
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE6ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE20EncodeWithSeparatorsEPKvbPS8_
382
383
  static CHECKED_STATUS DecodeKeyPortion(Slice* encoded_key,
384
                                         bool is_last,
385
                                         Arena* arena,
386
0
                                         uint8_t* cell_ptr) {
387
0
    if (PREDICT_FALSE(encoded_key->size() < sizeof(char))) {
388
0
      return STATUS(InvalidArgument, "key too short", encoded_key->ToDebugString());
389
0
    }
390
391
0
    *cell_ptr = *encoded_key->data();
392
0
    encoded_key->remove_prefix(sizeof(char));
393
0
    return Status::OK();
394
0
  }
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE6ENS_10faststringEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINS6_11ArenaTraitsEEEPh
Unexecuted instantiation: _ZN2yb16KeyEncoderTraitsILNS_8DataTypeE6ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvE16DecodeKeyPortionEPNS_5SliceEbPNS_8internal9ArenaBaseINSC_11ArenaTraitsEEEPh
395
};
396
397
// Forward declaration is necessary for friend declaration in KeyEncoder.
398
template<typename Buffer>
399
class EncoderResolver;
400
401
// The runtime version of the key encoder
402
template <typename Buffer>
403
class KeyEncoder {
404
 public:
405
406
  // Encodes the provided key to the provided buffer
407
0
  void Encode(const void* key, Buffer* dst) const {
408
0
    encode_func_(key, dst);
409
0
  }
410
411
  // Special encoding for composite keys.
412
1
  void Encode(const void* key, bool is_last, Buffer* dst) const {
413
1
    encode_with_separators_func_(key, is_last, dst);
414
1
  }
415
416
  void ResetAndEncode(const void* key, Buffer* dst) const {
417
    dst->clear();
418
    Encode(key, dst);
419
  }
420
421
  // Decode the next component out of the composite key pointed to by '*encoded_key'
422
  // into *cell_ptr.
423
  // After decoding encoded_key is advanced forward such that it contains the remainder
424
  // of the composite key.
425
  // 'is_last' should be true when we expect that this component is the last (or only) component
426
  // of the composite key.
427
  // Any indirect data (eg strings) are allocated out of 'arena'.
428
  CHECKED_STATUS Decode(Slice* encoded_key,
429
                        bool is_last,
430
                        Arena* arena,
431
11
                        uint8_t* cell_ptr) const {
432
11
    return decode_key_portion_func_(encoded_key, is_last, arena, cell_ptr);
433
11
  }
434
435
 private:
436
  friend class EncoderResolver<Buffer>;
437
  template<typename EncoderTraitsClass>
438
  explicit KeyEncoder(EncoderTraitsClass t)
439
      : encode_func_(EncoderTraitsClass::Encode),
440
        encode_with_separators_func_(EncoderTraitsClass::EncodeWithSeparators),
441
82.5k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
82.5k
  }
_ZN2yb10KeyEncoderINS_10faststringEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE6ES1_vEEEET_
Line
Count
Source
441
1.44k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
1.44k
  }
_ZN2yb10KeyEncoderINS_10faststringEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE100ES1_vEEEET_
Line
Count
Source
441
1.44k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
1.44k
  }
_ZN2yb10KeyEncoderINS_10faststringEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE1ES1_vEEEET_
Line
Count
Source
441
1.44k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
1.44k
  }
_ZN2yb10KeyEncoderINS_10faststringEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE101ES1_vEEEET_
Line
Count
Source
441
1.44k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
1.44k
  }
_ZN2yb10KeyEncoderINS_10faststringEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE2ES1_vEEEET_
Line
Count
Source
441
1.44k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
1.44k
  }
_ZN2yb10KeyEncoderINS_10faststringEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE102ES1_vEEEET_
Line
Count
Source
441
1.44k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
1.44k
  }
_ZN2yb10KeyEncoderINS_10faststringEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE3ES1_vEEEET_
Line
Count
Source
441
1.44k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
1.44k
  }
_ZN2yb10KeyEncoderINS_10faststringEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE103ES1_vEEEET_
Line
Count
Source
441
1.44k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
1.44k
  }
_ZN2yb10KeyEncoderINS_10faststringEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE4ES1_vEEEET_
Line
Count
Source
441
1.44k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
1.44k
  }
_ZN2yb10KeyEncoderINS_10faststringEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE9ES1_vEEEET_
Line
Count
Source
441
1.44k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
1.44k
  }
_ZN2yb10KeyEncoderINS_10faststringEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE7ES1_vEEEET_
Line
Count
Source
441
1.44k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
1.44k
  }
_ZN2yb10KeyEncoderINS_10faststringEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE8ES1_vEEEET_
Line
Count
Source
441
1.44k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
1.44k
  }
_ZN2yb10KeyEncoderINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE6ES7_vEEEET_
Line
Count
Source
441
5.43k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
5.43k
  }
_ZN2yb10KeyEncoderINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE100ES7_vEEEET_
Line
Count
Source
441
5.43k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
5.43k
  }
_ZN2yb10KeyEncoderINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE1ES7_vEEEET_
Line
Count
Source
441
5.43k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
5.43k
  }
_ZN2yb10KeyEncoderINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE101ES7_vEEEET_
Line
Count
Source
441
5.43k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
5.43k
  }
_ZN2yb10KeyEncoderINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE2ES7_vEEEET_
Line
Count
Source
441
5.43k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
5.43k
  }
_ZN2yb10KeyEncoderINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE102ES7_vEEEET_
Line
Count
Source
441
5.43k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
5.43k
  }
_ZN2yb10KeyEncoderINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE3ES7_vEEEET_
Line
Count
Source
441
5.43k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
5.43k
  }
_ZN2yb10KeyEncoderINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE103ES7_vEEEET_
Line
Count
Source
441
5.43k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
5.43k
  }
_ZN2yb10KeyEncoderINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE4ES7_vEEEET_
Line
Count
Source
441
5.43k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
5.43k
  }
_ZN2yb10KeyEncoderINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE9ES7_vEEEET_
Line
Count
Source
441
5.43k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
5.43k
  }
_ZN2yb10KeyEncoderINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE7ES7_vEEEET_
Line
Count
Source
441
5.43k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
5.43k
  }
_ZN2yb10KeyEncoderINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEC2INS_16KeyEncoderTraitsILNS_8DataTypeE8ES7_vEEEET_
Line
Count
Source
441
5.43k
        decode_key_portion_func_(EncoderTraitsClass::DecodeKeyPortion) {
442
5.43k
  }
443
444
  typedef void (*EncodeFunc)(const void* key, Buffer* dst);
445
  const EncodeFunc encode_func_;
446
  typedef void (*EncodeWithSeparatorsFunc)(const void* key, bool is_last, Buffer* dst);
447
  const EncodeWithSeparatorsFunc encode_with_separators_func_;
448
449
  typedef Status (*DecodeKeyPortionFunc)(Slice* enc_key, bool is_last,
450
                                         Arena* arena, uint8_t* cell_ptr);
451
  const DecodeKeyPortionFunc decode_key_portion_func_;
452
453
 private:
454
  DISALLOW_COPY_AND_ASSIGN(KeyEncoder);
455
};
456
457
template <typename Buffer>
458
extern const KeyEncoder<Buffer>& GetKeyEncoder(const TypeInfo* typeinfo);
459
460
extern bool IsTypeAllowableInKey(const TypeInfo* typeinfo);
461
462
} // namespace yb
463
464
#endif // YB_COMMON_KEY_ENCODER_H