Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into apachegh-43519-clea…
Browse files Browse the repository at this point in the history
…nup-requirements
  • Loading branch information
jorisvandenbossche committed Sep 24, 2024
2 parents fa3a507 + 508eb2f commit ae5fc8f
Show file tree
Hide file tree
Showing 18 changed files with 332 additions and 140 deletions.
70 changes: 66 additions & 4 deletions c_glib/arrow-flight-glib/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,20 @@ gaflight_metadata_reader_read(GAFlightMetadataReader *reader, GError **error)
}
}

typedef struct GAFlightCallOptionsPrivate_
struct GAFlightCallOptionsPrivate
{
arrow::flight::FlightCallOptions options;
} GAFlightCallOptionsPrivate;
};

enum {
PROP_TIMEOUT = 1,
};

G_DEFINE_TYPE_WITH_PRIVATE(GAFlightCallOptions, gaflight_call_options, G_TYPE_OBJECT)

#define GAFLIGHT_CALL_OPTIONS_GET_PRIVATE(obj) \
#define GAFLIGHT_CALL_OPTIONS_GET_PRIVATE(object) \
static_cast<GAFlightCallOptionsPrivate *>( \
gaflight_call_options_get_instance_private(GAFLIGHT_CALL_OPTIONS(obj)))
gaflight_call_options_get_instance_private(GAFLIGHT_CALL_OPTIONS(object)))

static void
gaflight_call_options_finalize(GObject *object)
Expand All @@ -208,6 +212,42 @@ gaflight_call_options_finalize(GObject *object)
G_OBJECT_CLASS(gaflight_call_options_parent_class)->finalize(object);
}

static void
gaflight_call_options_set_property(GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
auto priv = GAFLIGHT_CALL_OPTIONS_GET_PRIVATE(object);

switch (prop_id) {
case PROP_TIMEOUT:
priv->options.timeout = arrow::flight::TimeoutDuration(g_value_get_double(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}

static void
gaflight_call_options_get_property(GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
auto priv = GAFLIGHT_CALL_OPTIONS_GET_PRIVATE(object);

switch (prop_id) {
case PROP_TIMEOUT:
g_value_set_double(value, priv->options.timeout.count());
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}

static void
gaflight_call_options_init(GAFlightCallOptions *object)
{
Expand All @@ -221,6 +261,28 @@ gaflight_call_options_class_init(GAFlightCallOptionsClass *klass)
auto gobject_class = G_OBJECT_CLASS(klass);

gobject_class->finalize = gaflight_call_options_finalize;
gobject_class->set_property = gaflight_call_options_set_property;
gobject_class->get_property = gaflight_call_options_get_property;

arrow::flight::FlightCallOptions options;
GParamSpec *spec;
/**
* GAFlightCallOptions:timeout:
*
* An optional timeout for this call. Negative durations mean an
* implementation-defined default behavior will be used
* instead. This is the default value.
*
* Since: 18.0.0
*/
spec = g_param_spec_double("timeout",
nullptr,
nullptr,
-G_MAXDOUBLE,
G_MAXDOUBLE,
options.timeout.count(),
static_cast<GParamFlags>(G_PARAM_READWRITE));
g_object_class_install_property(gobject_class, PROP_TIMEOUT, spec);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions c_glib/test/flight/test-call-options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,10 @@ def test_clear_headers
@options.clear_headers
assert_equal([], collect_headers)
end

def test_timeout
assert_in_delta(-1, @options.timeout)
@options.timeout = 10.1
assert_in_delta(10.1, @options.timeout)
end
end
Loading

0 comments on commit ae5fc8f

Please sign in to comment.