2017-07-04 10:42:53 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Common/UInt128.h>
|
2017-12-26 19:00:20 +00:00
|
|
|
#include <common/strong_typedef.h>
|
2020-02-10 13:40:42 +00:00
|
|
|
#include <Common/thread_local_rng.h>
|
2017-07-04 10:42:53 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2018-08-10 04:02:56 +00:00
|
|
|
STRONG_TYPEDEF(UInt128, UUID)
|
2017-07-04 10:42:53 +00:00
|
|
|
|
2020-02-10 13:40:42 +00:00
|
|
|
namespace UUIDHelpers
|
|
|
|
{
|
|
|
|
inline UUID generateV4()
|
|
|
|
{
|
|
|
|
UInt128 res{thread_local_rng(), thread_local_rng()};
|
|
|
|
res.low = (res.low & 0xffffffffffff0fffull) | 0x0000000000004000ull;
|
|
|
|
res.high = (res.high & 0x3fffffffffffffffull) | 0x8000000000000000ull;
|
|
|
|
return UUID{res};
|
|
|
|
}
|
|
|
|
|
|
|
|
const UUID Nil = UUID(UInt128(0, 0));
|
|
|
|
}
|
|
|
|
|
2017-07-04 10:42:53 +00:00
|
|
|
}
|