我要评分
获取效率
正确性
完整性
易理解

Min

The function interface declaration is as follows:

HmppResult HMPPS_AggMin_bool(const bool *src, int32_t len, int8_t *nullAddr, bool *min);

HmppResult HMPPS_AggMin_varchar(const varchar *src, const int32_t *offset, int32_t len, varchar *min, int32_t *minLen);

HmppResult HMPPS_AggMin_16s(const int16_t *src, int32_t len, int8_t *nullAddr, int16_t *min);

HmppResult HMPPS_AggMin_32s(const int32_t *src, int32_t len, int8_t *nullAddr, int32_t *min);

HmppResult HMPPS_AggMin_64s(const int64_t *src, int32_t len, int8_t *nullAddr, int64_t *min);

HmppResult HMPPS_AggMin_64f(const double *src, int32_t len, int8_t *nullAddr, double *min);

HmppResult HMPPS_AggMin_decimal128(const HmppDecimal128 *src, int32_t len, int8_t *nullAddr, HmppDecimal128 *min);

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

  • If the value of nullAddr is a null pointer, all elements in the src vector are used for the calculation.
  • Otherwise, when nullAddr[i] = 0, elements in src[i] (i indicates the index) are used for the calculation.

This field can be NULL.

Input

offset

Pointer to the offset address of the substring

The value cannot be NULL.

Input

min

Pointer to the result

The value cannot be NULL.

Output

minlen

Pointer to the length of the result string

The value cannot be NULL.

Output

When using the HMPPS_AggMin_varchar function, ensure sufficient memory for min to prevent segmentation faults. You are advised to allocate the same memory size for min 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, min, minlen, 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, 0, 0, 0, 0, 0, 0, 0, 1, 23};
    int64_t min;
    HmppResult result = HMPPS_AggMin_64s(src, BUFFER_SIZE_T, nullAddr, &min);
    printf("result = %d  ", result);
    if (result != HMPP_STS_NO_ERR) {
        return 0;
    }
    printf("min = %ld\n", min);
}

Output:

result = 0  min = 2