MCPcopy Create free account
hub / github.com/apache/arrow / garrow_numeric_array_mean

Function garrow_numeric_array_mean

c_glib/arrow-glib/compute.cpp:5187–5204  ·  view source on GitHub ↗

* garrow_numeric_array_mean: * @array: A #GArrowNumericArray. * @error: (nullable): Return location for a #GError or %NULL. * * Returns: The value of the computed mean. * * Since: 0.13.0 */

Source from the content-addressed store, hash-verified

5185 * Since: 0.13.0
5186 */
5187gdouble
5188garrow_numeric_array_mean(GArrowNumericArray *array, GError **error)
5189{
5190 auto arrow_array = garrow_array_get_raw(GARROW_ARRAY(array));
5191 auto arrow_mean_datum = arrow::compute::Mean(arrow_array);
5192 if (garrow::check(error, arrow_mean_datum, "[numeric-array][mean]")) {
5193 using ScalarType = typename arrow::TypeTraits<arrow::DoubleType>::ScalarType;
5194 auto arrow_numeric_scalar =
5195 std::dynamic_pointer_cast<ScalarType>((*arrow_mean_datum).scalar());
5196 if (arrow_numeric_scalar->is_valid) {
5197 return arrow_numeric_scalar->value;
5198 } else {
5199 return 0.0;
5200 }
5201 } else {
5202 return 0.0;
5203 }
5204}
5205
5206/**
5207 * garrow_int8_array_sum:

Callers

nothing calls this directly

Calls 4

MeanFunction · 0.85
garrow_array_get_rawFunction · 0.70
checkFunction · 0.70
scalarMethod · 0.45

Tested by

no test coverage detected