Merge pull request #7967 from godfreyd/en-docs/CLICKHOUSEDOCS-452

Docs for javaHashUTF16LE function
This commit is contained in:
alexey-milovidov 2019-12-03 03:58:09 +03:00 committed by GitHub
commit ee200fca77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 68 additions and 5 deletions

View File

@ -179,6 +179,8 @@ SELECT farmHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:0
Calculates [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) from a string. This hash function is neither fast nor having a good quality. The only reason to use it is when this algorithm is already used in another system and you have to calculate exactly the same result.
**Syntax**
```sql
SELECT javaHash('');
```
@ -187,8 +189,6 @@ SELECT javaHash('');
A `Int32` data type hash value.
Type: `javaHash`.
**Example**
Query:
@ -205,15 +205,40 @@ Result:
└───────────────────────────┘
```
## javaHashUTF16LE
## javaHashUTF16LE {#javahashutf16le}
The same as [JavaHash](#hash_functions-javahash), but for UTF-16LE code points. Works under the assumption that the string contains a set of bytes representing a UTF-16LE encoded text. If this assumption is not met, it returns some result (It only throws an exception in partial cases).
Calculates [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) from a string, assuming it contains bytes representing a string in UTF-16LE encoding.
**Syntax**
```sql
javaHashUTF16LE(stringUtf16le)
```
**Parameters**
- `stringUtf16le` — a string in UTF-16LE encoding.
**Returned value**
A `Int32` data type hash value.
**Example**
Correct query with UTF-16LE encoded string.
Query:
```sql
SELECT javaHashUTF16LE(convertCharset('Hello, world!', 'utf-8', 'utf-16le'))
SELECT javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le'))
```
Result:
```text
┌─javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le'))─┐
│ 3556498 │
└──────────────────────────────────────────────────────────────┘
```
## hiveHash {#hash_functions-hivehash}

View File

@ -207,6 +207,44 @@ SELECT javaHash('Hello, world!');
└───────────────────────────┘
```
## javaHashUTF16LE {#javahashutf16le}
Вычисляет [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) от строки, при допущении, что строка представлена в кодировке `UTF-16LE`.
**Синтаксис**
```sql
javaHashUTF16LE(stringUtf16le)
```
**Параметры**
- `stringUtf16le` — строка в `UTF-16LE`.
**Возвращаемое значение**
Хэш-значение типа `Int32`.
Тип: `javaHash`.
**Пример**
Верный запрос для строки кодированной в `UTF-16LE`.
Запрос:
```sql
SELECT javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le'))
```
Ответ:
```text
┌─javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le'))─┐
│ 3556498 │
└──────────────────────────────────────────────────────────────┘
```
## hiveHash {#hash_functions-hivehash}
Вычисляет `HiveHash` от строки.