Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions c_glib/arrow-glib/chunked-array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,30 @@ garrow_chunked_array_to_string(GArrowChunkedArray *chunked_array, GError **error
return g_strdup(arrow_chunked_array->ToString().c_str());
}

/**
* garrow_chunked_array_combine:
* @chunked_array: A #GArrowChunkedArray.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Returns: (nullable) (transfer full): The combined array that has
* all data in all chunks.
*
* Since: 4.0.0
*/
GArrowArray *
garrow_chunked_array_combine(GArrowChunkedArray *chunked_array, GError **error)
{
const auto arrow_chunked_array = garrow_chunked_array_get_raw(chunked_array);
auto arrow_combined_array = arrow::Concatenate(arrow_chunked_array->chunks());
if (garrow::check(error,
arrow_combined_array,
"[chunked-array][combine]")) {
return garrow_array_new_raw(&(*arrow_combined_array));
} else {
return NULL;
}
}

G_END_DECLS

GArrowChunkedArray *
Expand Down
3 changes: 3 additions & 0 deletions c_glib/arrow-glib/chunked-array.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,8 @@ GArrowChunkedArray *garrow_chunked_array_slice(GArrowChunkedArray *chunked_array
guint64 length);
gchar *garrow_chunked_array_to_string(GArrowChunkedArray *chunked_array,
GError **error);
GARROW_AVAILABLE_IN_4_0
GArrowArray *garrow_chunked_array_combine(GArrowChunkedArray *chunked_array,
GError **error);

G_END_DECLS
10 changes: 10 additions & 0 deletions c_glib/test/test-chunked-array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,14 @@ def test_to_s
]
PRETTY_PRINT
end

def test_combine
chunks = [
build_boolean_array([true]),
build_boolean_array([false, nil]),
]
chunked_array = Arrow::ChunkedArray.new(chunks)
assert_equal(build_boolean_array([true, false, nil]),
chunked_array.combine)
end
end