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

Function garrow_struct_array_new

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

* garrow_struct_array_new: * @data_type: The data type of the struct. * @length: The number of elements. * @fields: (element-type GArrowArray): The arrays for each field * as #GList of #GArrowArray. * @null_bitmap: (nullable): The bitmap that shows null elements. The * N-th element is null when the N-th bit is 0, not null otherwise. * If the array has no null elements, the bitmap must

Source from the content-addressed store, hash-verified

947 * Since: 0.4.0
948 */
949GArrowStructArray *
950garrow_struct_array_new(GArrowDataType *data_type,
951 gint64 length,
952 GList *fields,
953 GArrowBuffer *null_bitmap,
954 gint64 n_nulls)
955{
956 const auto arrow_data_type = garrow_data_type_get_raw(data_type);
957 std::vector<std::shared_ptr<arrow::Array>> arrow_fields;
958 for (auto node = fields; node; node = node->next) {
959 auto field = GARROW_ARRAY(node->data);
960 arrow_fields.push_back(garrow_array_get_raw(field));
961 }
962 const auto arrow_null_bitmap = garrow_buffer_get_raw(null_bitmap);
963 auto arrow_struct_array = std::make_shared<arrow::StructArray>(arrow_data_type,
964 length,
965 arrow_fields,
966 arrow_null_bitmap,
967 n_nulls);
968 auto arrow_array = std::static_pointer_cast<arrow::Array>(arrow_struct_array);
969 auto struct_array = garrow_array_new_raw(&arrow_array,
970 "array",
971 &arrow_array,
972 "null-bitmap",
973 null_bitmap,
974 NULL);
975 auto priv = GARROW_STRUCT_ARRAY_GET_PRIVATE(struct_array);
976 priv->fields = g_ptr_array_sized_new(arrow_fields.size());
977 g_ptr_array_set_free_func(priv->fields, g_object_unref);
978 for (auto node = fields; node; node = node->next) {
979 auto field = GARROW_ARRAY(node->data);
980 g_ptr_array_add(priv->fields, g_object_ref(field));
981 }
982 return GARROW_STRUCT_ARRAY(struct_array);
983}
984
985static GPtrArray *
986garrow_struct_array_get_fields_internal(GArrowStructArray *array)

Callers

nothing calls this directly

Calls 6

garrow_data_type_get_rawFunction · 0.85
garrow_buffer_get_rawFunction · 0.85
garrow_array_new_rawFunction · 0.85
push_backMethod · 0.80
garrow_array_get_rawFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected