Skip to content

GH-48488: [GLib][Ruby] Add GArrowListSliceOptions#48489

Merged
kou merged 6 commits intoapache:mainfrom
stenlarsson:glib-list-slice-options
Dec 23, 2025
Merged

GH-48488: [GLib][Ruby] Add GArrowListSliceOptions#48489
kou merged 6 commits intoapache:mainfrom
stenlarsson:glib-list-slice-options

Conversation

@stenlarsson
Copy link
Contributor

@stenlarsson stenlarsson commented Dec 14, 2025

Rationale for this change

The ListSliceOptions class is not available in GLib/Ruby, and it is used together with the list_slice compute function.

What changes are included in this PR?

This adds the ListSliceOptions class to GLib.

Are these changes tested?

Yes, with Ruby unit tests.

Are there any user-facing changes?

Yes, a new class.

@stenlarsson stenlarsson requested a review from kou as a code owner December 14, 2025 14:26
@github-actions
Copy link

⚠️ GitHub issue #48488 has been automatically assigned in GitHub to PR creator.

@stenlarsson
Copy link
Contributor Author

The property return_fixed_size_list has the type std::optional<bool>. While it would make sense in Ruby, I couldn't figure out how to set a boolean to null in GLib, so I created an enum instead.

Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

The property return_fixed_size_list has the type std::optional<bool>. While it would make sense in Ruby, I couldn't figure out how to set a boolean to null in GLib, so I created an enum instead.

OK. Let's wrap it in ruby/red-arrow/ to accept options.return_fixed_size_list = true/= false/= nil as a follow-up task.

if (options->stop.has_value()) {
g_value_set_int64(value, options->stop.value());
} else {
g_value_set_int64(value, -1); // Sentinel value for "not set"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add #define GARROW_LIST_SLICE_OPTIONS_STOP_UNSPECIFIED -1 or something to compute.h and use it here and others?

gobject-introspection gem defines it in Ruby automatically. So we can use it in our tests.

GArrowListSliceOptions *
garrow_list_slice_options_new(void)
{
auto options = g_object_new(GARROW_TYPE_LIST_SLICE_OPTIONS, NULL);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use nullptr instead of NULL because C++ prefers nullptr?

Suggested change
auto options = g_object_new(GARROW_TYPE_LIST_SLICE_OPTIONS, NULL);
auto options = g_object_new(GARROW_TYPE_LIST_SLICE_OPTIONS, nullptr);

@stenlarsson
Copy link
Contributor Author

Good idea! I added Ruby wrappers for both the return_fixed_size_array and stop methods.

Unfortunately the tests fails due to #48610.

@kou kou force-pushed the glib-list-slice-options branch from 081867a to db2c03b Compare December 21, 2025 02:07
@github-actions github-actions bot added awaiting changes Awaiting changes awaiting change review Awaiting change review and removed awaiting review Awaiting review awaiting changes Awaiting changes labels Dec 21, 2025
# list element’s length, nil values will be appended to create the requested
# slice size. The default of nil will return the same type which was passed in.
#
# Since: 23.0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YARD uses @since 23.0.0 not Since: 23.0.0 syntax: https://www.rubydoc.info/docs/yard/file/docs/Tags.md#since

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course. 🤦

@stenlarsson stenlarsson force-pushed the glib-list-slice-options branch from f94166d to 6789198 Compare December 23, 2025 09:28
@kou kou merged commit 3dc9821 into apache:main Dec 23, 2025
13 checks passed
@kou kou removed the awaiting change review Awaiting change review label Dec 23, 2025
@conbench-apache-arrow
Copy link

After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit 3dc9821.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants