Skip to content
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

Docs for javaHashUTF16LE function #7967

Merged
merged 4 commits into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 30 additions & 5 deletions docs/en/query_language/functions/hash_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
```
Expand All @@ -187,8 +189,6 @@ SELECT javaHash('');

A `Int32` data type hash value.

Type: `javaHash`.

**Example**

Query:
Expand All @@ -205,15 +205,40 @@ Result:
└───────────────────────────┘
```

## javaHashUTF16LE
## javaHashUTF16LE {#javahashutf16le}

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**

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).
- `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}
Expand Down
38 changes: 38 additions & 0 deletions docs/ru/query_language/functions/hash_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` от строки.
Expand Down