-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support more hash functions for tuple, unify FunctionHash template. [CLICKHOUSE-3490] #3451
Conversation
|
||
static UInt64 mergeHashes(UInt64 h1, UInt64 h2) | ||
{ | ||
return IntHash64Impl::apply(h1) ^ h2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the main hash function is cryptographic, we must use cryptographic hash function to combine too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to do it, variants:
combine(x, y) = sipHash64(x || y)
where||
is "concatenation".- if there was more than one element in tuple, update (
SipHash::update
,MD5_update
, etc.) state by length of each element then by contents of each element; and finalize at the end.
|
||
SELECT murmurHash3_64(1, 2, 3); | ||
SELECT murmurHash3_64(1, 3, 2); | ||
SELECT murmurHash3_64('a', [1, 2, 3], 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And please add also a test with tuple argument or multiple arguments, one of them is tuple.
3533626746 | ||
2388617433 | ||
2708309598 | ||
3012058918 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't understand, why it was changed...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just changed to intHash32
or intHash64
as it was for other non-crypto hash functions.
I don't think it is expected behaviour.
Even halfMD5 is switched to intHash for integers. This is totally wrong. Will fix. |
Fixed idiosyncrasy with hash functions introduced in #3451
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en