-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ARROW-7742: [GLib] Add support for MapArray #6436
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you check my comments?
c_glib/arrow-glib/array-builder.cpp
Outdated
{ | ||
GObjectClass *gobject_class; | ||
|
||
gobject_class = G_OBJECT_CLASS(klass); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use auto gobject_class = ...
here?
c_glib/arrow-glib/array-builder.cpp
Outdated
* @data_type: #GArrowMapDataType for the map. | ||
* @error: (nullable): Return location for a #GError or %NULL. | ||
* | ||
* Returns: A newly created #GArrowMapArrayBuilder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add on success, %NULL on error
?
c_glib/arrow-glib/array-builder.cpp
Outdated
auto builder = garrow_array_builder_new(arrow_data_type, | ||
error, | ||
"[map-array-builder][new]"); | ||
return GARROW_MAP_ARRAY_BUILDER(builder); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add NULL
check?
c_glib/arrow-glib/array-builder.cpp
Outdated
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder))); | ||
|
||
auto status = arrow_builder->Append(); | ||
return garrow_error_check(error, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use garrow::check()
?
arrow_items, | ||
arrow_memory_pool, | ||
&arrow_array); | ||
if (garrow_error_check(error, status, "[map-array][new]")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use garrow::check()
?
auto data_type = GARROW_DATA_TYPE(map_data_type); | ||
auto arrow_data_type = garrow_data_type_get_raw(data_type); | ||
auto arrow_map_data_type = | ||
static_cast<arrow::MapType *>(arrow_data_type.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use std::static_pointer_cast<arrow::MapType>(arrow_data_type)
here?
auto data_type = GARROW_DATA_TYPE(map_data_type); | ||
auto arrow_data_type = garrow_data_type_get_raw(data_type); | ||
auto arrow_map_data_type = | ||
static_cast<arrow::MapType *>(arrow_data_type.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
|
||
def setup | ||
offsets = build_int32_array([0, 2, 5]) | ||
@keys = build_string_array(["a", "b", "c", "d", "e"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keys
-> keys
.
def setup | ||
offsets = build_int32_array([0, 2, 5]) | ||
@keys = build_string_array(["a", "b", "c", "d", "e"]) | ||
@items = build_int16_array([0, 1, 2, 3, 4]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@items
-> items
.
c_glib/arrow-glib/array-builder.cpp
Outdated
* @builder: A #GArrowMapArrayBuilder. | ||
* | ||
* Returns: (transfer none): The #GArrowArrayBuilder for struct values. | ||
* This is used instead of garrow_map_array_builder_get_key_builder() and garrow_map_array_builder_get_item_builder(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this?
* Returns: (transfer none): The #GArrowArrayBuilder to add map entries as struct values.
* This can be used instead of garrow_map_array_builder_get_key_builder() and
* garrow_map_array_builder_get_item_builder(). You can build map entries as a list of
* struct values with this builder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for improving document. I've applied this.
da5085a
to
4d84134
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
This PR add support for
GArrowMapArrayBuilder
,GArrowMapArray
, andGArrowMapDataType
.