mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
dbms: add function metroHash64
This commit is contained in:
parent
348ebf0731
commit
58408dc8a3
@ -4,6 +4,7 @@
|
||||
#include <openssl/sha.h>
|
||||
#include <city.h>
|
||||
#include <farmhash.h>
|
||||
#include <metrohash.h>
|
||||
|
||||
#include <Poco/ByteOrder.h>
|
||||
|
||||
@ -839,6 +840,25 @@ struct ImplFarmHash64
|
||||
static auto Hash64(const char * const s, const std::size_t len) { return farmhash::Hash64(s, len); }
|
||||
};
|
||||
|
||||
struct ImplMetroHash64
|
||||
{
|
||||
static constexpr auto name = "metroHash64";
|
||||
using uint128_t = uint128;
|
||||
|
||||
static auto Hash128to64(const uint128_t & x) { return ::Hash128to64(x); }
|
||||
static auto Hash64(const char * const s, const std::size_t len)
|
||||
{
|
||||
union {
|
||||
std::uint64_t u64;
|
||||
std::uint8_t u8[sizeof(u64)];
|
||||
};
|
||||
|
||||
metrohash64_1(reinterpret_cast<const std::uint8_t *>(s), len, 0, u8);
|
||||
|
||||
return u64;
|
||||
}
|
||||
};
|
||||
|
||||
using FunctionHalfMD5 = FunctionStringHash64<HalfMD5Impl, NameHalfMD5>;
|
||||
using FunctionSipHash64 = FunctionStringHash64<SipHash64Impl, NameSipHash64>;
|
||||
using FunctionIntHash32 = FunctionIntHash<IntHash32Impl, NameIntHash32>;
|
||||
@ -850,5 +870,6 @@ using FunctionSHA256 = FunctionStringHashFixedString<SHA256Impl>;
|
||||
using FunctionSipHash128 = FunctionStringHashFixedString<SipHash128Impl>;
|
||||
using FunctionCityHash64 = FunctionNeighbourhoodHash64<ImplCityHash64>;
|
||||
using FunctionFarmHash64 = FunctionNeighbourhoodHash64<ImplFarmHash64>;
|
||||
using FunctionMetroHash64 = FunctionNeighbourhoodHash64<ImplMetroHash64>;
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ void registerFunctionsHashing(FunctionFactory & factory)
|
||||
factory.registerFunction<FunctionSipHash128>();
|
||||
factory.registerFunction<FunctionCityHash64>();
|
||||
factory.registerFunction<FunctionFarmHash64>();
|
||||
factory.registerFunction<FunctionMetroHash64>();
|
||||
factory.registerFunction<FunctionIntHash32>();
|
||||
factory.registerFunction<FunctionIntHash64>();
|
||||
factory.registerFunction<FunctionURLHash>();
|
||||
|
Loading…
Reference in New Issue
Block a user