aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-02-25 11:28:36 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-02-25 11:28:36 +0300
commit840813e444ead1827cba829e6ec0fb9739e03c4a (patch)
treed02d3fc3388eb180ec62d570cc94920df0282938 /library
parent66834feb30614a28410b37b4be1842f6eb9fc7ed (diff)
downloadydb-840813e444ead1827cba829e6ec0fb9739e03c4a.tar.gz
intermediate changes
ref:e3f00ef4e6dea6578b7e9ead4e6c020e1e259495
Diffstat (limited to 'library')
-rw-r--r--library/cpp/actors/protos/CMakeLists.txt4
-rw-r--r--library/cpp/histogram/adaptive/protos/CMakeLists.txt4
-rw-r--r--library/cpp/lwtrace/protos/CMakeLists.txt4
-rw-r--r--library/cpp/messagebus/monitoring/CMakeLists.txt4
-rw-r--r--library/cpp/monlib/encode/legacy_protobuf/protos/CMakeLists.txt4
-rw-r--r--library/cpp/protobuf/util/proto/CMakeLists.txt4
-rw-r--r--library/cpp/retry/protos/CMakeLists.txt4
-rw-r--r--library/cpp/yt/misc/CMakeLists.txt1
-rw-r--r--library/cpp/yt/misc/farm_hash.h54
-rw-r--r--library/cpp/yt/misc/unittests/farm_fingerprint_stability_ut.cpp39
-rw-r--r--library/cpp/yt/misc/unittests/ya.make1
-rw-r--r--library/cpp/yt/misc/ya.make1
12 files changed, 96 insertions, 28 deletions
diff --git a/library/cpp/actors/protos/CMakeLists.txt b/library/cpp/actors/protos/CMakeLists.txt
index 4fc386c54c..12369cde0e 100644
--- a/library/cpp/actors/protos/CMakeLists.txt
+++ b/library/cpp/actors/protos/CMakeLists.txt
@@ -10,7 +10,3 @@ target_proto_messages(cpp-actors-protos PRIVATE
${CMAKE_SOURCE_DIR}/library/cpp/actors/protos/services_common.proto
${CMAKE_SOURCE_DIR}/library/cpp/actors/protos/unittests.proto
)
-target_proto_plugin(cpp-actors-protos
- cpp_styleguide
- cpp_styleguide
-)
diff --git a/library/cpp/histogram/adaptive/protos/CMakeLists.txt b/library/cpp/histogram/adaptive/protos/CMakeLists.txt
index 272f39ddce..0ad780d702 100644
--- a/library/cpp/histogram/adaptive/protos/CMakeLists.txt
+++ b/library/cpp/histogram/adaptive/protos/CMakeLists.txt
@@ -7,7 +7,3 @@ target_link_libraries(histogram-adaptive-protos PUBLIC
target_proto_messages(histogram-adaptive-protos PRIVATE
${CMAKE_SOURCE_DIR}/library/cpp/histogram/adaptive/protos/histo.proto
)
-target_proto_plugin(histogram-adaptive-protos
- cpp_styleguide
- cpp_styleguide
-)
diff --git a/library/cpp/lwtrace/protos/CMakeLists.txt b/library/cpp/lwtrace/protos/CMakeLists.txt
index 6cceb38524..909a9a2191 100644
--- a/library/cpp/lwtrace/protos/CMakeLists.txt
+++ b/library/cpp/lwtrace/protos/CMakeLists.txt
@@ -7,7 +7,3 @@ target_link_libraries(cpp-lwtrace-protos PUBLIC
target_proto_messages(cpp-lwtrace-protos PRIVATE
${CMAKE_SOURCE_DIR}/library/cpp/lwtrace/protos/lwtrace.proto
)
-target_proto_plugin(cpp-lwtrace-protos
- cpp_styleguide
- cpp_styleguide
-)
diff --git a/library/cpp/messagebus/monitoring/CMakeLists.txt b/library/cpp/messagebus/monitoring/CMakeLists.txt
index ec708863aa..f31ba07768 100644
--- a/library/cpp/messagebus/monitoring/CMakeLists.txt
+++ b/library/cpp/messagebus/monitoring/CMakeLists.txt
@@ -8,7 +8,3 @@ target_link_libraries(cpp-messagebus-monitoring PUBLIC
target_proto_messages(cpp-messagebus-monitoring PRIVATE
${CMAKE_SOURCE_DIR}/library/cpp/messagebus/monitoring/mon_proto.proto
)
-target_proto_plugin(cpp-messagebus-monitoring
- cpp_styleguide
- cpp_styleguide
-)
diff --git a/library/cpp/monlib/encode/legacy_protobuf/protos/CMakeLists.txt b/library/cpp/monlib/encode/legacy_protobuf/protos/CMakeLists.txt
index ea9bd6c6d9..92064d1387 100644
--- a/library/cpp/monlib/encode/legacy_protobuf/protos/CMakeLists.txt
+++ b/library/cpp/monlib/encode/legacy_protobuf/protos/CMakeLists.txt
@@ -7,7 +7,3 @@ target_link_libraries(encode-legacy_protobuf-protos PUBLIC
target_proto_messages(encode-legacy_protobuf-protos PRIVATE
${CMAKE_SOURCE_DIR}/library/cpp/monlib/encode/legacy_protobuf/protos/metric_meta.proto
)
-target_proto_plugin(encode-legacy_protobuf-protos
- cpp_styleguide
- cpp_styleguide
-)
diff --git a/library/cpp/protobuf/util/proto/CMakeLists.txt b/library/cpp/protobuf/util/proto/CMakeLists.txt
index 7c3a768355..572a1ef66c 100644
--- a/library/cpp/protobuf/util/proto/CMakeLists.txt
+++ b/library/cpp/protobuf/util/proto/CMakeLists.txt
@@ -7,7 +7,3 @@ target_link_libraries(protobuf-util-proto PUBLIC
target_proto_messages(protobuf-util-proto PRIVATE
${CMAKE_SOURCE_DIR}/library/cpp/protobuf/util/proto/merge.proto
)
-target_proto_plugin(protobuf-util-proto
- cpp_styleguide
- cpp_styleguide
-)
diff --git a/library/cpp/retry/protos/CMakeLists.txt b/library/cpp/retry/protos/CMakeLists.txt
index 3331178ecc..c8c8a85208 100644
--- a/library/cpp/retry/protos/CMakeLists.txt
+++ b/library/cpp/retry/protos/CMakeLists.txt
@@ -7,7 +7,3 @@ target_link_libraries(cpp-retry-protos PUBLIC
target_proto_messages(cpp-retry-protos PRIVATE
${CMAKE_SOURCE_DIR}/library/cpp/retry/protos/retry_options.proto
)
-target_proto_plugin(cpp-retry-protos
- cpp_styleguide
- cpp_styleguide
-)
diff --git a/library/cpp/yt/misc/CMakeLists.txt b/library/cpp/yt/misc/CMakeLists.txt
index c9ac50fd71..cccaef7540 100644
--- a/library/cpp/yt/misc/CMakeLists.txt
+++ b/library/cpp/yt/misc/CMakeLists.txt
@@ -2,6 +2,7 @@ add_library(cpp-yt-misc)
target_link_libraries(cpp-yt-misc PUBLIC
contrib-libs-cxxsupp
yutil
+ contrib-libs-farmhash
cpp-yt-exception
)
target_sources(cpp-yt-misc PRIVATE
diff --git a/library/cpp/yt/misc/farm_hash.h b/library/cpp/yt/misc/farm_hash.h
new file mode 100644
index 0000000000..be18b3bfc2
--- /dev/null
+++ b/library/cpp/yt/misc/farm_hash.h
@@ -0,0 +1,54 @@
+#pragma once
+
+#include <contrib/libs/farmhash/farmhash.h>
+
+namespace NYT {
+
+using TFingerprint = ui64;
+
+////////////////////////////////////////////////////////////////////////////////
+
+static inline TFingerprint FarmHash(ui64 value)
+{
+ return ::util::Fingerprint(value);
+}
+
+static inline TFingerprint FarmHash(const void* buf, size_t len)
+{
+ return ::util::Hash64(static_cast<const char*>(buf), len);
+}
+
+static inline TFingerprint FarmHash(const void* buf, size_t len, ui64 seed)
+{
+ return ::util::Hash64WithSeed(static_cast<const char*>(buf), len, seed);
+}
+
+static inline TFingerprint FarmFingerprint(ui64 value)
+{
+ return ::util::Fingerprint(value);
+}
+
+static inline TFingerprint FarmFingerprint(const void* buf, size_t len)
+{
+ return ::util::Fingerprint64(static_cast<const char*>(buf), len);
+}
+
+static inline TFingerprint FarmFingerprint(ui64 first, ui64 second)
+{
+ return ::util::Fingerprint(::util::Uint128(first, second));
+}
+
+// Forever-fixed Google FarmHash fingerprint.
+template <class T>
+TFingerprint FarmFingerprint(const T* begin, const T* end)
+{
+ ui64 result = 0xdeadc0de;
+ for (const auto* value = begin; value < end; ++value) {
+ result = FarmFingerprint(result, FarmFingerprint(*value));
+ }
+ return result ^ (end - begin);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+} // namespace NYT
diff --git a/library/cpp/yt/misc/unittests/farm_fingerprint_stability_ut.cpp b/library/cpp/yt/misc/unittests/farm_fingerprint_stability_ut.cpp
new file mode 100644
index 0000000000..77726661ee
--- /dev/null
+++ b/library/cpp/yt/misc/unittests/farm_fingerprint_stability_ut.cpp
@@ -0,0 +1,39 @@
+#include <yt/yt/core/test_framework/framework.h>
+
+#include <yt/yt/core/misc/farm_hash.h>
+
+namespace NYT {
+namespace {
+
+/////////////////////////////////////////////////////////////////////////////
+/*
+ * NB: This provides a sanity check for stability
+ * of FarmHash and FarmFingerprint functions.
+ */
+
+TEST(TFarmHashTest, Test)
+{
+ // NB: At the time of creation of this test, FarmHash function relied on
+ // FarmFingerprint, however we do not require it, so this test is more or less a sanity check.
+ static_assert(std::is_same<ui64, decltype(FarmHash(42ULL))>::value);
+ EXPECT_EQ(17355217915646310598ULL, FarmHash(42ULL));
+}
+
+TEST(TFarmFingerprintTest, Test)
+{
+ static_assert(std::is_same<ui64, decltype(FarmFingerprint(42ULL))>::value);
+ EXPECT_EQ(17355217915646310598ULL, FarmFingerprint(42ULL));
+
+ TString buf = "MDwhat?";
+
+ static_assert(std::is_same<ui64, decltype(FarmFingerprint(buf.Data(), buf.Size()))>::value);
+ EXPECT_EQ(10997514911242581312ULL, FarmFingerprint(buf.Data(), buf.Size()));
+
+ static_assert(std::is_same<ui64, decltype(FarmFingerprint(1234ULL, 5678ULL))>::value);
+ EXPECT_EQ(16769064555670434975ULL, FarmFingerprint(1234ULL, 5678ULL));
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace
+} // namespace NYT
diff --git a/library/cpp/yt/misc/unittests/ya.make b/library/cpp/yt/misc/unittests/ya.make
index 690082ca59..0a4ebd5641 100644
--- a/library/cpp/yt/misc/unittests/ya.make
+++ b/library/cpp/yt/misc/unittests/ya.make
@@ -5,6 +5,7 @@ OWNER(g:yt)
SRCS(
enum_ut.cpp
guid_ut.cpp
+ farm_fingerprint_stability_ut.cpp
preprocessor_ut.cpp
)
diff --git a/library/cpp/yt/misc/ya.make b/library/cpp/yt/misc/ya.make
index bb76711ddd..76c75b0034 100644
--- a/library/cpp/yt/misc/ya.make
+++ b/library/cpp/yt/misc/ya.make
@@ -8,6 +8,7 @@ SRCS(
)
PEERDIR(
+ contrib/libs/farmhash
library/cpp/yt/exception
)