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

Function garrow_numeric_array_mean

c_glib/arrow-glib/compute.cpp:5142–5159  ·  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

5140 * Since: 0.13.0
5141 */
5142gdouble
5143garrow_numeric_array_mean(GArrowNumericArray *array, GError **error)
5144{
5145 auto arrow_array = garrow_array_get_raw(GARROW_ARRAY(array));
5146 auto arrow_mean_datum = arrow::compute::Mean(arrow_array);
5147 if (garrow::check(error, arrow_mean_datum, "[numeric-array][mean]")) {
5148 using ScalarType = typename arrow::TypeTraits<arrow::DoubleType>::ScalarType;
5149 auto arrow_numeric_scalar =
5150 std::dynamic_pointer_cast<ScalarType>((*arrow_mean_datum).scalar());
5151 if (arrow_numeric_scalar->is_valid) {
5152 return arrow_numeric_scalar->value;
5153 } else {
5154 return 0.0;
5155 }
5156 } else {
5157 return 0.0;
5158 }
5159}
5160
5161/**
5162 * 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