* garrow_array_count: * @array: A #GArrowArray. * @options: (nullable): A #GArrowCountOptions. * @error: (nullable): Return location for a #GError or %NULL. * * Returns: The number of target values on success. If an error is occurred, * the returned value is untrustful value. * * Since: 0.13.0 */
| 4977 | * Since: 0.13.0 |
| 4978 | */ |
| 4979 | gint64 |
| 4980 | garrow_array_count(GArrowArray *array, GArrowCountOptions *options, GError **error) |
| 4981 | { |
| 4982 | auto arrow_array = garrow_array_get_raw(array); |
| 4983 | auto arrow_array_raw = arrow_array.get(); |
| 4984 | arrow::Result<arrow::Datum> arrow_counted_datum; |
| 4985 | if (options) { |
| 4986 | auto arrow_options = garrow_count_options_get_raw(options); |
| 4987 | arrow_counted_datum = arrow::compute::Count(*arrow_array_raw, *arrow_options); |
| 4988 | } else { |
| 4989 | arrow_counted_datum = arrow::compute::Count(*arrow_array_raw); |
| 4990 | } |
| 4991 | if (garrow::check(error, arrow_counted_datum, "[array][count]")) { |
| 4992 | using ScalarType = typename arrow::TypeTraits<arrow::Int64Type>::ScalarType; |
| 4993 | auto arrow_counted_scalar = |
| 4994 | std::dynamic_pointer_cast<ScalarType>((*arrow_counted_datum).scalar()); |
| 4995 | return arrow_counted_scalar->value; |
| 4996 | } else { |
| 4997 | return 0; |
| 4998 | } |
| 4999 | } |
| 5000 | |
| 5001 | /** |
| 5002 | * garrow_array_count_values: |
nothing calls this directly
no test coverage detected