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

Function garrow_union_array_get_field

c_glib/arrow-glib/composite-array.cpp:1434–1462  ·  view source on GitHub ↗

* garrow_union_array_get_field * @array: A #GArrowUnionArray. * @i: The index of the field in the union. * * Returns: (nullable) (transfer full): The i-th field values as a * #GArrowArray or %NULL on out of range. */

Source from the content-addressed store, hash-verified

1432 * #GArrowArray or %NULL on out of range.
1433 */
1434GArrowArray *
1435garrow_union_array_get_field(GArrowUnionArray *array, gint i)
1436{
1437 auto priv = GARROW_UNION_ARRAY_GET_PRIVATE(array);
1438 if (!priv->fields) {
1439 auto arrow_array = garrow_array_get_raw(GARROW_ARRAY(array));
1440 auto arrow_union_array = std::static_pointer_cast<arrow::UnionArray>(arrow_array);
1441 auto n_fields = arrow_union_array->num_fields();
1442 priv->fields = g_ptr_array_sized_new(n_fields);
1443 g_ptr_array_set_free_func(priv->fields, g_object_unref);
1444 for (int i = 0; i < n_fields; ++i) {
1445 auto arrow_field = arrow_union_array->field(i);
1446 g_ptr_array_add(priv->fields, garrow_array_new_raw(&arrow_field));
1447 }
1448 }
1449
1450 if (i < 0) {
1451 i += priv->fields->len;
1452 }
1453 if (i < 0) {
1454 return NULL;
1455 }
1456 if (i >= static_cast<gint>(priv->fields->len)) {
1457 return NULL;
1458 }
1459 auto field = static_cast<GArrowArray *>(g_ptr_array_index(priv->fields, i));
1460 g_object_ref(field);
1461 return field;
1462}
1463
1464/**
1465 * garrow_union_array_get_n_fields

Callers

nothing calls this directly

Calls 4

garrow_array_new_rawFunction · 0.85
garrow_array_get_rawFunction · 0.70
num_fieldsMethod · 0.45
fieldMethod · 0.45

Tested by

no test coverage detected