/Users/deen/code/yugabyte-db/src/yb/util/yb_partition.h
Line | Count | Source |
1 | | //-------------------------------------------------------------------------------------------------- |
2 | | // Copyright (c) YugaByte, Inc. |
3 | | // |
4 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
5 | | // in compliance with the License. You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
10 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
11 | | // or implied. See the License for the specific language governing permissions and limitations |
12 | | // under the License. |
13 | | // |
14 | | //-------------------------------------------------------------------------------------------------- |
15 | | |
16 | | #ifndef YB_UTIL_YB_PARTITION_H |
17 | | #define YB_UTIL_YB_PARTITION_H |
18 | | |
19 | | #include <string> |
20 | | #include "yb/util/status_fwd.h" |
21 | | #include "yb/gutil/endian.h" |
22 | | |
23 | | namespace yb { |
24 | | |
25 | | class YBPartition { |
26 | | public: |
27 | | static const uint16 kMaxHashCode = UINT16_MAX; |
28 | | static const uint16 kMinHashCode = 0; |
29 | | |
30 | | static uint16_t CqlToYBHashCode(int64_t cql_hash); |
31 | | |
32 | | static int64_t YBToCqlHashCode(uint16_t hash); |
33 | | |
34 | | static std::string CqlTokenSplit(size_t node_count, size_t index); |
35 | | |
36 | | static void AppendBytesToKey(const char *bytes, size_t len, std::string *encoded_key); |
37 | | |
38 | | template<typename signed_type, typename unsigned_type> |
39 | 12.8M | static void AppendIntToKey(signed_type val, std::string *encoded_key) { |
40 | 12.8M | unsigned_type uval = Load<unsigned_type, BigEndian>(&val); |
41 | 12.8M | encoded_key->append(reinterpret_cast<char *>(&uval), sizeof(uval)); |
42 | 12.8M | } void yb::YBPartition::AppendIntToKey<int, unsigned int>(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) Line | Count | Source | 39 | 10.1M | static void AppendIntToKey(signed_type val, std::string *encoded_key) { | 40 | 10.1M | unsigned_type uval = Load<unsigned_type, BigEndian>(&val); | 41 | 10.1M | encoded_key->append(reinterpret_cast<char *>(&uval), sizeof(uval)); | 42 | 10.1M | } |
void yb::YBPartition::AppendIntToKey<bool, unsigned char>(bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) Line | Count | Source | 39 | 36.5k | static void AppendIntToKey(signed_type val, std::string *encoded_key) { | 40 | 36.5k | unsigned_type uval = Load<unsigned_type, BigEndian>(&val); | 41 | 36.5k | encoded_key->append(reinterpret_cast<char *>(&uval), sizeof(uval)); | 42 | 36.5k | } |
void yb::YBPartition::AppendIntToKey<signed char, unsigned char>(signed char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) Line | Count | Source | 39 | 135k | static void AppendIntToKey(signed_type val, std::string *encoded_key) { | 40 | 135k | unsigned_type uval = Load<unsigned_type, BigEndian>(&val); | 41 | 135k | encoded_key->append(reinterpret_cast<char *>(&uval), sizeof(uval)); | 42 | 135k | } |
void yb::YBPartition::AppendIntToKey<short, unsigned short>(short, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) Line | Count | Source | 39 | 71.9k | static void AppendIntToKey(signed_type val, std::string *encoded_key) { | 40 | 71.9k | unsigned_type uval = Load<unsigned_type, BigEndian>(&val); | 41 | 71.9k | encoded_key->append(reinterpret_cast<char *>(&uval), sizeof(uval)); | 42 | 71.9k | } |
void yb::YBPartition::AppendIntToKey<long long, unsigned long long>(long long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) Line | Count | Source | 39 | 2.29M | static void AppendIntToKey(signed_type val, std::string *encoded_key) { | 40 | 2.29M | unsigned_type uval = Load<unsigned_type, BigEndian>(&val); | 41 | 2.29M | encoded_key->append(reinterpret_cast<char *>(&uval), sizeof(uval)); | 42 | 2.29M | } |
void yb::YBPartition::AppendIntToKey<unsigned int, unsigned int>(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) Line | Count | Source | 39 | 459 | static void AppendIntToKey(signed_type val, std::string *encoded_key) { | 40 | 459 | unsigned_type uval = Load<unsigned_type, BigEndian>(&val); | 41 | 459 | encoded_key->append(reinterpret_cast<char *>(&uval), sizeof(uval)); | 42 | 459 | } |
Unexecuted instantiation: void yb::YBPartition::AppendIntToKey<unsigned long long, unsigned long long>(unsigned long long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) void yb::YBPartition::AppendIntToKey<float, unsigned int>(float, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) Line | Count | Source | 39 | 447 | static void AppendIntToKey(signed_type val, std::string *encoded_key) { | 40 | 447 | unsigned_type uval = Load<unsigned_type, BigEndian>(&val); | 41 | 447 | encoded_key->append(reinterpret_cast<char *>(&uval), sizeof(uval)); | 42 | 447 | } |
void yb::YBPartition::AppendIntToKey<double, unsigned long long>(double, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) Line | Count | Source | 39 | 133k | static void AppendIntToKey(signed_type val, std::string *encoded_key) { | 40 | 133k | unsigned_type uval = Load<unsigned_type, BigEndian>(&val); | 41 | 133k | encoded_key->append(reinterpret_cast<char *>(&uval), sizeof(uval)); | 42 | 133k | } |
Unexecuted instantiation: void yb::YBPartition::AppendIntToKey<unsigned char, unsigned char>(unsigned char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) |
43 | | |
44 | | static uint16_t HashColumnCompoundValue(const std::string &compound); |
45 | | }; |
46 | | |
47 | | } // namespace yb |
48 | | |
49 | | #endif // YB_UTIL_YB_PARTITION_H |