@@ -254,6 +254,10 @@ G_BEGIN_DECLS
254254 * #GArrowAssumeTimezoneOptions is a class to customize the `assume_timezone`
255255 * function.
256256 *
257+ * #GArrowCumulativeOptions is a class to customize the cumulative functions
258+ * such as `cumulative_sum`, `cumulative_prod`, `cumulative_max`, and
259+ * `cumulative_min`.
260+ *
257261 * There are many functions to compute data on an array.
258262 */
259263
@@ -6491,6 +6495,173 @@ garrow_assume_timezone_options_new(void)
64916495 return GARROW_ASSUME_TIMEZONE_OPTIONS (options);
64926496}
64936497
6498+ typedef struct GArrowCumulativeOptionsPrivate_
6499+ {
6500+ GArrowScalar *start;
6501+ } GArrowCumulativeOptionsPrivate;
6502+
6503+ enum {
6504+ PROP_CUMULATIVE_OPTIONS_START = 1 ,
6505+ PROP_CUMULATIVE_OPTIONS_SKIP_NULLS,
6506+ };
6507+
6508+ G_DEFINE_TYPE_WITH_PRIVATE (GArrowCumulativeOptions,
6509+ garrow_cumulative_options,
6510+ GARROW_TYPE_FUNCTION_OPTIONS)
6511+
6512+ #define GARROW_CUMULATIVE_OPTIONS_GET_PRIVATE (object ) \
6513+ static_cast <GArrowCumulativeOptionsPrivate *>( \
6514+ garrow_cumulative_options_get_instance_private (GARROW_CUMULATIVE_OPTIONS(object)))
6515+
6516+ static void
6517+ garrow_cumulative_options_dispose(GObject *object)
6518+ {
6519+ auto priv = GARROW_CUMULATIVE_OPTIONS_GET_PRIVATE (object);
6520+
6521+ if (priv->start ) {
6522+ g_object_unref (priv->start );
6523+ priv->start = nullptr ;
6524+ }
6525+
6526+ G_OBJECT_CLASS (garrow_cumulative_options_parent_class)->dispose (object);
6527+ }
6528+
6529+ static void
6530+ garrow_cumulative_options_set_property (GObject *object,
6531+ guint prop_id,
6532+ const GValue *value,
6533+ GParamSpec *pspec)
6534+ {
6535+ auto priv = GARROW_CUMULATIVE_OPTIONS_GET_PRIVATE (object);
6536+ auto options = garrow_cumulative_options_get_raw (GARROW_CUMULATIVE_OPTIONS (object));
6537+
6538+ switch (prop_id) {
6539+ case PROP_CUMULATIVE_OPTIONS_START:
6540+ {
6541+ auto scalar = GARROW_SCALAR (g_value_get_object (value));
6542+ if (priv->start == scalar) {
6543+ return ;
6544+ }
6545+ if (priv->start ) {
6546+ g_object_unref (priv->start );
6547+ }
6548+ priv->start = scalar;
6549+ if (priv->start ) {
6550+ g_object_ref (priv->start );
6551+ options->start = garrow_scalar_get_raw (scalar);
6552+ } else {
6553+ options->start = std::nullopt ;
6554+ }
6555+ break ;
6556+ }
6557+ case PROP_CUMULATIVE_OPTIONS_SKIP_NULLS:
6558+ options->skip_nulls = g_value_get_boolean (value);
6559+ break ;
6560+ default :
6561+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
6562+ break ;
6563+ }
6564+ }
6565+
6566+ static void
6567+ garrow_cumulative_options_get_property (GObject *object,
6568+ guint prop_id,
6569+ GValue *value,
6570+ GParamSpec *pspec)
6571+ {
6572+ auto priv = GARROW_CUMULATIVE_OPTIONS_GET_PRIVATE (object);
6573+ auto options = garrow_cumulative_options_get_raw (GARROW_CUMULATIVE_OPTIONS (object));
6574+
6575+ switch (prop_id) {
6576+ case PROP_CUMULATIVE_OPTIONS_START:
6577+ {
6578+ if (priv->start ) {
6579+ g_value_set_object (value, G_OBJECT (priv->start ));
6580+ } else {
6581+ g_value_set_object (value, NULL );
6582+ }
6583+ break ;
6584+ }
6585+ case PROP_CUMULATIVE_OPTIONS_SKIP_NULLS:
6586+ g_value_set_boolean (value, options->skip_nulls );
6587+ break ;
6588+ default :
6589+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
6590+ break ;
6591+ }
6592+ }
6593+
6594+ static void
6595+ garrow_cumulative_options_init (GArrowCumulativeOptions *object)
6596+ {
6597+ auto priv = GARROW_CUMULATIVE_OPTIONS_GET_PRIVATE (object);
6598+ priv->start = nullptr ;
6599+ auto function_options_priv = GARROW_FUNCTION_OPTIONS_GET_PRIVATE (object);
6600+ function_options_priv->options = static_cast <arrow::compute::FunctionOptions *>(
6601+ new arrow::compute::CumulativeOptions ());
6602+ }
6603+
6604+ static void
6605+ garrow_cumulative_options_class_init (GArrowCumulativeOptionsClass *klass)
6606+ {
6607+ auto gobject_class = G_OBJECT_CLASS (klass);
6608+
6609+ gobject_class->dispose = garrow_cumulative_options_dispose;
6610+ gobject_class->set_property = garrow_cumulative_options_set_property;
6611+ gobject_class->get_property = garrow_cumulative_options_get_property;
6612+
6613+ arrow::compute::CumulativeOptions options;
6614+
6615+ GParamSpec *spec;
6616+ /* *
6617+ * GArrowCumulativeOptions:start:
6618+ *
6619+ * Optional starting value for cumulative operation computation.
6620+ *
6621+ * Since: 23.0.0
6622+ */
6623+ spec =
6624+ g_param_spec_object (" start" ,
6625+ " Start" ,
6626+ " Optional starting value for cumulative operation computation" ,
6627+ GARROW_TYPE_SCALAR,
6628+ static_cast <GParamFlags>(G_PARAM_READWRITE));
6629+ g_object_class_install_property (gobject_class, PROP_CUMULATIVE_OPTIONS_START, spec);
6630+
6631+ /* *
6632+ * GArrowCumulativeOptions:skip-nulls:
6633+ *
6634+ * If true, nulls in the input are ignored and produce a corresponding null output.
6635+ * When false, the first null encountered is propagated through the remaining output.
6636+ *
6637+ * Since: 23.0.0
6638+ */
6639+ spec = g_param_spec_boolean (
6640+ " skip-nulls" ,
6641+ " Skip nulls" ,
6642+ " If true, nulls in the input are ignored and produce a corresponding null output. "
6643+ " When false, the first null encountered is propagated through the remaining output" ,
6644+ options.skip_nulls ,
6645+ static_cast <GParamFlags>(G_PARAM_READWRITE));
6646+ g_object_class_install_property (gobject_class,
6647+ PROP_CUMULATIVE_OPTIONS_SKIP_NULLS,
6648+ spec);
6649+ }
6650+
6651+ /* *
6652+ * garrow_cumulative_options_new:
6653+ *
6654+ * Returns: A newly created #GArrowCumulativeOptions.
6655+ *
6656+ * Since: 23.0.0
6657+ */
6658+ GArrowCumulativeOptions *
6659+ garrow_cumulative_options_new (void )
6660+ {
6661+ auto options = g_object_new (GARROW_TYPE_CUMULATIVE_OPTIONS, NULL );
6662+ return GARROW_CUMULATIVE_OPTIONS (options);
6663+ }
6664+
64946665G_END_DECLS
64956666
64966667arrow::Result<arrow::FieldRef>
@@ -6627,6 +6798,11 @@ garrow_function_options_new_raw(const arrow::compute::FunctionOptions *arrow_opt
66276798 static_cast <const arrow::compute::AssumeTimezoneOptions *>(arrow_options);
66286799 auto options = garrow_assume_timezone_options_new_raw (arrow_assume_timezone_options);
66296800 return GARROW_FUNCTION_OPTIONS (options);
6801+ } else if (arrow_type_name == " CumulativeOptions" ) {
6802+ const auto arrow_cumulative_options =
6803+ static_cast <const arrow::compute::CumulativeOptions *>(arrow_options);
6804+ auto options = garrow_cumulative_options_new_raw (arrow_cumulative_options);
6805+ return GARROW_FUNCTION_OPTIONS (options);
66306806 } else {
66316807 auto options = g_object_new (GARROW_TYPE_FUNCTION_OPTIONS, NULL );
66326808 return GARROW_FUNCTION_OPTIONS (options);
@@ -7167,3 +7343,30 @@ garrow_assume_timezone_options_get_raw(GArrowAssumeTimezoneOptions *options)
71677343 return static_cast <arrow::compute::AssumeTimezoneOptions *>(
71687344 garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
71697345}
7346+
7347+ GArrowCumulativeOptions *
7348+ garrow_cumulative_options_new_raw (const arrow::compute::CumulativeOptions *arrow_options)
7349+ {
7350+ GArrowScalar *start = nullptr ;
7351+ if (arrow_options->start .has_value ()) {
7352+ std::shared_ptr<arrow::Scalar> arrow_start = arrow_options->start .value ();
7353+ start = garrow_scalar_new_raw (&arrow_start);
7354+ }
7355+ auto options = GARROW_CUMULATIVE_OPTIONS (g_object_new (GARROW_TYPE_CUMULATIVE_OPTIONS,
7356+ " start" ,
7357+ start,
7358+ " skip-nulls" ,
7359+ arrow_options->skip_nulls ,
7360+ NULL ));
7361+ if (start) {
7362+ g_object_unref (start);
7363+ }
7364+ return options;
7365+ }
7366+
7367+ arrow::compute::CumulativeOptions *
7368+ garrow_cumulative_options_get_raw (GArrowCumulativeOptions *options)
7369+ {
7370+ return static_cast <arrow::compute::CumulativeOptions *>(
7371+ garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
7372+ }
0 commit comments