Skip to content

Commit 09fc139

Browse files
authored
[Feature](func) Support function mmh64_v2 (#2993)
## Versions - [x] dev - [x] 3.x - [ ] 2.1 - [ ] 2.0 ## Languages - [x] Chinese - [x] English ## Docs Checklist - [ ] Checked by AI - [ ] Test Cases Built
1 parent 96b6c04 commit 09fc139

14 files changed

Lines changed: 215 additions & 3 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
{
3+
"title": "MURMUR_HASH3_64_V2",
4+
"language": "en"
5+
}
6+
---
7+
8+
## Description
9+
10+
Computes a 64-bit MurmurHash3 hash value.
11+
12+
The difference from `MURMUR_HASH3_64` is: this version reuses the 128-bit processing function of MurmurHash3, outputting only the first 64-bit hash value, which is consistent with the [standard library](https://mmh3.readthedocs.io/en/latest/api.html#mmh3.hash64) implementation.
13+
14+
Note: According to testing, the performance of `xxhash_64` is approximately 2 times that of `murmur_hash3_64`. Therefore, when calculating hash values, it is recommended to use `xxhash_64` instead of `murmur_hash3_64`.
15+
16+
## Syntax
17+
18+
```sql
19+
MURMUR_HASH3_64_V2( <str> [ , <str> ... ] )
20+
```
21+
22+
## Parameters
23+
24+
| Parameter | Description |
25+
| --------- | ----------------------------------------------------- |
26+
| `<str>` | The value to be computed as a 64-bit MurmurHash3 hash |
27+
28+
## Return Value
29+
30+
Returns the 64-bit MurmurHash3 hash value of the input string.
31+
32+
Returns NULL if any parameter is NULL.
33+
34+
## Examples
35+
36+
```sql
37+
select murmur_hash3_64_v2(null), murmur_hash3_64_v2("hello"), murmur_hash3_64_v2("hello", "world");
38+
```
39+
40+
```text
41+
+--------------------------+-----------------------------+--------------------------------------+
42+
| murmur_hash3_64_v2(null) | murmur_hash3_64_v2("hello") | murmur_hash3_64_v2("hello", "world") |
43+
+--------------------------+-----------------------------+--------------------------------------+
44+
| NULL | -3758069500696749310 | -662943091231200135 |
45+
+--------------------------+-----------------------------+--------------------------------------+
46+
```

docs/sql-manual/sql-functions/scalar-functions/encrypt-digest-functions/murmur-hash3-64.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
Calculate 64-bit murmur3 hash value
1111

12+
The difference from `MURMUR_HASH3_64_V2` is: This version is specifically optimized for 64-bit output, with slightly better performance than the v2 version, but is inconsistent with the [standard library](https://mmh3.readthedocs.io/en/latest/api.html#mmh3.hash64) implementation.
13+
1214
-Note: After testing, the performance of `xxhash_64` is about twice that of `murmur_hash3_64`, so when calculating hash values, it is recommended to use `xxhash_64` instead of `murmur_hash3_64`.
1315

1416

@@ -28,7 +30,7 @@ MURMUR_HASH3_64( <str> [ , <str> ... ] )
2830

2931
Returns the 64-bit murmur3 hash of the input string.
3032

31-
33+
Returns NULL if any parameter input is NULL.
3234

3335
## Examples
3436

docs/sql-manual/sql-functions/scalar-functions/encrypt-digest-functions/xxhash-64.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Calculates the 64-bit xxhash value of the input string or binary.
1111

1212
-Note: After testing, the performance of `xxhash_64` is about twice that of `murmur_hash3_64`, so when calculating hash values, it is recommended to use `xxhash_64` instead of `murmur_hash3_64`.
1313

14+
## Alias
15+
16+
- `XXHASH3_64`
17+
1418
## Syntax
1519

1620
```sql
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
{
3+
"title": "MURMUR_HASH3_64_V2",
4+
"language": "zh-CN"
5+
}
6+
---
7+
8+
## 描述
9+
10+
计算 64 位 murmur3 hash 值
11+
12+
`MURMUR_HASH3_64`的区别是:此版本复用 MurmurHash3 的 128 位处理函数,仅输出第一个 64 位哈希值,与[标准库](https://mmh3.readthedocs.io/en/latest/api.html#mmh3.hash64)的行为保持一致。
13+
14+
-注:经过测试 xxhash_64 的性能大约是 murmur_hash3_64_v2 的 2 倍,所以在计算 hash 值时,更推荐使用`xxhash_64`,而不是`murmur_hash3_64`。如需更优的 64 位 MurmurHash3 性能,可考虑使用 `murmur_hash3_64`
15+
16+
## 语法
17+
18+
```sql
19+
MURMUR_HASH3_64_V2( <str> [ , <str> ... ] )
20+
```
21+
22+
## 参数
23+
24+
| 参数 | 说明 |
25+
|---------|------------------------|
26+
| `<str>` | 需要被计算 64 位 murmur3 hash 的值 |
27+
28+
## 返回值
29+
30+
返回输入字符串的 64 位 murmur3 hash 值。
31+
32+
任一参数为 NULL 时返回 NULL
33+
34+
## 示例
35+
36+
```sql
37+
select murmur_hash3_64_v2(null), murmur_hash3_64_v2("hello"), murmur_hash3_64_v2("hello", "world");
38+
```
39+
40+
```text
41+
+-----------------------+--------------------------+-----------------------------------+
42+
| murmur_hash3_64(NULL) | murmur_hash3_64('hello') | murmur_hash3_64('hello', 'world') |
43+
+-----------------------+--------------------------+-----------------------------------+
44+
| NULL | -3215607508166160593 | 3583109472027628045 |
45+
+-----------------------+--------------------------+-----------------------------------+
46+
```

i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/encrypt-digest-functions/murmur-hash3-64.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
计算 64 位 murmur3 hash 值
1111

12+
`MURMUR_HASH3_64_V2`的区别是:此版本专门为 64 位输出优化,性能略优于 v2 版本, 但与[标准库](https://mmh3.readthedocs.io/en/latest/api.html#mmh3.hash64)实现不一致。
13+
1214
-注:经过测试 xxhash_64 的性能大约是 murmur_hash3_64 的 2 倍,所以在计算 hash 值时,更推荐使用`xxhash_64`,而不是`murmur_hash3_64`
1315

1416
## 语法
@@ -27,6 +29,8 @@ MURMUR_HASH3_64( <str> [ , <str> ... ] )
2729

2830
返回输入字符串的 64 位 murmur3 hash 值。
2931

32+
任一参数输入为 NULL 时返回 NULL。
33+
3034
## 示例
3135

3236
```sql

i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/encrypt-digest-functions/xxhash-64.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
-注:经过测试 xxhash_64 的性能大约是 murmur_hash3_64 的 2 倍,所以在计算 hash 值时,更推荐使用`xxhash_64`,而不是`murmur_hash3_64`
1313

14+
## 别名
15+
16+
- `XXHASH3_64`
17+
1418
## 语法
1519

1620
```sql
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
{
3+
"title": "MURMUR_HASH3_64_V2",
4+
"language": "zh-CN"
5+
}
6+
---
7+
8+
## 描述
9+
10+
计算 64 位 murmur3 hash 值
11+
12+
`MURMUR_HASH3_64`的区别是:此版本复用 MurmurHash3 的 128 位处理函数,仅输出第一个 64 位哈希值,与[标准库](https://mmh3.readthedocs.io/en/latest/api.html#mmh3.hash64)的行为保持一致。
13+
14+
-注:经过测试 xxhash_64 的性能大约是 murmur_hash3_64_v2 的 2 倍,所以在计算 hash 值时,更推荐使用`xxhash_64`,而不是`murmur_hash3_64`
15+
16+
## 语法
17+
18+
```sql
19+
MURMUR_HASH3_64_V2( <str> [ , <str> ... ] )
20+
```
21+
22+
## 参数
23+
24+
| 参数 | 说明 |
25+
|---------|------------------------|
26+
| `<str>` | 需要被计算 64 位 murmur3 hash 的值 |
27+
28+
## 返回值
29+
30+
返回输入字符串的 64 位 murmur3 hash 值。
31+
32+
任一参数为 NULL 时返回 NULL
33+
34+
## 示例
35+
36+
```sql
37+
select murmur_hash3_64_v2(null), murmur_hash3_64_v2("hello"), murmur_hash3_64_v2("hello", "world");
38+
```
39+
40+
```text
41+
+-----------------------+--------------------------+-----------------------------------+
42+
| murmur_hash3_64(NULL) | murmur_hash3_64('hello') | murmur_hash3_64('hello', 'world') |
43+
+-----------------------+--------------------------+-----------------------------------+
44+
| NULL | -3215607508166160593 | 3583109472027628045 |
45+
+-----------------------+--------------------------+-----------------------------------+
46+
```

i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/scalar-functions/encrypt-digest-functions/murmur-hash3-64.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
计算 64 位 murmur3 hash 值
1111

12+
`MURMUR_HASH3_64_V2`的区别是:此版本专门为 64 位输出优化,性能略优于 v2 版本, 但与[标准库](https://mmh3.readthedocs.io/en/latest/api.html#mmh3.hash64)实现不一致。
13+
1214
-注:经过测试 xxhash_64 的性能大约是 murmur_hash3_64 的 2 倍,所以在计算 hash 值时,更推荐使用`xxhash_64`,而不是`murmur_hash3_64`
1315

1416
## 语法
@@ -27,7 +29,7 @@ MURMUR_HASH3_64( <str> [ , <str> ... ] )
2729

2830
返回输入字符串的 64 位 murmur3 hash 值。
2931

30-
32+
任一参数输入为 NULL 时返回 NULL。
3133

3234
## 示例
3335

i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/scalar-functions/encrypt-digest-functions/xxhash-64.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
-注:经过测试 xxhash_64 的性能大约是 murmur_hash3_64 的 2 倍,所以在计算 hash 值时,更推荐使用`xxhash_64`,而不是`murmur_hash3_64`
1313

14+
## 别名
15+
16+
- `XXHASH3_64`
17+
1418
## 语法
1519

1620
```sql

sidebars.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,7 @@
15011501
"sql-manual/sql-functions/scalar-functions/encrypt-digest-functions/md5sum",
15021502
"sql-manual/sql-functions/scalar-functions/encrypt-digest-functions/murmur-hash3-32",
15031503
"sql-manual/sql-functions/scalar-functions/encrypt-digest-functions/murmur-hash3-64",
1504+
"sql-manual/sql-functions/scalar-functions/encrypt-digest-functions/murmur-hash3-64-v2",
15041505
"sql-manual/sql-functions/scalar-functions/encrypt-digest-functions/sha",
15051506
"sql-manual/sql-functions/scalar-functions/encrypt-digest-functions/sha2",
15061507
"sql-manual/sql-functions/scalar-functions/encrypt-digest-functions/sm3",

0 commit comments

Comments
 (0)