---
title: Hash
description: "函数接口声明如下："
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/240RC1/accel/kunpengaccel_hmpp_06_0262.html
sourcePath: /source/zh/kunpengboostkithistory/240RC1/accel/kunpengaccel_hmpp_06_0262.html
indexId: 6e2d0548ac4b5e5a9cb6e8b1b203b1e84a16ccdbffe1dfd97c7e4451f3533da677
---
# Hash

函数接口声明如下：

HmppResult HMPPS_Hash_16s(const int16_t *src, int32_t len, const int8_t *nullAddr, int64_t *dst);

HmppResult HMPPS_Hash_32s(const int32_t *src, int32_t len, const int8_t *nullAddr, int64_t *dst);

HmppResult HMPPS_Hash_64s(const int64_t *src, int32_t len, const int8_t *nullAddr, int64_t *dst);

HmppResult HMPPS_Hash_64f(const double *src, int32_t len, const int8_t *nullAddr, int64_t *dst);

HmppResult HMPPS_Hash_bool(const bool *src, int32_t len, const int8_t *nullAddr, int64_t *dst);

HmppResult HMPPS_Hash_decimal64(const int64_t *src, int32_t len, const int8_t *nullAddr, int64_t *dst);

HmppResult HMPPS_Hash_decimal128(const HmppDecimal128 *src, int32_t len, const int8_t *nullAddr, int64_t *dst);

HmppResult HMPPS_Hash_varchar(const varchar *src, const int32_t *offset, int32_t len, const int8_t *nullAddr, int64_t *dst);

#### 参数

| 参数名 | 描述 | 取值范围 | 输入/输出 |
| --- | --- | --- | --- |
| src | 指向源向量的指针。 | 非空 | 输入 |
| offset | 指向子字符串偏移地址的指针。 | 非空 | 输入 |
| len | 向量长度。 | (0,INT\_MAX] | 输入 |
| nullAddr | 指向空地址的指针。 若nullAddr为空指针，表示src向量中所有元素都参与计算。 否则，当nullAddr[i]=0时，src[i]参与计算（i表示索引）。 | 无要求，可以为空 | 输入 |
| dst | 指向结果的指针。 | 非空 | 输出 |


#### 返回值

- 成功：返回HMPP_STS_NO_ERR。
- 失败：返回错误码。


#### 错误码

| 错误码 | 描述 |
| --- | --- |
| HMPP\_STS\_NULL\_PTR\_ERR | src、offset、dst这几个入参中存在空指针。 |
| HMPP\_STS\_SIZE\_ERR | len小于或等于0。 |


#### 示例

```
#include <stdio.h>
#include "hmpp.h"
#define BUFFER_SIZE_T 10
int main() {
int64_t src[BUFFER_SIZE_T] = {3, 6, 2, 8, 3, 15, 56, 31, 1, 23};
int64_t dst[BUFFER_SIZE_T] = {0};
int8_t nullAddr[BUFFER_SIZE_T] = {0, 0, 1, 1, 0, 1, 0, 0, 0, 0};
HmppResult result = HMPPS_Hash_64s(src, BUFFER_SIZE_T, nullAddr, dst);
printf("result = %d\n", result);
if (result != HMPP_STS_NO_ERR) {
return 0;
}
for (int i = 0; i < BUFFER_SIZE_T; i++) {
printf("%d, ", dst[i]);
}
printf("\n");
}
```

运行结果：

```
result = 0
806985981, -434172799, 0, 0, 806985981, 0, 2071699152, -304648091, -479945518, -1157406791,
```
