@@ -274,10 +274,11 @@ garrow_compute_initialize(GError **error)
274274 return garrow::check (error, status, " [compute][initialize]" );
275275}
276276
277- typedef struct GArrowExecuteContextPrivate_
277+ struct GArrowExecuteContextPrivate
278278{
279279 std::shared_ptr<arrow::compute::ExecContext> context;
280- } GArrowExecuteContextPrivate;
280+ GArrowExecutor *executor;
281+ };
281282
282283G_DEFINE_TYPE_WITH_PRIVATE (GArrowExecuteContext, garrow_execute_context, G_TYPE_OBJECT)
283284
@@ -289,6 +290,19 @@ enum {
289290 PROP_EXECUTOR = 1 ,
290291};
291292
293+ static void
294+ garrow_execute_context_dispose (GObject *object)
295+ {
296+ auto priv = GARROW_EXECUTE_CONTEXT_GET_PRIVATE (object);
297+
298+ if (priv->executor ) {
299+ g_object_unref (priv->executor );
300+ priv->executor = nullptr ;
301+ }
302+
303+ G_OBJECT_CLASS (garrow_execute_context_parent_class)->dispose (object);
304+ }
305+
292306static void
293307garrow_execute_context_finalize (GObject *object)
294308{
@@ -308,8 +322,8 @@ garrow_execute_context_set_property(GObject *object,
308322 switch (prop_id) {
309323 case PROP_EXECUTOR:
310324 {
311- auto executor = GARROW_EXECUTOR (g_value_get_object (value));
312- auto arrow_executor = garrow_executor_get_raw (executor);
325+ priv-> executor = GARROW_EXECUTOR (g_value_dup_object (value));
326+ auto arrow_executor = garrow_executor_get_raw (priv-> executor );
313327 priv->context =
314328 std::make_shared<arrow::compute::ExecContext>(arrow::default_memory_pool (),
315329 arrow_executor.get ());
@@ -321,28 +335,55 @@ garrow_execute_context_set_property(GObject *object,
321335 }
322336}
323337
338+ static void
339+ garrow_execute_context_get_property (GObject *object,
340+ guint prop_id,
341+ GValue *value,
342+ GParamSpec *pspec)
343+ {
344+ auto priv = GARROW_EXECUTE_CONTEXT_GET_PRIVATE (object);
345+
346+ switch (prop_id) {
347+ case PROP_EXECUTOR:
348+ g_value_set_object (value, priv->executor );
349+ break ;
350+ default :
351+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
352+ break ;
353+ }
354+ }
355+
324356static void
325357garrow_execute_context_init (GArrowExecuteContext *object)
326358{
327359 auto priv = GARROW_EXECUTE_CONTEXT_GET_PRIVATE (object);
328- priv->context = nullptr ;
360+ new (& priv->context ) std::shared_ptr<arrow::compute::ExecContext> ;
329361}
330362
331363static void
332364garrow_execute_context_class_init (GArrowExecuteContextClass *klass)
333365{
334366 auto gobject_class = G_OBJECT_CLASS (klass);
335367
368+ gobject_class->dispose = garrow_execute_context_dispose;
336369 gobject_class->finalize = garrow_execute_context_finalize;
337370 gobject_class->set_property = garrow_execute_context_set_property;
371+ gobject_class->get_property = garrow_execute_context_get_property;
338372
339373 GParamSpec *spec;
374+ /* *
375+ * GArrowExecuteContext:executor:
376+ *
377+ * The executor for execution.
378+ *
379+ * Since: 23.0.0
380+ */
340381 spec = g_param_spec_object (
341382 " executor" ,
342383 " Executor" ,
343- " The GArrowExecutor for execution" ,
384+ " The executor for execution" ,
344385 GARROW_TYPE_EXECUTOR,
345- static_cast <GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
386+ static_cast <GParamFlags>(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
346387 g_object_class_install_property (gobject_class, PROP_EXECUTOR, spec);
347388}
348389
0 commit comments