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

Hash

The function interface declaration is as follows:

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);

Parameters

Parameter

Description

Value Range

Input/Output

src

Pointer to the source vector

The value cannot be NULL.

Input

offset

Pointer to the offset address of the substring

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

dst

Pointer to the result

The value cannot be NULL.

Output

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, offset, or dst 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};
    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");
}

Output:

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