mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #4000 from housepower/feature/gccHash
Add gccHash function
This commit is contained in:
commit
0648088ff0
@ -28,6 +28,7 @@ void registerFunctionsHashing(FunctionFactory & factory)
|
|||||||
factory.registerFunction<FunctionMurmurHash3_32>();
|
factory.registerFunction<FunctionMurmurHash3_32>();
|
||||||
factory.registerFunction<FunctionMurmurHash3_64>();
|
factory.registerFunction<FunctionMurmurHash3_64>();
|
||||||
factory.registerFunction<FunctionMurmurHash3_128>();
|
factory.registerFunction<FunctionMurmurHash3_128>();
|
||||||
|
factory.registerFunction<FunctionGccMurmurHash>();
|
||||||
|
|
||||||
#if USE_XXHASH
|
#if USE_XXHASH
|
||||||
factory.registerFunction<FunctionXxHash32>();
|
factory.registerFunction<FunctionXxHash32>();
|
||||||
|
@ -257,6 +257,25 @@ struct MurmurHash2Impl64
|
|||||||
static constexpr bool use_int_hash_for_pods = false;
|
static constexpr bool use_int_hash_for_pods = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// To be compatible with gcc: https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191
|
||||||
|
struct GccMurmurHashImpl
|
||||||
|
{
|
||||||
|
static constexpr auto name = "gccMurmurHash";
|
||||||
|
using ReturnType = UInt64;
|
||||||
|
|
||||||
|
static UInt64 apply(const char * data, const size_t size)
|
||||||
|
{
|
||||||
|
return MurmurHash64A(data, size, 0xc70f6907UL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static UInt64 combineHashes(UInt64 h1, UInt64 h2)
|
||||||
|
{
|
||||||
|
return IntHash64Impl::apply(h1) ^ h2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static constexpr bool use_int_hash_for_pods = false;
|
||||||
|
};
|
||||||
|
|
||||||
struct MurmurHash3Impl32
|
struct MurmurHash3Impl32
|
||||||
{
|
{
|
||||||
static constexpr auto name = "murmurHash3_32";
|
static constexpr auto name = "murmurHash3_32";
|
||||||
@ -1070,6 +1089,7 @@ using FunctionFarmHash64 = FunctionAnyHash<ImplFarmHash64>;
|
|||||||
using FunctionMetroHash64 = FunctionAnyHash<ImplMetroHash64>;
|
using FunctionMetroHash64 = FunctionAnyHash<ImplMetroHash64>;
|
||||||
using FunctionMurmurHash2_32 = FunctionAnyHash<MurmurHash2Impl32>;
|
using FunctionMurmurHash2_32 = FunctionAnyHash<MurmurHash2Impl32>;
|
||||||
using FunctionMurmurHash2_64 = FunctionAnyHash<MurmurHash2Impl64>;
|
using FunctionMurmurHash2_64 = FunctionAnyHash<MurmurHash2Impl64>;
|
||||||
|
using FunctionGccMurmurHash = FunctionAnyHash<GccMurmurHashImpl>;
|
||||||
using FunctionMurmurHash3_32 = FunctionAnyHash<MurmurHash3Impl32>;
|
using FunctionMurmurHash3_32 = FunctionAnyHash<MurmurHash3Impl32>;
|
||||||
using FunctionMurmurHash3_64 = FunctionAnyHash<MurmurHash3Impl64>;
|
using FunctionMurmurHash3_64 = FunctionAnyHash<MurmurHash3Impl64>;
|
||||||
using FunctionMurmurHash3_128 = FunctionStringHashFixedString<MurmurHash3Impl128>;
|
using FunctionMurmurHash3_128 = FunctionStringHashFixedString<MurmurHash3Impl128>;
|
||||||
|
@ -22,5 +22,8 @@
|
|||||||
11303473983767132390
|
11303473983767132390
|
||||||
956517343494314387
|
956517343494314387
|
||||||
956517343494314387
|
956517343494314387
|
||||||
|
9631199822919835226
|
||||||
|
4334672815104069193
|
||||||
|
4334672815104069193
|
||||||
6145F501578671E2877DBA2BE487AF7E
|
6145F501578671E2877DBA2BE487AF7E
|
||||||
16FE7483905CCE7A85670E43E4678877
|
16FE7483905CCE7A85670E43E4678877
|
||||||
|
@ -28,5 +28,10 @@ SELECT murmurHash3_64('foo');
|
|||||||
SELECT murmurHash3_64('\x01');
|
SELECT murmurHash3_64('\x01');
|
||||||
SELECT murmurHash3_64(1);
|
SELECT murmurHash3_64(1);
|
||||||
|
|
||||||
|
SELECT gccMurmurHash('foo');
|
||||||
|
SELECT gccMurmurHash('\x01');
|
||||||
|
SELECT gccMurmurHash(1);
|
||||||
|
|
||||||
SELECT hex(murmurHash3_128('foo'));
|
SELECT hex(murmurHash3_128('foo'));
|
||||||
SELECT hex(murmurHash3_128('\x01'));
|
SELECT hex(murmurHash3_128('\x01'));
|
||||||
|
|
||||||
|
@ -13,3 +13,6 @@
|
|||||||
8163029322371165472
|
8163029322371165472
|
||||||
8788309436660676487
|
8788309436660676487
|
||||||
236561483980029756
|
236561483980029756
|
||||||
|
12384823029245979431
|
||||||
|
4507350192761038840
|
||||||
|
1188926775431157506
|
||||||
|
@ -17,3 +17,7 @@ SELECT murmurHash2_64(('a', [1, 2, 3], 4, (4, ['foo', 'bar'], 1, (1, 2))));
|
|||||||
SELECT murmurHash3_64(1, 2, 3);
|
SELECT murmurHash3_64(1, 2, 3);
|
||||||
SELECT murmurHash3_64(1, 3, 2);
|
SELECT murmurHash3_64(1, 3, 2);
|
||||||
SELECT murmurHash3_64(('a', [1, 2, 3], 4, (4, ['foo', 'bar'], 1, (1, 2))));
|
SELECT murmurHash3_64(('a', [1, 2, 3], 4, (4, ['foo', 'bar'], 1, (1, 2))));
|
||||||
|
|
||||||
|
SELECT gccMurmurHash(1, 2, 3);
|
||||||
|
SELECT gccMurmurHash(1, 3, 2);
|
||||||
|
SELECT gccMurmurHash(('a', [1, 2, 3], 4, (4, ['foo', 'bar'], 1, (1, 2))));
|
Loading…
Reference in New Issue
Block a user