@@ -315,6 +315,9 @@ G_BEGIN_DECLS
315315 * #GArrowRoundBinaryOptions is a class to customize the
316316 * `round_binary` function.
317317 *
318+ * #GArrowRoundTemporalOptions is a class to customize the `round_temporal`,
319+ * `floor_temporal`, and `ceil_temporal` functions.
320+ *
318321 * There are many functions to compute data on an array.
319322 */
320323
@@ -9158,6 +9161,203 @@ garrow_round_binary_options_new(void)
91589161 g_object_new (GARROW_TYPE_ROUND_BINARY_OPTIONS, nullptr ));
91599162}
91609163
9164+ enum {
9165+ PROP_ROUND_TEMPORAL_OPTIONS_MULTIPLE = 1 ,
9166+ PROP_ROUND_TEMPORAL_OPTIONS_UNIT,
9167+ PROP_ROUND_TEMPORAL_OPTIONS_WEEK_STARTS_MONDAY,
9168+ PROP_ROUND_TEMPORAL_OPTIONS_CEIL_IS_STRICTLY_GREATER,
9169+ PROP_ROUND_TEMPORAL_OPTIONS_CALENDAR_BASED_ORIGIN,
9170+ };
9171+
9172+ G_DEFINE_TYPE (GArrowRoundTemporalOptions,
9173+ garrow_round_temporal_options,
9174+ GARROW_TYPE_FUNCTION_OPTIONS)
9175+
9176+ static void
9177+ garrow_round_temporal_options_set_property(GObject *object,
9178+ guint prop_id,
9179+ const GValue *value,
9180+ GParamSpec *pspec)
9181+ {
9182+ auto options =
9183+ garrow_round_temporal_options_get_raw (GARROW_ROUND_TEMPORAL_OPTIONS (object));
9184+
9185+ switch (prop_id) {
9186+ case PROP_ROUND_TEMPORAL_OPTIONS_MULTIPLE:
9187+ options->multiple = g_value_get_int (value);
9188+ break ;
9189+ case PROP_ROUND_TEMPORAL_OPTIONS_UNIT:
9190+ options->unit = static_cast <arrow::compute::CalendarUnit>(g_value_get_enum (value));
9191+ break ;
9192+ case PROP_ROUND_TEMPORAL_OPTIONS_WEEK_STARTS_MONDAY:
9193+ options->week_starts_monday = g_value_get_boolean (value);
9194+ break ;
9195+ case PROP_ROUND_TEMPORAL_OPTIONS_CEIL_IS_STRICTLY_GREATER:
9196+ options->ceil_is_strictly_greater = g_value_get_boolean (value);
9197+ break ;
9198+ case PROP_ROUND_TEMPORAL_OPTIONS_CALENDAR_BASED_ORIGIN:
9199+ options->calendar_based_origin = g_value_get_boolean (value);
9200+ break ;
9201+ default :
9202+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
9203+ break ;
9204+ }
9205+ }
9206+
9207+ static void
9208+ garrow_round_temporal_options_get_property (GObject *object,
9209+ guint prop_id,
9210+ GValue *value,
9211+ GParamSpec *pspec)
9212+ {
9213+ auto options =
9214+ garrow_round_temporal_options_get_raw (GARROW_ROUND_TEMPORAL_OPTIONS (object));
9215+
9216+ switch (prop_id) {
9217+ case PROP_ROUND_TEMPORAL_OPTIONS_MULTIPLE:
9218+ g_value_set_int (value, options->multiple );
9219+ break ;
9220+ case PROP_ROUND_TEMPORAL_OPTIONS_UNIT:
9221+ g_value_set_enum (value, static_cast <GArrowCalendarUnit>(options->unit ));
9222+ break ;
9223+ case PROP_ROUND_TEMPORAL_OPTIONS_WEEK_STARTS_MONDAY:
9224+ g_value_set_boolean (value, options->week_starts_monday );
9225+ break ;
9226+ case PROP_ROUND_TEMPORAL_OPTIONS_CEIL_IS_STRICTLY_GREATER:
9227+ g_value_set_boolean (value, options->ceil_is_strictly_greater );
9228+ break ;
9229+ case PROP_ROUND_TEMPORAL_OPTIONS_CALENDAR_BASED_ORIGIN:
9230+ g_value_set_boolean (value, options->calendar_based_origin );
9231+ break ;
9232+ default :
9233+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
9234+ break ;
9235+ }
9236+ }
9237+
9238+ static void
9239+ garrow_round_temporal_options_init (GArrowRoundTemporalOptions *object)
9240+ {
9241+ auto arrow_priv = GARROW_FUNCTION_OPTIONS_GET_PRIVATE (object);
9242+ arrow_priv->options = static_cast <arrow::compute::FunctionOptions *>(
9243+ new arrow::compute::RoundTemporalOptions ());
9244+ }
9245+
9246+ static void
9247+ garrow_round_temporal_options_class_init (GArrowRoundTemporalOptionsClass *klass)
9248+ {
9249+ auto gobject_class = G_OBJECT_CLASS (klass);
9250+
9251+ gobject_class->set_property = garrow_round_temporal_options_set_property;
9252+ gobject_class->get_property = garrow_round_temporal_options_get_property;
9253+
9254+ arrow::compute::RoundTemporalOptions options;
9255+
9256+ GParamSpec *spec;
9257+ /* *
9258+ * GArrowRoundTemporalOptions:multiple:
9259+ *
9260+ * Number of units to round to.
9261+ *
9262+ * Since: 23.0.0
9263+ */
9264+ spec = g_param_spec_int (" multiple" ,
9265+ " Multiple" ,
9266+ " Number of units to round to" ,
9267+ G_MININT,
9268+ G_MAXINT,
9269+ options.multiple ,
9270+ static_cast <GParamFlags>(G_PARAM_READWRITE));
9271+ g_object_class_install_property (gobject_class,
9272+ PROP_ROUND_TEMPORAL_OPTIONS_MULTIPLE,
9273+ spec);
9274+
9275+ /* *
9276+ * GArrowRoundTemporalOptions:unit:
9277+ *
9278+ * The unit used for rounding of time.
9279+ *
9280+ * Since: 23.0.0
9281+ */
9282+ spec = g_param_spec_enum (" unit" ,
9283+ " Unit" ,
9284+ " The unit used for rounding of time" ,
9285+ GARROW_TYPE_CALENDAR_UNIT,
9286+ static_cast <GArrowCalendarUnit>(options.unit ),
9287+ static_cast <GParamFlags>(G_PARAM_READWRITE));
9288+ g_object_class_install_property (gobject_class, PROP_ROUND_TEMPORAL_OPTIONS_UNIT, spec);
9289+
9290+ /* *
9291+ * GArrowRoundTemporalOptions:week-starts-monday:
9292+ *
9293+ * What day does the week start with (Monday=true, Sunday=false).
9294+ *
9295+ * Since: 23.0.0
9296+ */
9297+ spec =
9298+ g_param_spec_boolean (" week-starts-monday" ,
9299+ " Week Starts Monday" ,
9300+ " What day does the week start with (Monday=true, Sunday=false)" ,
9301+ options.week_starts_monday ,
9302+ static_cast <GParamFlags>(G_PARAM_READWRITE));
9303+ g_object_class_install_property (gobject_class,
9304+ PROP_ROUND_TEMPORAL_OPTIONS_WEEK_STARTS_MONDAY,
9305+ spec);
9306+
9307+ /* *
9308+ * GArrowRoundTemporalOptions:ceil-is-strictly-greater:
9309+ *
9310+ * Enable this flag to return a rounded value that is strictly greater than the input.
9311+ * This applies for ceiling only.
9312+ *
9313+ * Since: 23.0.0
9314+ */
9315+ spec = g_param_spec_boolean (
9316+ " ceil-is-strictly-greater" ,
9317+ " Ceil Is Strictly Greater" ,
9318+ " Enable this flag to return a rounded value that is strictly greater than the input" ,
9319+ options.ceil_is_strictly_greater ,
9320+ static_cast <GParamFlags>(G_PARAM_READWRITE));
9321+ g_object_class_install_property (gobject_class,
9322+ PROP_ROUND_TEMPORAL_OPTIONS_CEIL_IS_STRICTLY_GREATER,
9323+ spec);
9324+
9325+ /* *
9326+ * GArrowRoundTemporalOptions:calendar-based-origin:
9327+ *
9328+ * By default time is rounded to a multiple of units since 1970-01-01T00:00:00.
9329+ * By setting calendar_based_origin to true, time will be rounded to a number
9330+ * of units since the last greater calendar unit.
9331+ *
9332+ * Since: 23.0.0
9333+ */
9334+ spec = g_param_spec_boolean (
9335+ " calendar-based-origin" ,
9336+ " Calendar Based Origin" ,
9337+ " By default time is rounded to a multiple of units since 1970-01-01T00:00:00. By "
9338+ " setting calendar_based_origin to true, time will be rounded to a number of units "
9339+ " since the last greater calendar unit" ,
9340+ options.calendar_based_origin ,
9341+ static_cast <GParamFlags>(G_PARAM_READWRITE));
9342+ g_object_class_install_property (gobject_class,
9343+ PROP_ROUND_TEMPORAL_OPTIONS_CALENDAR_BASED_ORIGIN,
9344+ spec);
9345+ }
9346+
9347+ /* *
9348+ * garrow_round_temporal_options_new:
9349+ *
9350+ * Returns: A newly created #GArrowRoundTemporalOptions.
9351+ *
9352+ * Since: 23.0.0
9353+ */
9354+ GArrowRoundTemporalOptions *
9355+ garrow_round_temporal_options_new (void )
9356+ {
9357+ return GARROW_ROUND_TEMPORAL_OPTIONS (
9358+ g_object_new (GARROW_TYPE_ROUND_TEMPORAL_OPTIONS, nullptr ));
9359+ }
9360+
91619361G_END_DECLS
91629362
91639363arrow::Result<arrow::FieldRef>
@@ -9393,6 +9593,11 @@ garrow_function_options_new_raw(const arrow::compute::FunctionOptions *arrow_opt
93939593 static_cast <const arrow::compute::RoundBinaryOptions *>(arrow_options);
93949594 auto options = garrow_round_binary_options_new_raw (arrow_round_binary_options);
93959595 return GARROW_FUNCTION_OPTIONS (options);
9596+ } else if (arrow_type_name == " RoundTemporalOptions" ) {
9597+ const auto arrow_round_temporal_options =
9598+ static_cast <const arrow::compute::RoundTemporalOptions *>(arrow_options);
9599+ auto options = garrow_round_temporal_options_new_raw (arrow_round_temporal_options);
9600+ return GARROW_FUNCTION_OPTIONS (options);
93969601 } else {
93979602 auto options = g_object_new (GARROW_TYPE_FUNCTION_OPTIONS, NULL );
93989603 return GARROW_FUNCTION_OPTIONS (options);
@@ -10343,3 +10548,29 @@ garrow_round_binary_options_get_raw(GArrowRoundBinaryOptions *options)
1034310548 return static_cast <arrow::compute::RoundBinaryOptions *>(
1034410549 garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
1034510550}
10551+
10552+ GArrowRoundTemporalOptions *
10553+ garrow_round_temporal_options_new_raw (
10554+ const arrow::compute::RoundTemporalOptions *arrow_options)
10555+ {
10556+ return GARROW_ROUND_TEMPORAL_OPTIONS (
10557+ g_object_new (GARROW_TYPE_ROUND_TEMPORAL_OPTIONS,
10558+ " multiple" ,
10559+ arrow_options->multiple ,
10560+ " unit" ,
10561+ static_cast <GArrowCalendarUnit>(arrow_options->unit ),
10562+ " week-starts-monday" ,
10563+ arrow_options->week_starts_monday ,
10564+ " ceil-is-strictly-greater" ,
10565+ arrow_options->ceil_is_strictly_greater ,
10566+ " calendar-based-origin" ,
10567+ arrow_options->calendar_based_origin ,
10568+ nullptr ));
10569+ }
10570+
10571+ arrow::compute::RoundTemporalOptions *
10572+ garrow_round_temporal_options_get_raw (GArrowRoundTemporalOptions *options)
10573+ {
10574+ return static_cast <arrow::compute::RoundTemporalOptions *>(
10575+ garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
10576+ }
0 commit comments