Skip to content

Commit aae49e8

Browse files
authored
apacheGH-49417: [GLib] Add garrow_map_data_type_is_keys_sorted() (apache#49418)
### Rationale for this change It's the bindings of `arrow::MapType::keys_sorted()`. ### What changes are included in this PR? Add `garrow_map_data_type_is_keys_sorted()`. ### Are these changes tested? Yes. ### Are there any user-facing changes? Yes. * GitHub Issue: apache#49417 Authored-by: Sutou Kouhei <kou@clear-code.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent 1cac811 commit aae49e8

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

c_glib/arrow-glib/composite-data-type.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,23 @@ garrow_map_data_type_get_item_type(GArrowMapDataType *map_data_type)
422422
return garrow_data_type_new_raw(&arrow_item_type);
423423
}
424424

425+
/**
426+
* garrow_map_data_type_is_keys_sorted:
427+
* @map_data_type: A #GArrowMapDataType.
428+
*
429+
* Returns: Whether the keys in the map is sorted or not.
430+
*
431+
* Since: 24.0.0
432+
*/
433+
gboolean
434+
garrow_map_data_type_is_keys_sorted(GArrowMapDataType *map_data_type)
435+
{
436+
auto data_type = GARROW_DATA_TYPE(map_data_type);
437+
auto arrow_data_type = garrow_data_type_get_raw(data_type);
438+
auto arrow_map_data_type = std::static_pointer_cast<arrow::MapType>(arrow_data_type);
439+
return arrow_map_data_type->keys_sorted();
440+
}
441+
425442
G_DEFINE_ABSTRACT_TYPE(GArrowUnionDataType, garrow_union_data_type, GARROW_TYPE_DATA_TYPE)
426443

427444
static void

c_glib/arrow-glib/composite-data-type.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ garrow_map_data_type_get_key_type(GArrowMapDataType *map_data_type);
142142
GARROW_AVAILABLE_IN_0_17
143143
GArrowDataType *
144144
garrow_map_data_type_get_item_type(GArrowMapDataType *map_data_type);
145+
GARROW_AVAILABLE_IN_24_0
146+
gboolean
147+
garrow_map_data_type_is_keys_sorted(GArrowMapDataType *map_data_type);
145148

146149
#define GARROW_TYPE_UNION_DATA_TYPE (garrow_union_data_type_get_type())
147150
GARROW_AVAILABLE_IN_ALL

c_glib/test/test-map-data-type.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,10 @@ def test_key
4141
def test_item
4242
assert_equal(@item_type, @data_type.item_type)
4343
end
44+
45+
def test_keys_sorted?
46+
assert do
47+
not @data_type.keys_sorted?
48+
end
49+
end
4450
end

0 commit comments

Comments
 (0)