mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-18 05:32:52 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
35 lines
793 B
C++
35 lines
793 B
C++
#include "FunctionsConsistentHashing.h"
|
|
#include <Functions/FunctionFactory.h>
|
|
|
|
#include <sumbur.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
struct SumburConsistentHashImpl
|
|
{
|
|
static constexpr auto name = "sumburConsistentHash";
|
|
|
|
using HashType = UInt32;
|
|
using ResultType = UInt16;
|
|
using BucketsType = ResultType;
|
|
static constexpr auto max_buckets = static_cast<UInt64>(std::numeric_limits<BucketsType>::max());
|
|
|
|
static inline ResultType apply(HashType hash, BucketsType n)
|
|
{
|
|
return static_cast<ResultType>(sumburConsistentHash(hash, n));
|
|
}
|
|
};
|
|
|
|
using FunctionSumburConsistentHash = FunctionConsistentHashImpl<SumburConsistentHashImpl>;
|
|
|
|
void registerFunctionSumburConsistentHash(FunctionFactory & factory)
|
|
{
|
|
factory.registerFunction<FunctionSumburConsistentHash>();
|
|
}
|
|
|
|
}
|
|
|
|
|