@@ -8355,6 +8355,8 @@ garrow_pairwise_options_new(void)
83558355
83568356enum {
83578357 PROP_MAKE_STRUCT_OPTIONS_FIELD_NAMES = 1 ,
8358+ PROP_MAKE_STRUCT_OPTIONS_FIELD_NULLABILITY,
8359+ PROP_MAKE_STRUCT_OPTIONS_FIELD_METADATA,
83588360};
83598361
83608362G_DEFINE_TYPE (GArrowMakeStructOptions,
@@ -8385,6 +8387,35 @@ garrow_make_struct_options_set_property(GObject *object,
83858387 options->field_metadata .assign (options->field_names .size (), NULLPTR);
83868388 }
83878389 break ;
8390+ case PROP_MAKE_STRUCT_OPTIONS_FIELD_NULLABILITY:
8391+ {
8392+ auto array = static_cast <GArray *>(g_value_get_boxed (value));
8393+ options->field_nullability .clear ();
8394+ if (array) {
8395+ for (guint i = 0 ; i < array->len ; ++i) {
8396+ auto nullability = g_array_index (array, gboolean, i);
8397+ options->field_nullability .push_back (nullability != FALSE );
8398+ }
8399+ }
8400+ }
8401+ break ;
8402+ case PROP_MAKE_STRUCT_OPTIONS_FIELD_METADATA:
8403+ {
8404+ auto array = static_cast <GArray *>(g_value_get_boxed (value));
8405+ options->field_metadata .clear ();
8406+ if (array) {
8407+ for (guint i = 0 ; i < array->len ; ++i) {
8408+ auto metadata = g_array_index (array, GHashTable *, i);
8409+ if (metadata) {
8410+ options->field_metadata .push_back (
8411+ garrow_internal_hash_table_to_metadata (metadata));
8412+ } else {
8413+ options->field_metadata .push_back (nullptr );
8414+ }
8415+ }
8416+ }
8417+ }
8418+ break ;
83888419 default :
83898420 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
83908421 break ;
@@ -8411,6 +8442,31 @@ garrow_make_struct_options_get_property(GObject *object,
84118442 g_value_take_boxed (value, strv);
84128443 }
84138444 break ;
8445+ case PROP_MAKE_STRUCT_OPTIONS_FIELD_NULLABILITY:
8446+ {
8447+ const auto &nullability = options->field_nullability ;
8448+ auto array = g_array_sized_new (FALSE , FALSE , sizeof (gboolean), nullability.size ());
8449+ for (gsize i = 0 ; i < nullability.size (); ++i) {
8450+ gboolean val = nullability[i] ? TRUE : FALSE ;
8451+ g_array_append_val (array, val);
8452+ }
8453+ g_value_take_boxed (value, array);
8454+ }
8455+ break ;
8456+ case PROP_MAKE_STRUCT_OPTIONS_FIELD_METADATA:
8457+ {
8458+ const auto &metadata = options->field_metadata ;
8459+ auto array = g_array_sized_new (FALSE , FALSE , sizeof (GHashTable *), metadata.size ());
8460+ for (gsize i = 0 ; i < metadata.size (); ++i) {
8461+ GHashTable *hash_table = nullptr ;
8462+ if (metadata[i]) {
8463+ hash_table = garrow_internal_hash_table_from_metadata (metadata[i]);
8464+ }
8465+ g_array_append_val (array, hash_table);
8466+ }
8467+ g_value_take_boxed (value, array);
8468+ }
8469+ break ;
84148470 default :
84158471 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
84168472 break ;
@@ -8451,6 +8507,39 @@ garrow_make_struct_options_class_init(GArrowMakeStructOptionsClass *klass)
84518507 g_object_class_install_property (gobject_class,
84528508 PROP_MAKE_STRUCT_OPTIONS_FIELD_NAMES,
84538509 spec);
8510+
8511+ /* *
8512+ * GArrowMakeStructOptions:field-nullability:
8513+ *
8514+ * Nullability for each field. This is a #GArray of #gboolean values.
8515+ *
8516+ * Since: 23.0.0
8517+ */
8518+ spec = g_param_spec_boxed (" field-nullability" ,
8519+ " Field nullability" ,
8520+ " Nullability for each field" ,
8521+ G_TYPE_ARRAY,
8522+ static_cast <GParamFlags>(G_PARAM_READWRITE));
8523+ g_object_class_install_property (gobject_class,
8524+ PROP_MAKE_STRUCT_OPTIONS_FIELD_NULLABILITY,
8525+ spec);
8526+
8527+ /* *
8528+ * GArrowMakeStructOptions:field-metadata:
8529+ *
8530+ * Metadata for each field. This is a #GArray of #GHashTable pointers
8531+ * (element-type utf8 utf8), or %NULL for fields without metadata.
8532+ *
8533+ * Since: 23.0.0
8534+ */
8535+ spec = g_param_spec_boxed (" field-metadata" ,
8536+ " Field metadata" ,
8537+ " Metadata for each field" ,
8538+ G_TYPE_ARRAY,
8539+ static_cast <GParamFlags>(G_PARAM_READWRITE));
8540+ g_object_class_install_property (gobject_class,
8541+ PROP_MAKE_STRUCT_OPTIONS_FIELD_METADATA,
8542+ spec);
84548543}
84558544
84568545/* *
@@ -8467,37 +8556,6 @@ garrow_make_struct_options_new(void)
84678556 return GARROW_MAKE_STRUCT_OPTIONS (options);
84688557}
84698558
8470- /* *
8471- * garrow_make_struct_options_add_field:
8472- * @options: A #GArrowMakeStructOptions.
8473- * @name: The name of the field to add.
8474- * @nullability: Whether the field is nullable.
8475- * @metadata: (nullable) (element-type utf8 utf8): A #GHashTable for the field's
8476- * metadata, or %NULL.
8477- *
8478- * Adds a field to the struct options with the specified name, nullability,
8479- * and optional metadata.
8480- *
8481- * Since: 23.0.0
8482- */
8483- void
8484- garrow_make_struct_options_add_field (GArrowMakeStructOptions *options,
8485- const char *name,
8486- gboolean nullability,
8487- GHashTable *metadata)
8488- {
8489- auto arrow_options = static_cast <arrow::compute::MakeStructOptions *>(
8490- garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
8491- arrow_options->field_names .emplace_back (name);
8492- arrow_options->field_nullability .push_back (nullability != FALSE );
8493- if (metadata) {
8494- arrow_options->field_metadata .push_back (
8495- garrow_internal_hash_table_to_metadata (metadata));
8496- } else {
8497- arrow_options->field_metadata .push_back (nullptr );
8498- }
8499- }
8500-
85018559G_END_DECLS
85028560
85038561arrow::Result<arrow::FieldRef>
0 commit comments