@@ -279,6 +279,9 @@ G_BEGIN_DECLS
279279 * #GArrowListFlattenOptions is a class to customize the `list_flatten`
280280 * function.
281281 *
282+ * #GArrowMapLookupOptions is a class to customize the `map_lookup`
283+ * function.
284+ *
282285 * There are many functions to compute data on an array.
283286 */
284287
@@ -7498,6 +7501,169 @@ garrow_list_flatten_options_new(void)
74987501 return GARROW_LIST_FLATTEN_OPTIONS (options);
74997502}
75007503
7504+ typedef struct GArrowMapLookupOptionsPrivate_
7505+ {
7506+ GArrowScalar *query_key;
7507+ } GArrowMapLookupOptionsPrivate;
7508+
7509+ enum {
7510+ PROP_MAP_LOOKUP_OPTIONS_QUERY_KEY = 1 ,
7511+ PROP_MAP_LOOKUP_OPTIONS_OCCURRENCE,
7512+ };
7513+
7514+ G_DEFINE_TYPE_WITH_PRIVATE (GArrowMapLookupOptions,
7515+ garrow_map_lookup_options,
7516+ GARROW_TYPE_FUNCTION_OPTIONS)
7517+
7518+ #define GARROW_MAP_LOOKUP_OPTIONS_GET_PRIVATE (object ) \
7519+ static_cast <GArrowMapLookupOptionsPrivate *>( \
7520+ garrow_map_lookup_options_get_instance_private (GARROW_MAP_LOOKUP_OPTIONS(object)))
7521+
7522+ static void
7523+ garrow_map_lookup_options_dispose(GObject *object)
7524+ {
7525+ auto priv = GARROW_MAP_LOOKUP_OPTIONS_GET_PRIVATE (object);
7526+
7527+ if (priv->query_key ) {
7528+ g_object_unref (priv->query_key );
7529+ priv->query_key = NULL ;
7530+ }
7531+
7532+ G_OBJECT_CLASS (garrow_map_lookup_options_parent_class)->dispose (object);
7533+ }
7534+
7535+ static void
7536+ garrow_map_lookup_options_set_property (GObject *object,
7537+ guint prop_id,
7538+ const GValue *value,
7539+ GParamSpec *pspec)
7540+ {
7541+ auto priv = GARROW_MAP_LOOKUP_OPTIONS_GET_PRIVATE (object);
7542+ auto options = garrow_map_lookup_options_get_raw (GARROW_MAP_LOOKUP_OPTIONS (object));
7543+
7544+ switch (prop_id) {
7545+ case PROP_MAP_LOOKUP_OPTIONS_QUERY_KEY:
7546+ {
7547+ auto query_key = g_value_get_object (value);
7548+ if (priv->query_key != query_key) {
7549+ if (priv->query_key ) {
7550+ g_object_unref (priv->query_key );
7551+ }
7552+ priv->query_key = GARROW_SCALAR (query_key);
7553+ if (priv->query_key ) {
7554+ g_object_ref (priv->query_key );
7555+ options->query_key = garrow_scalar_get_raw (priv->query_key );
7556+ } else {
7557+ options->query_key = nullptr ;
7558+ }
7559+ }
7560+ }
7561+ break ;
7562+ case PROP_MAP_LOOKUP_OPTIONS_OCCURRENCE:
7563+ options->occurrence =
7564+ static_cast <arrow::compute::MapLookupOptions::Occurrence>(g_value_get_enum (value));
7565+ break ;
7566+ default :
7567+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
7568+ break ;
7569+ }
7570+ }
7571+
7572+ static void
7573+ garrow_map_lookup_options_get_property (GObject *object,
7574+ guint prop_id,
7575+ GValue *value,
7576+ GParamSpec *pspec)
7577+ {
7578+ auto priv = GARROW_MAP_LOOKUP_OPTIONS_GET_PRIVATE (object);
7579+ auto options = garrow_map_lookup_options_get_raw (GARROW_MAP_LOOKUP_OPTIONS (object));
7580+
7581+ switch (prop_id) {
7582+ case PROP_MAP_LOOKUP_OPTIONS_QUERY_KEY:
7583+ g_value_set_object (value, priv->query_key );
7584+ break ;
7585+ case PROP_MAP_LOOKUP_OPTIONS_OCCURRENCE:
7586+ g_value_set_enum (value, static_cast <GArrowMapLookupOccurrence>(options->occurrence ));
7587+ break ;
7588+ default :
7589+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
7590+ break ;
7591+ }
7592+ }
7593+
7594+ static void
7595+ garrow_map_lookup_options_init (GArrowMapLookupOptions *object)
7596+ {
7597+ auto priv = GARROW_FUNCTION_OPTIONS_GET_PRIVATE (object);
7598+ priv->options = static_cast <arrow::compute::FunctionOptions *>(
7599+ new arrow::compute::MapLookupOptions ());
7600+ }
7601+
7602+ static void
7603+ garrow_map_lookup_options_class_init (GArrowMapLookupOptionsClass *klass)
7604+ {
7605+ auto gobject_class = G_OBJECT_CLASS (klass);
7606+
7607+ gobject_class->dispose = garrow_map_lookup_options_dispose;
7608+ gobject_class->set_property = garrow_map_lookup_options_set_property;
7609+ gobject_class->get_property = garrow_map_lookup_options_get_property;
7610+
7611+ arrow::compute::MapLookupOptions options;
7612+
7613+ GParamSpec *spec;
7614+ /* *
7615+ * GArrowMapLookupOptions:query-key:
7616+ *
7617+ * The key to lookup in the map.
7618+ *
7619+ * Since: 23.0.0
7620+ */
7621+ spec = g_param_spec_object (" query-key" ,
7622+ " Query key" ,
7623+ " The key to lookup in the map" ,
7624+ GARROW_TYPE_SCALAR,
7625+ static_cast <GParamFlags>(G_PARAM_READWRITE));
7626+ g_object_class_install_property (gobject_class, PROP_MAP_LOOKUP_OPTIONS_QUERY_KEY, spec);
7627+
7628+ /* *
7629+ * GArrowMapLookupOptions:occurrence:
7630+ *
7631+ * Whether to return the first, last, or all matching values.
7632+ *
7633+ * Since: 23.0.0
7634+ */
7635+ spec = g_param_spec_enum (" occurrence" ,
7636+ " Occurrence" ,
7637+ " Whether to return the first, last, or all matching values" ,
7638+ GARROW_TYPE_MAP_LOOKUP_OCCURRENCE,
7639+ static_cast <GArrowMapLookupOccurrence>(options.occurrence ),
7640+ static_cast <GParamFlags>(G_PARAM_READWRITE));
7641+ g_object_class_install_property (gobject_class,
7642+ PROP_MAP_LOOKUP_OPTIONS_OCCURRENCE,
7643+ spec);
7644+ }
7645+
7646+ /* *
7647+ * garrow_map_lookup_options_new:
7648+ * @query_key: (nullable): A #GArrowScalar to be looked up.
7649+ * @occurrence: A #GArrowMapLookupOccurrence.
7650+ *
7651+ * Returns: A newly created #GArrowMapLookupOptions.
7652+ *
7653+ * Since: 23.0.0
7654+ */
7655+ GArrowMapLookupOptions *
7656+ garrow_map_lookup_options_new (GArrowScalar *query_key,
7657+ GArrowMapLookupOccurrence occurrence)
7658+ {
7659+ return GARROW_MAP_LOOKUP_OPTIONS (g_object_new (GARROW_TYPE_MAP_LOOKUP_OPTIONS,
7660+ " query-key" ,
7661+ query_key,
7662+ " occurrence" ,
7663+ occurrence,
7664+ NULL ));
7665+ }
7666+
75017667G_END_DECLS
75027668
75037669arrow::Result<arrow::FieldRef>
@@ -7677,6 +7843,11 @@ garrow_function_options_new_raw(const arrow::compute::FunctionOptions *arrow_opt
76777843 static_cast <const arrow::compute::ListFlattenOptions *>(arrow_options);
76787844 auto options = garrow_list_flatten_options_new_raw (arrow_list_flatten_options);
76797845 return GARROW_FUNCTION_OPTIONS (options);
7846+ } else if (arrow_type_name == " MapLookupOptions" ) {
7847+ const auto arrow_map_lookup_options =
7848+ static_cast <const arrow::compute::MapLookupOptions *>(arrow_options);
7849+ auto options = garrow_map_lookup_options_new_raw (arrow_map_lookup_options);
7850+ return GARROW_FUNCTION_OPTIONS (options);
76807851 } else {
76817852 auto options = g_object_new (GARROW_TYPE_FUNCTION_OPTIONS, NULL );
76827853 return GARROW_FUNCTION_OPTIONS (options);
@@ -8370,3 +8541,28 @@ garrow_list_flatten_options_get_raw(GArrowListFlattenOptions *options)
83708541 return static_cast <arrow::compute::ListFlattenOptions *>(
83718542 garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
83728543}
8544+
8545+ GArrowMapLookupOptions *
8546+ garrow_map_lookup_options_new_raw (const arrow::compute::MapLookupOptions *arrow_options)
8547+ {
8548+ GArrowScalar *query_key = nullptr ;
8549+ if (arrow_options->query_key ) {
8550+ auto arrow_query_key = arrow_options->query_key ;
8551+ query_key = garrow_scalar_new_raw (&arrow_query_key);
8552+ }
8553+ GArrowMapLookupOccurrence occurrence =
8554+ static_cast <GArrowMapLookupOccurrence>(arrow_options->occurrence );
8555+ return GARROW_MAP_LOOKUP_OPTIONS (g_object_new (GARROW_TYPE_MAP_LOOKUP_OPTIONS,
8556+ " query-key" ,
8557+ query_key,
8558+ " occurrence" ,
8559+ occurrence,
8560+ NULL ));
8561+ }
8562+
8563+ arrow::compute::MapLookupOptions *
8564+ garrow_map_lookup_options_get_raw (GArrowMapLookupOptions *options)
8565+ {
8566+ return static_cast <arrow::compute::MapLookupOptions *>(
8567+ garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
8568+ }
0 commit comments