| 1373 | */ |
| 1374 | PG_FUNCTION_INFO_V1( svec_mean_final ); |
| 1375 | Datum svec_mean_final( PG_FUNCTION_ARGS) |
| 1376 | { |
| 1377 | /* Validate state input*/ |
| 1378 | if PG_ARGISNULL(0) { |
| 1379 | PG_RETURN_NULL(); |
| 1380 | } |
| 1381 | |
| 1382 | SvecType *svec; |
| 1383 | ArrayType *transarray; |
| 1384 | |
| 1385 | /* Read the argument */ |
| 1386 | if (fcinfo->context && IsA(fcinfo->context, AggState)) |
| 1387 | transarray = PG_GETARG_ARRAYTYPE_P(0); |
| 1388 | else |
| 1389 | transarray = PG_GETARG_ARRAYTYPE_P_COPY(0); |
| 1390 | |
| 1391 | /* Define the array */ |
| 1392 | float8 *array = (float8 *)ARR_DATA_PTR(transarray); |
| 1393 | int dim = ARR_DIMS(transarray)[0]; |
| 1394 | |
| 1395 | /* Divide */ |
| 1396 | for (int i=0; i<dim-1; i++) { |
| 1397 | array[i] = array[i] / array[dim-1]; |
| 1398 | } |
| 1399 | |
| 1400 | /* Create the output SVEC */ |
| 1401 | SparseData sdata = float8arr_to_sdata(array,dim-1); |
| 1402 | svec = svec_from_sparsedata(sdata,true); |
| 1403 | |
| 1404 | PG_RETURN_SVECTYPE_P(svec); |
| 1405 | |
| 1406 | } |
nothing calls this directly
no test coverage detected