ClickHouse/src/Core/UUID.cpp

20 lines
402 B
C++
Raw Normal View History

2021-01-27 01:12:24 +00:00
#include <Core/UUID.h>
#include <Common/thread_local_rng.h>
namespace DB
{
namespace UUIDHelpers
{
UUID generateV4()
{
UInt128 res{thread_local_rng(), thread_local_rng()};
res.items[0] = (res.items[0] & 0xffffffffffff0fffull) | 0x0000000000004000ull;
res.items[1] = (res.items[1] & 0x3fffffffffffffffull) | 0x8000000000000000ull;
return UUID{res};
}
}
}