@@ -269,6 +269,9 @@ G_BEGIN_DECLS
269269 * #GArrowExtractRegexOptions is a class to customize the `extract_regex`
270270 * function.
271271 *
272+ * #GArrowMakeStructOptions is a class to customize the `make_struct`
273+ * function.
274+ *
272275 * There are many functions to compute data on an array.
273276 */
274277
@@ -7091,6 +7094,120 @@ garrow_extract_regex_options_new(void)
70917094 return GARROW_EXTRACT_REGEX_OPTIONS (options);
70927095}
70937096
7097+ enum {
7098+ PROP_MAKE_STRUCT_OPTIONS_FIELD_NAMES = 1 ,
7099+ };
7100+
7101+ G_DEFINE_TYPE (GArrowMakeStructOptions,
7102+ garrow_make_struct_options,
7103+ GARROW_TYPE_FUNCTION_OPTIONS)
7104+
7105+ static void
7106+ garrow_make_struct_options_set_property(GObject *object,
7107+ guint prop_id,
7108+ const GValue *value,
7109+ GParamSpec *pspec)
7110+ {
7111+ auto options = static_cast <arrow::compute::MakeStructOptions *>(
7112+ garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (object)));
7113+
7114+ switch (prop_id) {
7115+ case PROP_MAKE_STRUCT_OPTIONS_FIELD_NAMES:
7116+ {
7117+ auto strv = static_cast <gchar **>(g_value_get_boxed (value));
7118+ options->field_names .clear ();
7119+ if (strv) {
7120+ for (gchar **p = strv; *p; ++p) {
7121+ options->field_names .emplace_back (*p);
7122+ }
7123+ }
7124+ // Keep nullability and metadata vectors in sync with names.
7125+ options->field_nullability .assign (options->field_names .size (), true );
7126+ options->field_metadata .assign (options->field_names .size (), NULLPTR);
7127+ }
7128+ break ;
7129+ default :
7130+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
7131+ break ;
7132+ }
7133+ }
7134+
7135+ static void
7136+ garrow_make_struct_options_get_property (GObject *object,
7137+ guint prop_id,
7138+ GValue *value,
7139+ GParamSpec *pspec)
7140+ {
7141+ auto options = static_cast <arrow::compute::MakeStructOptions *>(
7142+ garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (object)));
7143+
7144+ switch (prop_id) {
7145+ case PROP_MAKE_STRUCT_OPTIONS_FIELD_NAMES:
7146+ {
7147+ const auto &names = options->field_names ;
7148+ auto strv = static_cast <gchar **>(g_new0 (gchar *, names.size () + 1 ));
7149+ for (gsize i = 0 ; i < names.size (); ++i) {
7150+ strv[i] = g_strdup (names[i].c_str ());
7151+ }
7152+ g_value_take_boxed (value, strv);
7153+ }
7154+ break ;
7155+ default :
7156+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
7157+ break ;
7158+ }
7159+ }
7160+
7161+ static void
7162+ garrow_make_struct_options_init (GArrowMakeStructOptions *object)
7163+ {
7164+ auto priv = GARROW_FUNCTION_OPTIONS_GET_PRIVATE (object);
7165+ priv->options = static_cast <arrow::compute::FunctionOptions *>(
7166+ new arrow::compute::MakeStructOptions ());
7167+ }
7168+
7169+ static void
7170+ garrow_make_struct_options_class_init (GArrowMakeStructOptionsClass *klass)
7171+ {
7172+ auto gobject_class = G_OBJECT_CLASS (klass);
7173+
7174+ gobject_class->set_property = garrow_make_struct_options_set_property;
7175+ gobject_class->get_property = garrow_make_struct_options_get_property;
7176+
7177+ arrow::compute::MakeStructOptions options;
7178+
7179+ GParamSpec *spec;
7180+ /* *
7181+ * GArrowMakeStructOptions:field-names:
7182+ *
7183+ * Names for wrapped columns.
7184+ *
7185+ * Since: 23.0.0
7186+ */
7187+ spec = g_param_spec_boxed (" field-names" ,
7188+ " Field names" ,
7189+ " Names for wrapped columns" ,
7190+ G_TYPE_STRV,
7191+ static_cast <GParamFlags>(G_PARAM_READWRITE));
7192+ g_object_class_install_property (gobject_class,
7193+ PROP_MAKE_STRUCT_OPTIONS_FIELD_NAMES,
7194+ spec);
7195+ }
7196+
7197+ /* *
7198+ * garrow_make_struct_options_new:
7199+ *
7200+ * Returns: A newly created #GArrowMakeStructOptions.
7201+ *
7202+ * Since: 23.0.0
7203+ */
7204+ GArrowMakeStructOptions *
7205+ garrow_make_struct_options_new (void )
7206+ {
7207+ auto options = g_object_new (GARROW_TYPE_MAKE_STRUCT_OPTIONS, NULL );
7208+ return GARROW_MAKE_STRUCT_OPTIONS (options);
7209+ }
7210+
70947211G_END_DECLS
70957212
70967213arrow::Result<arrow::FieldRef>
@@ -7254,6 +7371,11 @@ garrow_function_options_new_raw(const arrow::compute::FunctionOptions *arrow_opt
72547371 static_cast <const arrow::compute::ExtractRegexOptions *>(arrow_options);
72557372 auto options = garrow_extract_regex_options_new_raw (arrow_extract_regex_options);
72567373 return GARROW_FUNCTION_OPTIONS (options);
7374+ } else if (arrow_type_name == " MakeStructOptions" ) {
7375+ const auto arrow_make_struct_options =
7376+ static_cast <const arrow::compute::MakeStructOptions *>(arrow_options);
7377+ auto options = garrow_make_struct_options_new_raw (arrow_make_struct_options);
7378+ return GARROW_FUNCTION_OPTIONS (options);
72577379 } else {
72587380 auto options = g_object_new (GARROW_TYPE_FUNCTION_OPTIONS, NULL );
72597381 return GARROW_FUNCTION_OPTIONS (options);
@@ -7893,3 +8015,21 @@ garrow_extract_regex_options_get_raw(GArrowExtractRegexOptions *options)
78938015 return static_cast <arrow::compute::ExtractRegexOptions *>(
78948016 garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
78958017}
8018+
8019+ GArrowMakeStructOptions *
8020+ garrow_make_struct_options_new_raw (const arrow::compute::MakeStructOptions *arrow_options)
8021+ {
8022+ auto options =
8023+ GARROW_MAKE_STRUCT_OPTIONS (g_object_new (GARROW_TYPE_MAKE_STRUCT_OPTIONS, NULL ));
8024+ auto arrow_new_options = static_cast <arrow::compute::MakeStructOptions *>(
8025+ garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
8026+ *arrow_new_options = *arrow_options;
8027+ return options;
8028+ }
8029+
8030+ arrow::compute::MakeStructOptions *
8031+ garrow_make_struct_options_get_raw (GArrowMakeStructOptions *options)
8032+ {
8033+ return static_cast <arrow::compute::MakeStructOptions *>(
8034+ garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
8035+ }
0 commit comments