summaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Functions/jumpConsistentHash.cpp
diff options
context:
space:
mode:
authorAlexSm <[email protected]>2024-01-04 15:09:05 +0100
committerGitHub <[email protected]>2024-01-04 15:09:05 +0100
commitdab291146f6cd7d35684e3a1150e5bb1c412982c (patch)
tree36ef35f6cacb6432845a4a33f940c95871036b32 /contrib/clickhouse/src/Functions/jumpConsistentHash.cpp
parent63660ad5e7512029fd0218e7a636580695a24e1f (diff)
Library import 5, delete go dependencies (#832)
* Library import 5, delete go dependencies * Fix yt client
Diffstat (limited to 'contrib/clickhouse/src/Functions/jumpConsistentHash.cpp')
-rw-r--r--contrib/clickhouse/src/Functions/jumpConsistentHash.cpp47
1 files changed, 0 insertions, 47 deletions
diff --git a/contrib/clickhouse/src/Functions/jumpConsistentHash.cpp b/contrib/clickhouse/src/Functions/jumpConsistentHash.cpp
deleted file mode 100644
index ffc21eb5cea..00000000000
--- a/contrib/clickhouse/src/Functions/jumpConsistentHash.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "FunctionsConsistentHashing.h"
-#include <Functions/FunctionFactory.h>
-
-
-namespace DB
-{
-namespace
-{
-
-/// Code from https://arxiv.org/pdf/1406.2294.pdf
-inline int32_t JumpConsistentHash(uint64_t key, int32_t num_buckets)
-{
- int64_t b = -1, j = 0;
- while (j < num_buckets)
- {
- b = j;
- key = key * 2862933555777941757ULL + 1;
- j = static_cast<int64_t>((b + 1) * (static_cast<double>(1LL << 31) / static_cast<double>((key >> 33) + 1)));
- }
- return static_cast<int32_t>(b);
-}
-
-struct JumpConsistentHashImpl
-{
- static constexpr auto name = "jumpConsistentHash";
-
- using HashType = UInt64;
- using ResultType = Int32;
- using BucketsType = ResultType;
- static constexpr auto max_buckets = static_cast<UInt64>(std::numeric_limits<BucketsType>::max());
-
- static inline ResultType apply(UInt64 hash, BucketsType n)
- {
- return JumpConsistentHash(hash, n);
- }
-};
-
-using FunctionJumpConsistentHash = FunctionConsistentHashImpl<JumpConsistentHashImpl>;
-
-}
-
-REGISTER_FUNCTION(JumpConsistentHash)
-{
- factory.registerFunction<FunctionJumpConsistentHash>();
-}
-
-}