@@ -285,6 +285,8 @@ G_BEGIN_DECLS
285285 * #GArrowListSliceOptions is a class to customize the `list_slice`
286286 * function.
287287 *
288+ * #GArrowModeOptions is a class to customize the `mode` function.
289+ *
288290 * There are many functions to compute data on an array.
289291 */
290292
@@ -7878,6 +7880,142 @@ garrow_list_slice_options_new(void)
78787880 return GARROW_LIST_SLICE_OPTIONS (options);
78797881}
78807882
7883+ enum {
7884+ PROP_MODE_OPTIONS_N = 1 ,
7885+ PROP_MODE_OPTIONS_SKIP_NULLS,
7886+ PROP_MODE_OPTIONS_MIN_COUNT,
7887+ };
7888+
7889+ G_DEFINE_TYPE (GArrowModeOptions, garrow_mode_options, GARROW_TYPE_FUNCTION_OPTIONS)
7890+
7891+ static void
7892+ garrow_mode_options_set_property(GObject *object,
7893+ guint prop_id,
7894+ const GValue *value,
7895+ GParamSpec *pspec)
7896+ {
7897+ auto options = garrow_mode_options_get_raw (GARROW_MODE_OPTIONS (object));
7898+
7899+ switch (prop_id) {
7900+ case PROP_MODE_OPTIONS_N:
7901+ options->n = g_value_get_int64 (value);
7902+ break ;
7903+ case PROP_MODE_OPTIONS_SKIP_NULLS:
7904+ options->skip_nulls = g_value_get_boolean (value);
7905+ break ;
7906+ case PROP_MODE_OPTIONS_MIN_COUNT:
7907+ options->min_count = g_value_get_uint (value);
7908+ break ;
7909+ default :
7910+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
7911+ break ;
7912+ }
7913+ }
7914+
7915+ static void
7916+ garrow_mode_options_get_property (GObject *object,
7917+ guint prop_id,
7918+ GValue *value,
7919+ GParamSpec *pspec)
7920+ {
7921+ auto options = garrow_mode_options_get_raw (GARROW_MODE_OPTIONS (object));
7922+
7923+ switch (prop_id) {
7924+ case PROP_MODE_OPTIONS_N:
7925+ g_value_set_int64 (value, options->n );
7926+ break ;
7927+ case PROP_MODE_OPTIONS_SKIP_NULLS:
7928+ g_value_set_boolean (value, options->skip_nulls );
7929+ break ;
7930+ case PROP_MODE_OPTIONS_MIN_COUNT:
7931+ g_value_set_uint (value, options->min_count );
7932+ break ;
7933+ default :
7934+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
7935+ break ;
7936+ }
7937+ }
7938+
7939+ static void
7940+ garrow_mode_options_init (GArrowModeOptions *object)
7941+ {
7942+ auto priv = GARROW_FUNCTION_OPTIONS_GET_PRIVATE (object);
7943+ priv->options =
7944+ static_cast <arrow::compute::FunctionOptions *>(new arrow::compute::ModeOptions ());
7945+ }
7946+
7947+ static void
7948+ garrow_mode_options_class_init (GArrowModeOptionsClass *klass)
7949+ {
7950+ auto gobject_class = G_OBJECT_CLASS (klass);
7951+
7952+ gobject_class->set_property = garrow_mode_options_set_property;
7953+ gobject_class->get_property = garrow_mode_options_get_property;
7954+
7955+ arrow::compute::ModeOptions options;
7956+
7957+ GParamSpec *spec;
7958+ /* *
7959+ * GArrowModeOptions:n:
7960+ *
7961+ * Number of distinct most-common values to return.
7962+ *
7963+ * Since: 23.0.0
7964+ */
7965+ spec = g_param_spec_int64 (" n" ,
7966+ " N" ,
7967+ " Number of distinct most-common values to return" ,
7968+ 1 ,
7969+ G_MAXINT64,
7970+ options.n ,
7971+ static_cast <GParamFlags>(G_PARAM_READWRITE));
7972+ g_object_class_install_property (gobject_class, PROP_MODE_OPTIONS_N, spec);
7973+
7974+ /* *
7975+ * GArrowModeOptions:skip-nulls:
7976+ *
7977+ * Whether NULLs are skipped or not.
7978+ *
7979+ * Since: 23.0.0
7980+ */
7981+ spec = g_param_spec_boolean (" skip-nulls" ,
7982+ " Skip NULLs" ,
7983+ " Whether NULLs are skipped or not" ,
7984+ options.skip_nulls ,
7985+ static_cast <GParamFlags>(G_PARAM_READWRITE));
7986+ g_object_class_install_property (gobject_class, PROP_MODE_OPTIONS_SKIP_NULLS, spec);
7987+
7988+ /* *
7989+ * GArrowModeOptions:min-count:
7990+ *
7991+ * If less than this many non-null values are observed, emit null.
7992+ *
7993+ * Since: 23.0.0
7994+ */
7995+ spec =
7996+ g_param_spec_uint (" min-count" ,
7997+ " Min count" ,
7998+ " If less than this many non-null values are observed, emit null" ,
7999+ 0 ,
8000+ G_MAXUINT,
8001+ options.min_count ,
8002+ static_cast <GParamFlags>(G_PARAM_READWRITE));
8003+ g_object_class_install_property (gobject_class, PROP_MODE_OPTIONS_MIN_COUNT, spec);
8004+ }
8005+
8006+ /* *
8007+ * garrow_mode_options_new:
8008+ *
8009+ * Returns: A newly created #GArrowModeOptions.
8010+ *
8011+ * Since: 23.0.0
8012+ */
8013+ GArrowModeOptions *
8014+ garrow_mode_options_new (void )
8015+ {
8016+ return GARROW_MODE_OPTIONS (g_object_new (GARROW_TYPE_MODE_OPTIONS, NULL ));
8017+ }
8018+
78818019G_END_DECLS
78828020
78838021arrow::Result<arrow::FieldRef>
@@ -8062,6 +8200,11 @@ garrow_function_options_new_raw(const arrow::compute::FunctionOptions *arrow_opt
80628200 static_cast <const arrow::compute::MapLookupOptions *>(arrow_options);
80638201 auto options = garrow_map_lookup_options_new_raw (arrow_map_lookup_options);
80648202 return GARROW_FUNCTION_OPTIONS (options);
8203+ } else if (arrow_type_name == " ModeOptions" ) {
8204+ const auto arrow_mode_options =
8205+ static_cast <const arrow::compute::ModeOptions *>(arrow_options);
8206+ auto options = garrow_mode_options_new_raw (arrow_mode_options);
8207+ return GARROW_FUNCTION_OPTIONS (options);
80658208 } else {
80668209 auto options = g_object_new (GARROW_TYPE_FUNCTION_OPTIONS, NULL );
80678210 return GARROW_FUNCTION_OPTIONS (options);
@@ -8815,3 +8958,24 @@ garrow_list_slice_options_get_raw(GArrowListSliceOptions *options)
88158958 return static_cast <arrow::compute::ListSliceOptions *>(
88168959 garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
88178960}
8961+
8962+ GArrowModeOptions *
8963+ garrow_mode_options_new_raw (const arrow::compute::ModeOptions *arrow_options)
8964+ {
8965+ auto options = g_object_new (GARROW_TYPE_MODE_OPTIONS,
8966+ " n" ,
8967+ arrow_options->n ,
8968+ " skip-nulls" ,
8969+ arrow_options->skip_nulls ,
8970+ " min-count" ,
8971+ arrow_options->min_count ,
8972+ NULL );
8973+ return GARROW_MODE_OPTIONS (options);
8974+ }
8975+
8976+ arrow::compute::ModeOptions *
8977+ garrow_mode_options_get_raw (GArrowModeOptions *options)
8978+ {
8979+ return static_cast <arrow::compute::ModeOptions *>(
8980+ garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
8981+ }
0 commit comments