@@ -360,14 +360,13 @@ garrow_struct_array_flatten(GArrowStructArray *array, GError **error)
360360 std::static_pointer_cast<arrow::StructArray>(arrow_array);
361361
362362 auto memory_pool = arrow::default_memory_pool ();
363- arrow::ArrayVector arrow_arrays;
364- auto status = arrow_struct_array->Flatten (memory_pool, &arrow_arrays);
365- if (!garrow_error_check (error, status, " [struct-array][flatten]" )) {
363+ auto arrow_arrays = arrow_struct_array->Flatten (memory_pool);
364+ if (!garrow::check (error, arrow_arrays, " [struct-array][flatten]" )) {
366365 return NULL ;
367366 }
368367
369368 GList *arrays = NULL ;
370- for (auto arrow_array : arrow_arrays) {
369+ for (auto arrow_array : * arrow_arrays) {
371370 auto array = garrow_array_new_raw (&arrow_array);
372371 arrays = g_list_prepend (arrays, array);
373372 }
@@ -411,15 +410,13 @@ garrow_map_array_new(GArrowArray *offsets,
411410 const auto arrow_offsets = garrow_array_get_raw (offsets);
412411 const auto arrow_keys = garrow_array_get_raw (keys);
413412 const auto arrow_items = garrow_array_get_raw (items);
414- std::shared_ptr<arrow::Array> arrow_array;
415413 auto arrow_memory_pool = arrow::default_memory_pool ();
416- auto status = arrow::MapArray::FromArrays (arrow_offsets,
417- arrow_keys,
418- arrow_items,
419- arrow_memory_pool,
420- &arrow_array);
421- if (garrow::check (error, status, " [map-array][new]" )) {
422- return GARROW_MAP_ARRAY (garrow_array_new_raw (&arrow_array));
414+ auto arrow_array = arrow::MapArray::FromArrays (arrow_offsets,
415+ arrow_keys,
416+ arrow_items,
417+ arrow_memory_pool);
418+ if (garrow::check (error, arrow_array, " [map-array][new]" )) {
419+ return GARROW_MAP_ARRAY (garrow_array_new_raw (&(*arrow_array)));
423420 } else {
424421 return NULL ;
425422 }
@@ -543,12 +540,10 @@ garrow_sparse_union_array_new(GArrowInt8Array *type_ids,
543540 auto *field = GARROW_ARRAY (node->data );
544541 arrow_fields.push_back (garrow_array_get_raw (field));
545542 }
546- std::shared_ptr<arrow::Array> arrow_union_array;
547- auto status = arrow::UnionArray::MakeSparse (*arrow_type_ids,
548- arrow_fields,
549- &arrow_union_array);
550- if (garrow_error_check (error, status, " [sparse-union-array][new]" )) {
551- return GARROW_SPARSE_UNION_ARRAY (garrow_array_new_raw (&arrow_union_array));
543+ auto arrow_union_array = arrow::UnionArray::MakeSparse (*arrow_type_ids,
544+ arrow_fields);
545+ if (garrow::check (error, arrow_union_array, " [sparse-union-array][new]" )) {
546+ return GARROW_SPARSE_UNION_ARRAY (garrow_array_new_raw (&(*arrow_union_array)));
552547 } else {
553548 return NULL ;
554549 }
@@ -586,16 +581,11 @@ garrow_sparse_union_array_new_data_type(GArrowSparseUnionDataType *data_type,
586581 auto *field = GARROW_ARRAY (node->data );
587582 arrow_fields.push_back (garrow_array_get_raw (field));
588583 }
589- std::shared_ptr<arrow::Array> arrow_union_array;
590- auto status = arrow::UnionArray::MakeSparse (*arrow_type_ids,
591- arrow_fields,
592- arrow_field_names,
593- arrow_union_data_type->type_codes (),
594- &arrow_union_array);
595- if (garrow_error_check (error,
596- status,
597- " [sparse-union-array][new][data-type]" )) {
598- return GARROW_SPARSE_UNION_ARRAY (garrow_array_new_raw (&arrow_union_array));
584+ auto arrow_union_array = arrow::UnionArray::MakeSparse (
585+ *arrow_type_ids, arrow_fields, arrow_field_names,
586+ arrow_union_data_type->type_codes ());
587+ if (garrow::check (error, arrow_union_array, " [sparse-union-array][new][data-type]" )) {
588+ return GARROW_SPARSE_UNION_ARRAY (garrow_array_new_raw (&(*arrow_union_array)));
599589 } else {
600590 return NULL ;
601591 }
@@ -643,13 +633,11 @@ garrow_dense_union_array_new(GArrowInt8Array *type_ids,
643633 auto *field = GARROW_ARRAY (node->data );
644634 arrow_fields.push_back (garrow_array_get_raw (field));
645635 }
646- std::shared_ptr<arrow::Array> arrow_union_array;
647- auto status = arrow::UnionArray::MakeDense (*arrow_type_ids,
648- *arrow_value_offsets,
649- arrow_fields,
650- &arrow_union_array);
651- if (garrow_error_check (error, status, " [dense-union-array][new]" )) {
652- return GARROW_DENSE_UNION_ARRAY (garrow_array_new_raw (&arrow_union_array));
636+ auto arrow_union_array = arrow::UnionArray::MakeDense (*arrow_type_ids,
637+ *arrow_value_offsets,
638+ arrow_fields);
639+ if (garrow::check (error, arrow_union_array, " [dense-union-array][new]" )) {
640+ return GARROW_DENSE_UNION_ARRAY (garrow_array_new_raw (&(*arrow_union_array)));
653641 } else {
654642 return NULL ;
655643 }
@@ -691,15 +679,11 @@ garrow_dense_union_array_new_data_type(GArrowDenseUnionDataType *data_type,
691679 auto *field = GARROW_ARRAY (node->data );
692680 arrow_fields.push_back (garrow_array_get_raw (field));
693681 }
694- std::shared_ptr<arrow::Array> arrow_union_array;
695- auto status = arrow::UnionArray::MakeDense (*arrow_type_ids,
696- *arrow_value_offsets,
697- arrow_fields,
698- arrow_field_names,
699- arrow_union_data_type->type_codes (),
700- &arrow_union_array);
701- if (garrow_error_check (error, status, " [dense-union-array][new][data-type]" )) {
702- return GARROW_DENSE_UNION_ARRAY (garrow_array_new_raw (&arrow_union_array));
682+ auto arrow_union_array = arrow::UnionArray::MakeDense (
683+ *arrow_type_ids, *arrow_value_offsets, arrow_fields, arrow_field_names,
684+ arrow_union_data_type->type_codes ());
685+ if (garrow::check (error, arrow_union_array, " [dense-union-array][new][data-type]" )) {
686+ return GARROW_DENSE_UNION_ARRAY (garrow_array_new_raw (&(*arrow_union_array)));
703687 } else {
704688 return NULL ;
705689 }
@@ -741,14 +725,11 @@ garrow_dictionary_array_new(GArrowDataType *data_type,
741725 const auto arrow_data_type = garrow_data_type_get_raw (data_type);
742726 const auto arrow_indices = garrow_array_get_raw (indices);
743727 const auto arrow_dictionary = garrow_array_get_raw (dictionary);
744- std::shared_ptr<arrow::Array> arrow_dictionary_array;
745- auto status = arrow::DictionaryArray::FromArrays (arrow_data_type,
746- arrow_indices,
747- arrow_dictionary,
748- &arrow_dictionary_array);
749- if (garrow_error_check (error, status, " [dictionary-array][new]" )) {
728+ auto arrow_dictionary_array = arrow::DictionaryArray::FromArrays (
729+ arrow_data_type, arrow_indices, arrow_dictionary);
730+ if (garrow::check (error, arrow_dictionary_array, " [dictionary-array][new]" )) {
750731 auto arrow_array =
751- std::static_pointer_cast<arrow::Array>(arrow_dictionary_array);
732+ std::static_pointer_cast<arrow::Array>(* arrow_dictionary_array);
752733 return GARROW_DICTIONARY_ARRAY (garrow_array_new_raw (&arrow_array));
753734 } else {
754735 return NULL ;
0 commit comments