MCPcopy Create free account
hub / github.com/apache/madlib / array_min_index

Function array_min_index

methods/array_ops/src/pg_gp/array_ops.c:589–609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

587 */
588PG_FUNCTION_INFO_V1(array_min_index);
589Datum
590array_min_index(PG_FUNCTION_ARGS) {
591 if (PG_ARGISNULL(0)) { PG_RETURN_NULL(); }
592 ArrayType *v = PG_GETARG_ARRAYTYPE_P(0);
593
594 if (ARR_NDIM(v) != 1) {
595 ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
596 errmsg("Input array with multiple dimensions is not allowed!")));
597 }
598
599 value_index *result = (value_index *)palloc(sizeof(value_index));
600 result->value = get_float8_infinity();
601 result->index = 0;
602
603 Datum res = General_Array_to_Struct(v, result, element_argmin, value_index_finalize);
604
605 PG_FREE_IF_COPY(v, 0);
606
607 pfree(result);
608 return res;
609}
610
611/*
612 * This function returns dot product of two arrays as vectors.

Callers

nothing calls this directly

Calls 1

General_Array_to_StructFunction · 0.85

Tested by

no test coverage detected