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

Function garrow_numeric_array_sum

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

Source from the content-addressed store, hash-verified

42
43template <typename ArrowType, typename GArrowArrayType>
44typename ArrowType::c_type
45garrow_numeric_array_sum(GArrowArrayType array,
46 GError **error,
47 const gchar *tag,
48 typename ArrowType::c_type default_value)
49{
50 auto arrow_array = garrow_array_get_raw(GARROW_ARRAY(array));
51 auto arrow_sum_datum = arrow::compute::Sum(arrow_array);
52 if (garrow::check(error, arrow_sum_datum, tag)) {
53 using ScalarType = typename arrow::TypeTraits<ArrowType>::ScalarType;
54 auto arrow_numeric_scalar =
55 std::dynamic_pointer_cast<ScalarType>((*arrow_sum_datum).scalar());
56 if (arrow_numeric_scalar->is_valid) {
57 return arrow_numeric_scalar->value;
58 } else {
59 return default_value;
60 }
61 } else {
62 return default_value;
63 }
64}
65
66template <typename GArrowTypeNewRaw>
67auto

Callers

nothing calls this directly

Calls 4

SumFunction · 0.85
garrow_array_get_rawFunction · 0.70
checkFunction · 0.70
scalarMethod · 0.45

Tested by

no test coverage detected