aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkhvostikovao <khvostikovao@yandex-team.ru>2022-02-10 16:52:06 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:52:06 +0300
commit06189cb2ee513c85b125b5bd1c879a5a4f05ca77 (patch)
treeb1d025e74b437ef31f6dcfde01766663c842197b
parente1eef5fd2ea964227b9be2c182415857c35e1290 (diff)
downloadydb-06189cb2ee513c85b125b5bd1c879a5a4f05ca77.tar.gz
Restoring authorship annotation for <khvostikovao@yandex-team.ru>. Commit 1 of 2.
-rw-r--r--util/generic/guid.cpp34
-rw-r--r--util/generic/guid.h12
-rw-r--r--util/generic/guid_ut.cpp12
3 files changed, 29 insertions, 29 deletions
diff --git a/util/generic/guid.cpp b/util/generic/guid.cpp
index 8b907457bc..ef023aa5e2 100644
--- a/util/generic/guid.cpp
+++ b/util/generic/guid.cpp
@@ -48,23 +48,23 @@ void CreateGuid(TGUID* res) {
WriteUnaligned<ui64>(&dw[1], RandomNumber<ui64>());
}
-TGUID TGUID::CreateTimebased() {
- TGUID result;
- // GUID_EPOCH_OFFSET is the number of 100-ns intervals between the
- // UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
- constexpr ui64 GUID_EPOCH_OFFSET = 0x01b21dd213814000;
- const ui64 timestamp = Now().NanoSeconds() / 100 + GUID_EPOCH_OFFSET;
- result.dw[0] = ui32(timestamp & 0xffffffff); // time low
- const ui32 timeMid = ui32((timestamp >> 32) & 0xffff);
- constexpr ui32 UUID_VERSION = 1;
- const ui32 timeHighAndVersion = ui16((timestamp >> 48) & 0x0fff) | (UUID_VERSION << 12);
- result.dw[1] = (timeMid << 16) | timeHighAndVersion;
- const ui32 clockSeq = RandomNumber<ui32>(0x3fff) | 0x8000;
- result.dw[2] = (clockSeq << 16) | RandomNumber<ui16>();
- result.dw[3] = RandomNumber<ui32>() | (1 << 24);
- return result;
-}
-
+TGUID TGUID::CreateTimebased() {
+ TGUID result;
+ // GUID_EPOCH_OFFSET is the number of 100-ns intervals between the
+ // UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
+ constexpr ui64 GUID_EPOCH_OFFSET = 0x01b21dd213814000;
+ const ui64 timestamp = Now().NanoSeconds() / 100 + GUID_EPOCH_OFFSET;
+ result.dw[0] = ui32(timestamp & 0xffffffff); // time low
+ const ui32 timeMid = ui32((timestamp >> 32) & 0xffff);
+ constexpr ui32 UUID_VERSION = 1;
+ const ui32 timeHighAndVersion = ui16((timestamp >> 48) & 0x0fff) | (UUID_VERSION << 12);
+ result.dw[1] = (timeMid << 16) | timeHighAndVersion;
+ const ui32 clockSeq = RandomNumber<ui32>(0x3fff) | 0x8000;
+ result.dw[2] = (clockSeq << 16) | RandomNumber<ui16>();
+ result.dw[3] = RandomNumber<ui32>() | (1 << 24);
+ return result;
+}
+
TString GetGuidAsString(const TGUID& g) {
return g.AsGuidString();
}
diff --git a/util/generic/guid.h b/util/generic/guid.h
index 2bf6c8ad99..8267935bcc 100644
--- a/util/generic/guid.h
+++ b/util/generic/guid.h
@@ -36,12 +36,12 @@ struct TGUID {
TString AsUuidString() const;
static TGUID Create();
-
- /**
- * Generate time based UUID version 1 RFC4122 GUID
- * https://datatracker.ietf.org/doc/html/rfc4122#section-4.1
- **/
- static TGUID CreateTimebased();
+
+ /**
+ * Generate time based UUID version 1 RFC4122 GUID
+ * https://datatracker.ietf.org/doc/html/rfc4122#section-4.1
+ **/
+ static TGUID CreateTimebased();
};
constexpr bool operator==(const TGUID& a, const TGUID& b) noexcept {
diff --git a/util/generic/guid_ut.cpp b/util/generic/guid_ut.cpp
index 048354ff39..a8fb32ea5f 100644
--- a/util/generic/guid_ut.cpp
+++ b/util/generic/guid_ut.cpp
@@ -119,10 +119,10 @@ Y_UNIT_TEST_SUITE(TGuidTest) {
UNIT_ASSERT_VALUES_EQUAL(guid.AsGuidString(), "5612-12000000-123-0");
UNIT_ASSERT_VALUES_EQUAL(guid.AsUuidString(), "00005612-1200-0000-0000-012300000000");
}
-
- Y_UNIT_TEST(TimeBased) {
- TString guid = TGUID::CreateTimebased().AsUuidString();
- UNIT_ASSERT(!guid.empty());
- UNIT_ASSERT_EQUAL(guid[14], '1');
- }
+
+ Y_UNIT_TEST(TimeBased) {
+ TString guid = TGUID::CreateTimebased().AsUuidString();
+ UNIT_ASSERT(!guid.empty());
+ UNIT_ASSERT_EQUAL(guid[14], '1');
+ }
}