Max
The function interface declaration is as follows:
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);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
src |
Pointer to the source vector |
The value cannot be NULL. |
Input |
len |
Vector length |
(0,INT_MAX] |
Input |
nullAddr |
Pointer to a null address
|
This field can be NULL. |
Input |
offset |
Pointer to the offset address of the substring |
The value cannot be NULL. |
Input |
max |
Pointer to the result |
The value cannot be NULL. |
Output |
maxlen |
Pointer to the length of the result string |
The value cannot be NULL. |
Output |
When using the HMPPS_AggMax_varchar function, ensure sufficient memory for max to prevent segmentation faults. You are advised to allocate the same memory size for max as that for src.
Return Value
- Success: HMPP_STS_NO_ERR
- Failure: An error code is returned.
Error Codes
Error Code |
Description |
|---|---|
HMPP_STS_NULL_PTR_ERR |
The value of src, max, maxlen, or offset is NULL. |
HMPP_STS_SIZE_ERR |
The value of len is less than or equal to 0. |
Example
#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);
Output:
result = 0 max = 31