/Users/deen/code/yugabyte-db/src/yb/util/strongly_typed_uuid.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | // |
13 | | |
14 | | #ifndef YB_UTIL_STRONGLY_TYPED_UUID_H |
15 | | #define YB_UTIL_STRONGLY_TYPED_UUID_H |
16 | | |
17 | | #include <random> |
18 | | |
19 | | #include <boost/preprocessor/cat.hpp> |
20 | | |
21 | | #include "yb/gutil/endian.h" |
22 | | |
23 | | #include "yb/util/status_fwd.h" |
24 | | #include "yb/util/slice.h" |
25 | | #include "yb/util/uuid.h" |
26 | | |
27 | | // A "strongly-typed UUID" tool. This is needed to prevent passing the wrong UUID as a |
28 | | // function parameter, and to make callsites more readable by enforcing that MyUuidType is |
29 | | // specified instead of just UUID. Conversion from strongly-typed UUIDs |
30 | | // to regular UUIDs is automatic, but the reverse conversion is always explicit. |
31 | | #define YB_STRONGLY_TYPED_UUID(TypeName) \ |
32 | | struct BOOST_PP_CAT(TypeName, _Tag); \ |
33 | | typedef ::yb::StronglyTypedUuid<BOOST_PP_CAT(TypeName, _Tag)> TypeName; \ |
34 | | typedef boost::hash<TypeName> BOOST_PP_CAT(TypeName, Hash); \ |
35 | | Result<TypeName> BOOST_PP_CAT(FullyDecode, TypeName)(const Slice& slice); \ |
36 | | TypeName BOOST_PP_CAT(TryFullyDecode, TypeName)(const Slice& slice); \ |
37 | | Result<TypeName> BOOST_PP_CAT(Decode, TypeName)(Slice* slice); \ |
38 | | Result<TypeName> BOOST_PP_CAT(TypeName, FromString)(const std::string& strval); \ |
39 | | Result<TypeName> FromStringHelper(TypeName*, const std::string& strval); |
40 | | |
41 | | #define YB_STRONGLY_TYPED_UUID_IMPL(TypeName) \ |
42 | 9.93M | Result<TypeName> BOOST_PP_CAT(FullyDecode, TypeName)(const Slice& slice) { \ |
43 | 9.93M | return TypeName(VERIFY_RESULT(yb::Uuid::FullyDecode(slice, BOOST_PP_STRINGIZE(TypeName)))); \ |
44 | 9.93M | } \ Unexecuted instantiation: _ZN2yb4util19FullyDecodeTestUuidERKNS_5SliceE Unexecuted instantiation: _ZN2yb19FullyDecodeClientIdERKNS_5SliceE Unexecuted instantiation: _ZN2yb24FullyDecodeTxnSnapshotIdERKNS_5SliceE Unexecuted instantiation: _ZN2yb35FullyDecodeTxnSnapshotRestorationIdERKNS_5SliceE Unexecuted instantiation: _ZN2yb29FullyDecodeSnapshotScheduleIdERKNS_5SliceE _ZN2yb24FullyDecodeTransactionIdERKNS_5SliceE Line | Count | Source | 42 | 9.93M | Result<TypeName> BOOST_PP_CAT(FullyDecode, TypeName)(const Slice& slice) { \ | 43 | 9.93M | return TypeName(VERIFY_RESULT(yb::Uuid::FullyDecode(slice, BOOST_PP_STRINGIZE(TypeName)))); \ | 44 | 9.93M | } \ |
|
45 | 892 | TypeName BOOST_PP_CAT(TryFullyDecode, TypeName)(const Slice& slice) { \ |
46 | 892 | return TypeName(yb::Uuid::TryFullyDecode(slice)); \ |
47 | 892 | } \ Unexecuted instantiation: _ZN2yb4util22TryFullyDecodeTestUuidERKNS_5SliceE Unexecuted instantiation: _ZN2yb22TryFullyDecodeClientIdERKNS_5SliceE _ZN2yb27TryFullyDecodeTxnSnapshotIdERKNS_5SliceE Line | Count | Source | 45 | 16 | TypeName BOOST_PP_CAT(TryFullyDecode, TypeName)(const Slice& slice) { \ | 46 | 16 | return TypeName(yb::Uuid::TryFullyDecode(slice)); \ | 47 | 16 | } \ |
_ZN2yb38TryFullyDecodeTxnSnapshotRestorationIdERKNS_5SliceE Line | Count | Source | 45 | 862 | TypeName BOOST_PP_CAT(TryFullyDecode, TypeName)(const Slice& slice) { \ | 46 | 862 | return TypeName(yb::Uuid::TryFullyDecode(slice)); \ | 47 | 862 | } \ |
_ZN2yb32TryFullyDecodeSnapshotScheduleIdERKNS_5SliceE Line | Count | Source | 45 | 14 | TypeName BOOST_PP_CAT(TryFullyDecode, TypeName)(const Slice& slice) { \ | 46 | 14 | return TypeName(yb::Uuid::TryFullyDecode(slice)); \ | 47 | 14 | } \ |
Unexecuted instantiation: _ZN2yb27TryFullyDecodeTransactionIdERKNS_5SliceE |
48 | 6.64M | Result<TypeName> BOOST_PP_CAT(Decode, TypeName)(Slice* slice) { \ |
49 | 6.64M | return TypeName(VERIFY_RESULT(yb::Uuid::Decode(slice))); \ |
50 | 6.64M | } \ Unexecuted instantiation: _ZN2yb4util14DecodeTestUuidEPNS_5SliceE Unexecuted instantiation: _ZN2yb14DecodeClientIdEPNS_5SliceE Unexecuted instantiation: _ZN2yb19DecodeTxnSnapshotIdEPNS_5SliceE Unexecuted instantiation: _ZN2yb30DecodeTxnSnapshotRestorationIdEPNS_5SliceE Unexecuted instantiation: _ZN2yb24DecodeSnapshotScheduleIdEPNS_5SliceE _ZN2yb19DecodeTransactionIdEPNS_5SliceE Line | Count | Source | 48 | 6.64M | Result<TypeName> BOOST_PP_CAT(Decode, TypeName)(Slice* slice) { \ | 49 | 6.64M | return TypeName(VERIFY_RESULT(yb::Uuid::Decode(slice))); \ | 50 | 6.64M | } \ |
|
51 | 320 | Result<TypeName> BOOST_PP_CAT(TypeName, FromString)(const std::string& strval) { \ |
52 | 319 | return TypeName(VERIFY_RESULT(::yb::Uuid::FromString(strval))); \ |
53 | 320 | } \ _ZN2yb4util18TestUuidFromStringERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE Line | Count | Source | 51 | 3 | Result<TypeName> BOOST_PP_CAT(TypeName, FromString)(const std::string& strval) { \ | 52 | 2 | return TypeName(VERIFY_RESULT(::yb::Uuid::FromString(strval))); \ | 53 | 3 | } \ |
Unexecuted instantiation: _ZN2yb18ClientIdFromStringERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE Unexecuted instantiation: _ZN2yb23TxnSnapshotIdFromStringERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE Unexecuted instantiation: _ZN2yb34TxnSnapshotRestorationIdFromStringERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE Unexecuted instantiation: _ZN2yb28SnapshotScheduleIdFromStringERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE _ZN2yb23TransactionIdFromStringERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE Line | Count | Source | 51 | 317 | Result<TypeName> BOOST_PP_CAT(TypeName, FromString)(const std::string& strval) { \ | 52 | 317 | return TypeName(VERIFY_RESULT(::yb::Uuid::FromString(strval))); \ | 53 | 317 | } \ |
|
54 | 317 | Result<TypeName> FromStringHelper(TypeName*, const std::string& strval) { \ |
55 | 317 | return BOOST_PP_CAT(TypeName, FromString)(strval); \ |
56 | 317 | } Unexecuted instantiation: _ZN2yb4util16FromStringHelperEPNS_17StronglyTypedUuidINS0_12TestUuid_TagEEERKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE Unexecuted instantiation: _ZN2yb16FromStringHelperEPNS_17StronglyTypedUuidINS_12ClientId_TagEEERKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE Unexecuted instantiation: _ZN2yb16FromStringHelperEPNS_17StronglyTypedUuidINS_17TxnSnapshotId_TagEEERKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE Unexecuted instantiation: _ZN2yb16FromStringHelperEPNS_17StronglyTypedUuidINS_28TxnSnapshotRestorationId_TagEEERKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE Unexecuted instantiation: _ZN2yb16FromStringHelperEPNS_17StronglyTypedUuidINS_22SnapshotScheduleId_TagEEERKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE _ZN2yb16FromStringHelperEPNS_17StronglyTypedUuidINS_17TransactionId_TagEEERKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE Line | Count | Source | 54 | 317 | Result<TypeName> FromStringHelper(TypeName*, const std::string& strval) { \ | 55 | 317 | return BOOST_PP_CAT(TypeName, FromString)(strval); \ | 56 | 317 | } |
|
57 | | |
58 | | namespace yb { |
59 | | |
60 | | template <class Tag> |
61 | | class StronglyTypedUuid { |
62 | | public: |
63 | | // This is public so that we can construct a strongly-typed UUID value out of a regular one. |
64 | | // In that case we'll have to spell out the class name, which will enforce readability. |
65 | 59.1M | explicit StronglyTypedUuid(const Uuid& uuid) : uuid_(uuid) {} _ZN2yb17StronglyTypedUuidINS_28TxnSnapshotRestorationId_TagEEC2ERKNS_4UuidE Line | Count | Source | 65 | 863 | explicit StronglyTypedUuid(const Uuid& uuid) : uuid_(uuid) {} |
_ZN2yb17StronglyTypedUuidINS_22SnapshotScheduleId_TagEEC2ERKNS_4UuidE Line | Count | Source | 65 | 15 | explicit StronglyTypedUuid(const Uuid& uuid) : uuid_(uuid) {} |
_ZN2yb17StronglyTypedUuidINS_17TxnSnapshotId_TagEEC2ERKNS_4UuidE Line | Count | Source | 65 | 17 | explicit StronglyTypedUuid(const Uuid& uuid) : uuid_(uuid) {} |
_ZN2yb17StronglyTypedUuidINS_17TransactionId_TagEEC2ERKNS_4UuidE Line | Count | Source | 65 | 55.7M | explicit StronglyTypedUuid(const Uuid& uuid) : uuid_(uuid) {} |
_ZN2yb17StronglyTypedUuidINS_4util12TestUuid_TagEEC2ERKNS_4UuidE Line | Count | Source | 65 | 11 | explicit StronglyTypedUuid(const Uuid& uuid) : uuid_(uuid) {} |
_ZN2yb17StronglyTypedUuidINS_12ClientId_TagEEC2ERKNS_4UuidE Line | Count | Source | 65 | 3.45M | explicit StronglyTypedUuid(const Uuid& uuid) : uuid_(uuid) {} |
|
66 | | |
67 | 9.56M | StronglyTypedUuid<Tag>(uint64_t pb1, uint64_t pb2) { |
68 | 9.56M | pb1 = LittleEndian::FromHost64(pb1); |
69 | 9.56M | pb2 = LittleEndian::FromHost64(pb2); |
70 | 9.56M | memcpy(uuid_.data(), &pb1, sizeof(pb1)); |
71 | 9.56M | memcpy(uuid_.data() + sizeof(pb1), &pb2, sizeof(pb2)); |
72 | 9.56M | } _ZN2yb17StronglyTypedUuidINS_12ClientId_TagEEC2Eyy Line | Count | Source | 67 | 9.56M | StronglyTypedUuid<Tag>(uint64_t pb1, uint64_t pb2) { | 68 | 9.56M | pb1 = LittleEndian::FromHost64(pb1); | 69 | 9.56M | pb2 = LittleEndian::FromHost64(pb2); | 70 | 9.56M | memcpy(uuid_.data(), &pb1, sizeof(pb1)); | 71 | 9.56M | memcpy(uuid_.data() + sizeof(pb1), &pb2, sizeof(pb2)); | 72 | 9.56M | } |
_ZN2yb17StronglyTypedUuidINS_17TransactionId_TagEEC2Eyy Line | Count | Source | 67 | 1.30k | StronglyTypedUuid<Tag>(uint64_t pb1, uint64_t pb2) { | 68 | 1.30k | pb1 = LittleEndian::FromHost64(pb1); | 69 | 1.30k | pb2 = LittleEndian::FromHost64(pb2); | 70 | 1.30k | memcpy(uuid_.data(), &pb1, sizeof(pb1)); | 71 | 1.30k | memcpy(uuid_.data() + sizeof(pb1), &pb2, sizeof(pb2)); | 72 | 1.30k | } |
|
73 | | |
74 | | // Gets the underlying UUID, only if not undefined. |
75 | 74.5M | const boost::uuids::uuid& operator *() const { |
76 | 74.5M | return uuid_.impl(); |
77 | 74.5M | } Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_22SnapshotScheduleId_TagEEdeEv _ZNK2yb17StronglyTypedUuidINS_17TransactionId_TagEEdeEv Line | Count | Source | 75 | 50.3M | const boost::uuids::uuid& operator *() const { | 76 | 50.3M | return uuid_.impl(); | 77 | 50.3M | } |
Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_17TxnSnapshotId_TagEEdeEv _ZNK2yb17StronglyTypedUuidINS_4util12TestUuid_TagEEdeEv Line | Count | Source | 75 | 17 | const boost::uuids::uuid& operator *() const { | 76 | 17 | return uuid_.impl(); | 77 | 17 | } |
_ZNK2yb17StronglyTypedUuidINS_12ClientId_TagEEdeEv Line | Count | Source | 75 | 24.1M | const boost::uuids::uuid& operator *() const { | 76 | 24.1M | return uuid_.impl(); | 77 | 24.1M | } |
Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_28TxnSnapshotRestorationId_TagEEdeEv |
78 | | |
79 | | // Converts a UUID to a string, returns "<Undefined{ClassName}>" if UUID is undefined, where |
80 | | // {ClassName} is the name associated with the Tag class. |
81 | 2.48M | std::string ToString() const { |
82 | 2.48M | return uuid_.ToString(); |
83 | 2.48M | } _ZNK2yb17StronglyTypedUuidINS_17TransactionId_TagEE8ToStringEv Line | Count | Source | 81 | 2.48M | std::string ToString() const { | 82 | 2.48M | return uuid_.ToString(); | 83 | 2.48M | } |
Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_22SnapshotScheduleId_TagEE8ToStringEv Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_17TxnSnapshotId_TagEE8ToStringEv Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_28TxnSnapshotRestorationId_TagEE8ToStringEv _ZNK2yb17StronglyTypedUuidINS_4util12TestUuid_TagEE8ToStringEv Line | Count | Source | 81 | 2 | std::string ToString() const { | 82 | 2 | return uuid_.ToString(); | 83 | 2 | } |
Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_12ClientId_TagEE8ToStringEv |
84 | | |
85 | | // Returns true iff the UUID is nil. |
86 | 21.5M | bool IsNil() const { |
87 | 21.5M | return uuid_.IsNil(); |
88 | 21.5M | } _ZNK2yb17StronglyTypedUuidINS_17TransactionId_TagEE5IsNilEv Line | Count | Source | 86 | 7.22M | bool IsNil() const { | 87 | 7.22M | return uuid_.IsNil(); | 88 | 7.22M | } |
_ZNK2yb17StronglyTypedUuidINS_28TxnSnapshotRestorationId_TagEE5IsNilEv Line | Count | Source | 86 | 862 | bool IsNil() const { | 87 | 862 | return uuid_.IsNil(); | 88 | 862 | } |
_ZNK2yb17StronglyTypedUuidINS_4util12TestUuid_TagEE5IsNilEv Line | Count | Source | 86 | 3 | bool IsNil() const { | 87 | 3 | return uuid_.IsNil(); | 88 | 3 | } |
_ZNK2yb17StronglyTypedUuidINS_12ClientId_TagEE5IsNilEv Line | Count | Source | 86 | 14.3M | bool IsNil() const { | 87 | 14.3M | return uuid_.IsNil(); | 88 | 14.3M | } |
_ZNK2yb17StronglyTypedUuidINS_22SnapshotScheduleId_TagEE5IsNilEv Line | Count | Source | 86 | 14 | bool IsNil() const { | 87 | 14 | return uuid_.IsNil(); | 88 | 14 | } |
_ZNK2yb17StronglyTypedUuidINS_17TxnSnapshotId_TagEE5IsNilEv Line | Count | Source | 86 | 16 | bool IsNil() const { | 87 | 16 | return uuid_.IsNil(); | 88 | 16 | } |
|
89 | | |
90 | 892 | explicit operator bool() const { |
91 | 892 | return !IsNil(); |
92 | 892 | } _ZNK2yb17StronglyTypedUuidINS_22SnapshotScheduleId_TagEEcvbEv Line | Count | Source | 90 | 14 | explicit operator bool() const { | 91 | 14 | return !IsNil(); | 92 | 14 | } |
_ZNK2yb17StronglyTypedUuidINS_28TxnSnapshotRestorationId_TagEEcvbEv Line | Count | Source | 90 | 862 | explicit operator bool() const { | 91 | 862 | return !IsNil(); | 92 | 862 | } |
_ZNK2yb17StronglyTypedUuidINS_17TxnSnapshotId_TagEEcvbEv Line | Count | Source | 90 | 16 | explicit operator bool() const { | 91 | 16 | return !IsNil(); | 92 | 16 | } |
|
93 | | |
94 | 0 | bool operator!() const { |
95 | 0 | return IsNil(); |
96 | 0 | } Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_28TxnSnapshotRestorationId_TagEEntEv Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_17TxnSnapshotId_TagEEntEv Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_22SnapshotScheduleId_TagEEntEv |
97 | | |
98 | | // Represent UUID as pair of uint64 for protobuf serialization. |
99 | | // This serialization is independent of the byte order on the machine. |
100 | | // For instance we could convert UUID to pair of uint64 on little endian machine, transfer them |
101 | | // to big endian machine and UUID created from them will be the same. |
102 | 1.32M | std::pair<uint64_t, uint64_t> ToUInt64Pair() const { |
103 | 1.32M | std::pair<uint64_t, uint64_t> result; |
104 | 1.32M | memcpy(&result.first, uuid_.data(), sizeof(result.first)); |
105 | 1.32M | memcpy(&result.second, uuid_.data() + sizeof(result.first), sizeof(result.second)); |
106 | 1.32M | return std::pair<uint64_t, uint64_t>( |
107 | 1.32M | LittleEndian::ToHost64(result.first), LittleEndian::ToHost64(result.second)); |
108 | 1.32M | } |
109 | | |
110 | | // Represents an invalid UUID. |
111 | 42.1M | static StronglyTypedUuid<Tag> Nil() { |
112 | 42.1M | return StronglyTypedUuid(Uuid::Nil()); |
113 | 42.1M | } Unexecuted instantiation: _ZN2yb17StronglyTypedUuidINS_28TxnSnapshotRestorationId_TagEE3NilEv _ZN2yb17StronglyTypedUuidINS_22SnapshotScheduleId_TagEE3NilEv Line | Count | Source | 111 | 1 | static StronglyTypedUuid<Tag> Nil() { | 112 | 1 | return StronglyTypedUuid(Uuid::Nil()); | 113 | 1 | } |
Unexecuted instantiation: _ZN2yb17StronglyTypedUuidINS_17TxnSnapshotId_TagEE3NilEv _ZN2yb17StronglyTypedUuidINS_17TransactionId_TagEE3NilEv Line | Count | Source | 111 | 38.7M | static StronglyTypedUuid<Tag> Nil() { | 112 | 38.7M | return StronglyTypedUuid(Uuid::Nil()); | 113 | 38.7M | } |
_ZN2yb17StronglyTypedUuidINS_4util12TestUuid_TagEE3NilEv Line | Count | Source | 111 | 6 | static StronglyTypedUuid<Tag> Nil() { | 112 | 6 | return StronglyTypedUuid(Uuid::Nil()); | 113 | 6 | } |
_ZN2yb17StronglyTypedUuidINS_12ClientId_TagEE3NilEv Line | Count | Source | 111 | 3.42M | static StronglyTypedUuid<Tag> Nil() { | 112 | 3.42M | return StronglyTypedUuid(Uuid::Nil()); | 113 | 3.42M | } |
|
114 | | |
115 | | // Converts a string to a StronglyTypedUuid, if such a conversion exists. |
116 | | // The empty string maps to undefined. |
117 | 315 | static Result<StronglyTypedUuid<Tag>> FromString(const std::string& strval) { |
118 | 315 | return FromStringHelper(static_cast<StronglyTypedUuid<Tag>*>(nullptr), strval); |
119 | 315 | } Unexecuted instantiation: _ZN2yb17StronglyTypedUuidINS_28TxnSnapshotRestorationId_TagEE10FromStringERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE Unexecuted instantiation: _ZN2yb17StronglyTypedUuidINS_22SnapshotScheduleId_TagEE10FromStringERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE _ZN2yb17StronglyTypedUuidINS_17TransactionId_TagEE10FromStringERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE Line | Count | Source | 117 | 315 | static Result<StronglyTypedUuid<Tag>> FromString(const std::string& strval) { | 118 | 315 | return FromStringHelper(static_cast<StronglyTypedUuid<Tag>*>(nullptr), strval); | 119 | 315 | } |
|
120 | | |
121 | | // Generate a random StronglyTypedUuid. |
122 | 275k | static StronglyTypedUuid<Tag> GenerateRandom() { |
123 | 275k | return StronglyTypedUuid(Uuid::Generate()); |
124 | 275k | } _ZN2yb17StronglyTypedUuidINS_17TransactionId_TagEE14GenerateRandomEv Line | Count | Source | 122 | 243k | static StronglyTypedUuid<Tag> GenerateRandom() { | 123 | 243k | return StronglyTypedUuid(Uuid::Generate()); | 124 | 243k | } |
_ZN2yb17StronglyTypedUuidINS_17TxnSnapshotId_TagEE14GenerateRandomEv Line | Count | Source | 122 | 1 | static StronglyTypedUuid<Tag> GenerateRandom() { | 123 | 1 | return StronglyTypedUuid(Uuid::Generate()); | 124 | 1 | } |
_ZN2yb17StronglyTypedUuidINS_28TxnSnapshotRestorationId_TagEE14GenerateRandomEv Line | Count | Source | 122 | 1 | static StronglyTypedUuid<Tag> GenerateRandom() { | 123 | 1 | return StronglyTypedUuid(Uuid::Generate()); | 124 | 1 | } |
_ZN2yb17StronglyTypedUuidINS_4util12TestUuid_TagEE14GenerateRandomEv Line | Count | Source | 122 | 2 | static StronglyTypedUuid<Tag> GenerateRandom() { | 123 | 2 | return StronglyTypedUuid(Uuid::Generate()); | 124 | 2 | } |
Unexecuted instantiation: _ZN2yb17StronglyTypedUuidINS_22SnapshotScheduleId_TagEE14GenerateRandomEv _ZN2yb17StronglyTypedUuidINS_12ClientId_TagEE14GenerateRandomEv Line | Count | Source | 122 | 31.9k | static StronglyTypedUuid<Tag> GenerateRandom() { | 123 | 31.9k | return StronglyTypedUuid(Uuid::Generate()); | 124 | 31.9k | } |
|
125 | | |
126 | 200k | static StronglyTypedUuid<Tag> GenerateRandom(std::mt19937_64* rng) { |
127 | 200k | return StronglyTypedUuid(Uuid::Generate(rng)); |
128 | 200k | } |
129 | | |
130 | 1.12M | uint8_t* data() { |
131 | 1.12M | return uuid_.data(); |
132 | 1.12M | } _ZN2yb17StronglyTypedUuidINS_17TransactionId_TagEE4dataEv Line | Count | Source | 130 | 1.12M | uint8_t* data() { | 131 | 1.12M | return uuid_.data(); | 132 | 1.12M | } |
Unexecuted instantiation: _ZN2yb17StronglyTypedUuidINS_17TxnSnapshotId_TagEE4dataEv Unexecuted instantiation: _ZN2yb17StronglyTypedUuidINS_22SnapshotScheduleId_TagEE4dataEv Unexecuted instantiation: _ZN2yb17StronglyTypedUuidINS_28TxnSnapshotRestorationId_TagEE4dataEv |
133 | | |
134 | 2.15M | const uint8_t* data() const { |
135 | 2.15M | return uuid_.data(); |
136 | 2.15M | } Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_28TxnSnapshotRestorationId_TagEE4dataEv Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_17TxnSnapshotId_TagEE4dataEv Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_22SnapshotScheduleId_TagEE4dataEv _ZNK2yb17StronglyTypedUuidINS_17TransactionId_TagEE4dataEv Line | Count | Source | 134 | 2.15M | const uint8_t* data() const { | 135 | 2.15M | return uuid_.data(); | 136 | 2.15M | } |
|
137 | | |
138 | 3.27M | size_t size() const { |
139 | 3.27M | return uuid_.size(); |
140 | 3.27M | } _ZNK2yb17StronglyTypedUuidINS_17TransactionId_TagEE4sizeEv Line | Count | Source | 138 | 3.27M | size_t size() const { | 139 | 3.27M | return uuid_.size(); | 140 | 3.27M | } |
Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_28TxnSnapshotRestorationId_TagEE4sizeEv Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_22SnapshotScheduleId_TagEE4sizeEv Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_17TxnSnapshotId_TagEE4sizeEv |
141 | | |
142 | 101M | Slice AsSlice() const { |
143 | 101M | return Slice(uuid_.AsSlice()); |
144 | 101M | } Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_17TxnSnapshotId_TagEE7AsSliceEv Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_22SnapshotScheduleId_TagEE7AsSliceEv _ZNK2yb17StronglyTypedUuidINS_17TransactionId_TagEE7AsSliceEv Line | Count | Source | 142 | 101M | Slice AsSlice() const { | 143 | 101M | return Slice(uuid_.AsSlice()); | 144 | 101M | } |
Unexecuted instantiation: _ZNK2yb17StronglyTypedUuidINS_28TxnSnapshotRestorationId_TagEE7AsSliceEv |
145 | | |
146 | 72.3M | static size_t StaticSize() { |
147 | 72.3M | return boost::uuids::uuid::static_size(); |
148 | 72.3M | } |
149 | | |
150 | 0 | static size_t StaticStringSize() { |
151 | 0 | return 36; |
152 | 0 | } |
153 | | |
154 | | private: |
155 | | // Represented as an optional UUID. |
156 | | Uuid uuid_; |
157 | | }; |
158 | | |
159 | | template <class Tag> |
160 | 51.6k | std::ostream& operator << (std::ostream& out, const StronglyTypedUuid<Tag>& uuid) { |
161 | 51.6k | return out << uuid.ToString(); |
162 | 51.6k | } _ZN2yblsINS_17TransactionId_TagEEERNSt3__113basic_ostreamIcNS2_11char_traitsIcEEEES7_RKNS_17StronglyTypedUuidIT_EE Line | Count | Source | 160 | 51.6k | std::ostream& operator << (std::ostream& out, const StronglyTypedUuid<Tag>& uuid) { | 161 | 51.6k | return out << uuid.ToString(); | 162 | 51.6k | } |
Unexecuted instantiation: _ZN2yblsINS_22SnapshotScheduleId_TagEEERNSt3__113basic_ostreamIcNS2_11char_traitsIcEEEES7_RKNS_17StronglyTypedUuidIT_EE Unexecuted instantiation: _ZN2yblsINS_17TxnSnapshotId_TagEEERNSt3__113basic_ostreamIcNS2_11char_traitsIcEEEES7_RKNS_17StronglyTypedUuidIT_EE Unexecuted instantiation: _ZN2yblsINS_28TxnSnapshotRestorationId_TagEEERNSt3__113basic_ostreamIcNS2_11char_traitsIcEEEES7_RKNS_17StronglyTypedUuidIT_EE Unexecuted instantiation: _ZN2yblsINS_4util12TestUuid_TagEEERNSt3__113basic_ostreamIcNS3_11char_traitsIcEEEES8_RKNS_17StronglyTypedUuidIT_EE Unexecuted instantiation: _ZN2yblsINS_12ClientId_TagEEERNSt3__113basic_ostreamIcNS2_11char_traitsIcEEEES7_RKNS_17StronglyTypedUuidIT_EE |
163 | | |
164 | | template <class Tag> |
165 | 22.2M | bool operator == (const StronglyTypedUuid<Tag>& lhs, const StronglyTypedUuid<Tag>& rhs) noexcept { |
166 | 22.2M | return *lhs == *rhs; |
167 | 22.2M | } Unexecuted instantiation: _ZN2ybeqINS_22SnapshotScheduleId_TagEEEbRKNS_17StronglyTypedUuidIT_EES6_ _ZN2ybeqINS_17TransactionId_TagEEEbRKNS_17StronglyTypedUuidIT_EES6_ Line | Count | Source | 165 | 14.0M | bool operator == (const StronglyTypedUuid<Tag>& lhs, const StronglyTypedUuid<Tag>& rhs) noexcept { | 166 | 14.0M | return *lhs == *rhs; | 167 | 14.0M | } |
_ZN2ybeqINS_4util12TestUuid_TagEEEbRKNS_17StronglyTypedUuidIT_EES7_ Line | Count | Source | 165 | 8 | bool operator == (const StronglyTypedUuid<Tag>& lhs, const StronglyTypedUuid<Tag>& rhs) noexcept { | 166 | 8 | return *lhs == *rhs; | 167 | 8 | } |
_ZN2ybeqINS_12ClientId_TagEEEbRKNS_17StronglyTypedUuidIT_EES6_ Line | Count | Source | 165 | 8.12M | bool operator == (const StronglyTypedUuid<Tag>& lhs, const StronglyTypedUuid<Tag>& rhs) noexcept { | 166 | 8.12M | return *lhs == *rhs; | 167 | 8.12M | } |
Unexecuted instantiation: _ZN2ybeqINS_17TxnSnapshotId_TagEEEbRKNS_17StronglyTypedUuidIT_EES6_ Unexecuted instantiation: _ZN2ybeqINS_28TxnSnapshotRestorationId_TagEEEbRKNS_17StronglyTypedUuidIT_EES6_ |
168 | | |
169 | | template <class Tag> |
170 | 2 | bool operator != (const StronglyTypedUuid<Tag>& lhs, const StronglyTypedUuid<Tag>& rhs) noexcept { |
171 | 2 | return !(lhs == rhs); |
172 | 2 | } _ZN2ybneINS_4util12TestUuid_TagEEEbRKNS_17StronglyTypedUuidIT_EES7_ Line | Count | Source | 170 | 2 | bool operator != (const StronglyTypedUuid<Tag>& lhs, const StronglyTypedUuid<Tag>& rhs) noexcept { | 171 | 2 | return !(lhs == rhs); | 172 | 2 | } |
Unexecuted instantiation: _ZN2ybneINS_17TxnSnapshotId_TagEEEbRKNS_17StronglyTypedUuidIT_EES6_ |
173 | | |
174 | | template <class Tag> |
175 | 0 | bool operator < (const StronglyTypedUuid<Tag>& lhs, const StronglyTypedUuid<Tag>& rhs) noexcept { |
176 | 0 | return *lhs < *rhs; |
177 | 0 | } Unexecuted instantiation: _ZN2ybltINS_17TxnSnapshotId_TagEEEbRKNS_17StronglyTypedUuidIT_EES6_ Unexecuted instantiation: _ZN2ybltINS_22SnapshotScheduleId_TagEEEbRKNS_17StronglyTypedUuidIT_EES6_ Unexecuted instantiation: _ZN2ybltINS_17TransactionId_TagEEEbRKNS_17StronglyTypedUuidIT_EES6_ |
178 | | |
179 | | template <class Tag> |
180 | | bool operator > (const StronglyTypedUuid<Tag>& lhs, const StronglyTypedUuid<Tag>& rhs) noexcept { |
181 | | return rhs < lhs; |
182 | | } |
183 | | |
184 | | template <class Tag> |
185 | | bool operator <= (const StronglyTypedUuid<Tag>& lhs, const StronglyTypedUuid<Tag>& rhs) noexcept { |
186 | | return !(rhs < lhs); |
187 | | } |
188 | | |
189 | | template <class Tag> |
190 | 0 | bool operator >= (const StronglyTypedUuid<Tag>& lhs, const StronglyTypedUuid<Tag>& rhs) noexcept { |
191 | 0 | return !(lhs < rhs); |
192 | 0 | } |
193 | | |
194 | | template <class Tag> |
195 | 30.0M | std::size_t hash_value(const StronglyTypedUuid<Tag>& u) noexcept { |
196 | 30.0M | return hash_value(*u); |
197 | 30.0M | } Unexecuted instantiation: _ZN2yb10hash_valueINS_22SnapshotScheduleId_TagEEEmRKNS_17StronglyTypedUuidIT_EE _ZN2yb10hash_valueINS_17TransactionId_TagEEEmRKNS_17StronglyTypedUuidIT_EE Line | Count | Source | 195 | 22.1M | std::size_t hash_value(const StronglyTypedUuid<Tag>& u) noexcept { | 196 | 22.1M | return hash_value(*u); | 197 | 22.1M | } |
_ZN2yb10hash_valueINS_12ClientId_TagEEEmRKNS_17StronglyTypedUuidIT_EE Line | Count | Source | 195 | 7.92M | std::size_t hash_value(const StronglyTypedUuid<Tag>& u) noexcept { | 196 | 7.92M | return hash_value(*u); | 197 | 7.92M | } |
Unexecuted instantiation: _ZN2yb10hash_valueINS_17TxnSnapshotId_TagEEEmRKNS_17StronglyTypedUuidIT_EE Unexecuted instantiation: _ZN2yb10hash_valueINS_28TxnSnapshotRestorationId_TagEEEmRKNS_17StronglyTypedUuidIT_EE |
198 | | |
199 | | } // namespace yb |
200 | | |
201 | | #endif // YB_UTIL_STRONGLY_TYPED_UUID_H |