@@ -337,6 +337,8 @@ G_BEGIN_DECLS
337337 *
338338 * #GArrowWinsorizeOptions is a class to customize the `winsorize` function.
339339 *
340+ * #GArrowZeroFillOptions is a class to customize the `utf8_zero_fill` function.
341+ *
340342 * There are many functions to compute data on an array.
341343 */
342344
@@ -10571,6 +10573,156 @@ garrow_winsorize_options_new(void)
1057110573 return GARROW_WINSORIZE_OPTIONS (g_object_new (GARROW_TYPE_WINSORIZE_OPTIONS, NULL ));
1057210574}
1057310575
10576+ enum {
10577+ PROP_ZERO_FILL_OPTIONS_WIDTH = 1 ,
10578+ PROP_ZERO_FILL_OPTIONS_PADDING,
10579+ };
10580+
10581+ typedef struct _GArrowZeroFillOptionsPrivate GArrowZeroFillOptionsPrivate;
10582+ struct _GArrowZeroFillOptionsPrivate
10583+ {
10584+ gchar *padding;
10585+ };
10586+
10587+ G_DEFINE_TYPE_WITH_PRIVATE (GArrowZeroFillOptions,
10588+ garrow_zero_fill_options,
10589+ GARROW_TYPE_FUNCTION_OPTIONS)
10590+
10591+ #define GARROW_ZERO_FILL_OPTIONS_GET_PRIVATE (object ) \
10592+ static_cast <GArrowZeroFillOptionsPrivate *>( \
10593+ garrow_zero_fill_options_get_instance_private (GARROW_ZERO_FILL_OPTIONS(object)))
10594+
10595+ static void
10596+ garrow_zero_fill_options_dispose(GObject *object)
10597+ {
10598+ auto priv = GARROW_ZERO_FILL_OPTIONS_GET_PRIVATE (object);
10599+ if (priv->padding ) {
10600+ g_free (priv->padding );
10601+ priv->padding = nullptr ;
10602+ }
10603+ G_OBJECT_CLASS (garrow_zero_fill_options_parent_class)->dispose (object);
10604+ }
10605+
10606+ static void
10607+ garrow_zero_fill_options_set_property (GObject *object,
10608+ guint prop_id,
10609+ const GValue *value,
10610+ GParamSpec *pspec)
10611+ {
10612+ auto options = garrow_zero_fill_options_get_raw (GARROW_ZERO_FILL_OPTIONS (object));
10613+ auto priv = GARROW_ZERO_FILL_OPTIONS_GET_PRIVATE (object);
10614+
10615+ switch (prop_id) {
10616+ case PROP_ZERO_FILL_OPTIONS_WIDTH:
10617+ options->width = g_value_get_int64 (value);
10618+ break ;
10619+ case PROP_ZERO_FILL_OPTIONS_PADDING:
10620+ {
10621+ const gchar *padding = g_value_get_string (value);
10622+ if (priv->padding ) {
10623+ g_free (priv->padding );
10624+ }
10625+ priv->padding = g_strdup (padding);
10626+ options->padding = padding ? padding : " " ;
10627+ }
10628+ break ;
10629+ default :
10630+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
10631+ break ;
10632+ }
10633+ }
10634+
10635+ static void
10636+ garrow_zero_fill_options_get_property (GObject *object,
10637+ guint prop_id,
10638+ GValue *value,
10639+ GParamSpec *pspec)
10640+ {
10641+ auto options = garrow_zero_fill_options_get_raw (GARROW_ZERO_FILL_OPTIONS (object));
10642+ auto priv = GARROW_ZERO_FILL_OPTIONS_GET_PRIVATE (object);
10643+
10644+ switch (prop_id) {
10645+ case PROP_ZERO_FILL_OPTIONS_WIDTH:
10646+ g_value_set_int64 (value, options->width );
10647+ break ;
10648+ case PROP_ZERO_FILL_OPTIONS_PADDING:
10649+ g_value_set_string (value, priv->padding ? priv->padding : options->padding .c_str ());
10650+ break ;
10651+ default :
10652+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
10653+ break ;
10654+ }
10655+ }
10656+
10657+ static void
10658+ garrow_zero_fill_options_init (GArrowZeroFillOptions *object)
10659+ {
10660+ auto priv = GARROW_ZERO_FILL_OPTIONS_GET_PRIVATE (object);
10661+ priv->padding = nullptr ;
10662+ auto arrow_priv = GARROW_FUNCTION_OPTIONS_GET_PRIVATE (object);
10663+ arrow_priv->options =
10664+ static_cast <arrow::compute::FunctionOptions *>(new arrow::compute::ZeroFillOptions ());
10665+ // Sync the private string with the C++ options
10666+ auto arrow_options = garrow_zero_fill_options_get_raw (GARROW_ZERO_FILL_OPTIONS (object));
10667+ priv->padding = g_strdup (arrow_options->padding .c_str ());
10668+ }
10669+
10670+ static void
10671+ garrow_zero_fill_options_class_init (GArrowZeroFillOptionsClass *klass)
10672+ {
10673+ auto gobject_class = G_OBJECT_CLASS (klass);
10674+
10675+ gobject_class->dispose = garrow_zero_fill_options_dispose;
10676+ gobject_class->set_property = garrow_zero_fill_options_set_property;
10677+ gobject_class->get_property = garrow_zero_fill_options_get_property;
10678+
10679+ arrow::compute::ZeroFillOptions options;
10680+
10681+ GParamSpec *spec;
10682+ /* *
10683+ * GArrowZeroFillOptions:width:
10684+ *
10685+ * The desired string length.
10686+ *
10687+ * Since: 23.0.0
10688+ */
10689+ spec = g_param_spec_int64 (" width" ,
10690+ " Width" ,
10691+ " The desired string length" ,
10692+ G_MININT64,
10693+ G_MAXINT64,
10694+ options.width ,
10695+ static_cast <GParamFlags>(G_PARAM_READWRITE));
10696+ g_object_class_install_property (gobject_class, PROP_ZERO_FILL_OPTIONS_WIDTH, spec);
10697+
10698+ /* *
10699+ * GArrowZeroFillOptions:padding:
10700+ *
10701+ * What to pad the string with. Should be one codepoint (Unicode).
10702+ *
10703+ * Since: 23.0.0
10704+ */
10705+ spec = g_param_spec_string (" padding" ,
10706+ " Padding" ,
10707+ " What to pad the string with. Should be one codepoint (Unicode)" ,
10708+ options.padding .c_str (),
10709+ static_cast <GParamFlags>(G_PARAM_READWRITE));
10710+ g_object_class_install_property (gobject_class, PROP_ZERO_FILL_OPTIONS_PADDING, spec);
10711+ }
10712+
10713+ /* *
10714+ * garrow_zero_fill_options_new:
10715+ *
10716+ * Returns: A newly created #GArrowZeroFillOptions.
10717+ *
10718+ * Since: 23.0.0
10719+ */
10720+ GArrowZeroFillOptions *
10721+ garrow_zero_fill_options_new (void )
10722+ {
10723+ return GARROW_ZERO_FILL_OPTIONS (g_object_new (GARROW_TYPE_ZERO_FILL_OPTIONS, NULL ));
10724+ }
10725+
1057410726G_END_DECLS
1057510727
1057610728arrow::Result<arrow::FieldRef>
@@ -10852,6 +11004,11 @@ garrow_function_options_new_raw(const arrow::compute::FunctionOptions *arrow_opt
1085211004 static_cast <const arrow::compute::WinsorizeOptions *>(arrow_options);
1085311005 auto options = garrow_winsorize_options_new_raw (arrow_winsorize_options);
1085411006 return GARROW_FUNCTION_OPTIONS (options);
11007+ } else if (arrow_type_name == " ZeroFillOptions" ) {
11008+ const auto arrow_zero_fill_options =
11009+ static_cast <const arrow::compute::ZeroFillOptions *>(arrow_options);
11010+ auto options = garrow_zero_fill_options_new_raw (arrow_zero_fill_options);
11011+ return GARROW_FUNCTION_OPTIONS (options);
1085511012 } else {
1085611013 auto options = g_object_new (GARROW_TYPE_FUNCTION_OPTIONS, NULL );
1085711014 return GARROW_FUNCTION_OPTIONS (options);
@@ -11997,3 +12154,21 @@ garrow_winsorize_options_get_raw(GArrowWinsorizeOptions *options)
1199712154 return static_cast <arrow::compute::WinsorizeOptions *>(
1199812155 garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
1199912156}
12157+
12158+ GArrowZeroFillOptions *
12159+ garrow_zero_fill_options_new_raw (const arrow::compute::ZeroFillOptions *arrow_options)
12160+ {
12161+ return GARROW_ZERO_FILL_OPTIONS (g_object_new (GARROW_TYPE_ZERO_FILL_OPTIONS,
12162+ " width" ,
12163+ arrow_options->width ,
12164+ " padding" ,
12165+ arrow_options->padding .c_str (),
12166+ NULL ));
12167+ }
12168+
12169+ arrow::compute::ZeroFillOptions *
12170+ garrow_zero_fill_options_get_raw (GArrowZeroFillOptions *options)
12171+ {
12172+ return static_cast <arrow::compute::ZeroFillOptions *>(
12173+ garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
12174+ }
0 commit comments