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

函数接口声明如下：

HmppResult HMPPS_AggMax_bool(const bool *src, int32_t len, int8_t *nullAddr, bool *max);

HmppResult HMPPS_AggMax_varchar(const varchar *src, const int32_t *offset, int32_t len, varchar *max, int32_t *maxLen);

HmppResult HMPPS_AggMax_16s(const int16_t *src, int32_t len, int8_t *nullAddr, int16_t *max);

HmppResult HMPPS_AggMax_32s(const int32_t *src, int32_t len, int8_t *nullAddr, int32_t *max);

HmppResult HMPPS_AggMax_64s(const int64_t *src, int32_t len, int8_t *nullAddr, int64_t *max);

HmppResult HMPPS_AggMax_64f(const double *src, int32_t len, int8_t *nullAddr, double *max);

HmppResult HMPPS_AggMax_decimal128(const HmppDecimal128 *src, int32_t len, int8_t *nullAddr, HmppDecimal128 *max);

#### 参数

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


使用HMPPS_AggMax_varchar函数时，用户需要给max分配足够大的内存，否则可能导致段错误。建议分配与src同样大的内存大小。


#### 返回值

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


#### 错误码

| 错误码 | 描述 |
| --- | --- |
| HMPP\_STS\_NULL\_PTR\_ERR | src、max、maxlen、offset这几个入参中存在空指针。 |
| 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};
int8_t nullAddr[BUFFER_SIZE_T] = {0, 1, 0, 0, 0, 0, 1, 0, 0, 0};
int64_t max;
HmppResult result = HMPPS_AggMax_64s(src, BUFFER_SIZE_T, nullAddr, &max);
printf("result = %d  ", result);
if (result != HMPP_STS_NO_ERR) {
return 0;
}
printf("max = %ld\n", max);
```

运行结果：

```
result = 0  max = 31
```
