Skip to content

Commit

Permalink
Merge branch 'master' into ARROW-15260_filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisnic authored Jul 26, 2022
2 parents 6220e7f + a5a2837 commit c3b5774
Show file tree
Hide file tree
Showing 309 changed files with 12,707 additions and 2,924 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ jobs:
# aws-sdk-cpp.
DOCKER_RUN_ARGS: >-
"
-e ARROW_BUILD_STATIC=OFF
-e ARROW_FLIGHT=ON
-e ARROW_GCS=OFF
-e ARROW_MIMALLOC=OFF
Expand Down Expand Up @@ -145,7 +144,6 @@ jobs:
# aws-sdk-cpp.
DOCKER_RUN_ARGS: >-
"
-e ARROW_BUILD_STATIC=OFF
-e ARROW_FLIGHT=ON
-e ARROW_GCS=OFF
-e ARROW_MIMALLOC=OFF
Expand Down
1 change: 1 addition & 0 deletions c_glib/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.

brew "autoconf-archive"
brew "glib-utils"
brew "gobject-introspection"
brew "gtk-doc"
brew "libtool"
Expand Down
1 change: 1 addition & 0 deletions c_glib/arrow-cuda-glib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ if have_gi
dependencies: gir_dependencies,
export_packages: 'arrow-cuda-glib',
extra_args: gir_extra_args,
fatal_warnings: gi_fatal_warnings,
header: 'arrow-cuda-glib/arrow-cuda-glib.h',
identifier_prefix: 'GArrowCUDA',
includes: [
Expand Down
1 change: 1 addition & 0 deletions c_glib/arrow-dataset-glib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ if have_gi
'--warn-all',
'--include-uninstalled=./arrow-glib/Arrow-1.0.gir',
],
fatal_warnings: gi_fatal_warnings,
header: 'arrow-dataset-glib/arrow-dataset-glib.h',
identifier_prefix: 'GADataset',
includes: [
Expand Down
152 changes: 152 additions & 0 deletions c_glib/arrow-flight-glib/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,72 @@ gaflight_call_options_new(void)
g_object_new(GAFLIGHT_TYPE_CALL_OPTIONS, NULL));
}

/**
* gaflight_call_options_add_header:
* @options: A #GAFlightCallOptions.
* @name: A header name.
* @value: A header value.
*
* Add a header.
*
* Since: 9.0.0
*/
void
gaflight_call_options_add_header(GAFlightCallOptions *options,
const gchar *name,
const gchar *value)
{
auto flight_options = gaflight_call_options_get_raw(options);
flight_options->headers.emplace_back(name, value);
}

/**
* gaflight_call_options_clear_headers:
* @options: A #GAFlightCallOptions.
*
* Clear all headers.
*
* Since: 9.0.0
*/
void
gaflight_call_options_clear_headers(GAFlightCallOptions *options)
{
auto flight_options = gaflight_call_options_get_raw(options);
flight_options->headers.clear();
}

/**
* gaflight_call_options_foreach_header:
* @options: A #GAFlightCallOptions.
* @func: (scope call): The user's callback function.
* @user_data: (closure): Data for @func.
*
* Iterates over all header in the options.
*
* Since: 9.0.0
*/
void
gaflight_call_options_foreach_header(GAFlightCallOptions *options,
GAFlightHeaderFunc func,
gpointer user_data)
{
auto flight_options = gaflight_call_options_get_raw(options);
for (const auto &header : flight_options->headers) {
auto &key = header.first;
auto &value = header.second;
func(key.c_str(), value.c_str(), user_data);
}
}


typedef struct GAFlightClientOptionsPrivate_ {
arrow::flight::FlightClientOptions options;
} GAFlightClientOptionsPrivate;

enum {
PROP_DISABLE_SERVER_VERIFICATION = 1,
};

G_DEFINE_TYPE_WITH_PRIVATE(GAFlightClientOptions,
gaflight_client_options,
G_TYPE_OBJECT)
Expand All @@ -132,6 +193,42 @@ gaflight_client_options_finalize(GObject *object)
G_OBJECT_CLASS(gaflight_client_options_parent_class)->finalize(object);
}

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

switch (prop_id) {
case PROP_DISABLE_SERVER_VERIFICATION:
priv->options.disable_server_verification = g_value_get_boolean(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}

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

switch (prop_id) {
case PROP_DISABLE_SERVER_VERIFICATION:
g_value_set_boolean(value, priv->options.disable_server_verification);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}

static void
gaflight_client_options_init(GAFlightClientOptions *object)
{
Expand All @@ -146,6 +243,27 @@ gaflight_client_options_class_init(GAFlightClientOptionsClass *klass)
auto gobject_class = G_OBJECT_CLASS(klass);

gobject_class->finalize = gaflight_client_options_finalize;
gobject_class->set_property = gaflight_client_options_set_property;
gobject_class->get_property = gaflight_client_options_get_property;

auto options = arrow::flight::FlightClientOptions::Defaults();
GParamSpec *spec;
/**
* GAFlightClientOptions:disable-server-verification:
*
* Whether use TLS without validating the server certificate. Use
* with caution.
*
* Since: 9.0.0
*/
spec = g_param_spec_boolean("disable-server-verification",
NULL,
NULL,
options.disable_server_verification,
static_cast<GParamFlags>(G_PARAM_READWRITE));
g_object_class_install_property(gobject_class,
PROP_DISABLE_SERVER_VERIFICATION,
spec);
}

/**
Expand Down Expand Up @@ -342,6 +460,40 @@ gaflight_client_list_flights(GAFlightClient *client,
return g_list_reverse(listing);
}

/**
* gaflight_client_get_flight_info:
* @client: A #GAFlightClient.
* @descriptor: A #GAFlightDescriptor to be processed.
* @options: (nullable): A #GAFlightCallOptions.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Returns: (nullable) (transfer full): The returned #GAFlightInfo on
* success, %NULL on error.
*
* Since: 9.0.0
*/
GAFlightInfo *
gaflight_client_get_flight_info(GAFlightClient *client,
GAFlightDescriptor *descriptor,
GAFlightCallOptions *options,
GError **error)
{
auto flight_client = gaflight_client_get_raw(client);
auto flight_descriptor = gaflight_descriptor_get_raw(descriptor);
arrow::flight::FlightCallOptions flight_default_options;
auto flight_options = &flight_default_options;
if (options) {
flight_options = gaflight_call_options_get_raw(options);
}
auto result = flight_client->GetFlightInfo(*flight_options,
*flight_descriptor);
if (!garrow::check(error, result, "[flight-client][get-flight-info]")) {
return NULL;
}
auto flight_info = std::move(*result);
return gaflight_info_new_raw(flight_info.release());
}

/**
* gaflight_client_do_get:
* @client: A #GAFlightClient.
Expand Down
21 changes: 21 additions & 0 deletions c_glib/arrow-flight-glib/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ GARROW_AVAILABLE_IN_5_0
GAFlightCallOptions *
gaflight_call_options_new(void);

GARROW_AVAILABLE_IN_9_0
void
gaflight_call_options_add_header(GAFlightCallOptions *options,
const gchar *name,
const gchar *value);
GARROW_AVAILABLE_IN_9_0
void
gaflight_call_options_clear_headers(GAFlightCallOptions *options);
GARROW_AVAILABLE_IN_9_0
void
gaflight_call_options_foreach_header(GAFlightCallOptions *options,
GAFlightHeaderFunc func,
gpointer user_data);


#define GAFLIGHT_TYPE_CLIENT_OPTIONS (gaflight_client_options_get_type())
G_DECLARE_DERIVABLE_TYPE(GAFlightClientOptions,
Expand Down Expand Up @@ -98,6 +112,13 @@ gaflight_client_list_flights(GAFlightClient *client,
GAFlightCallOptions *options,
GError **error);

GARROW_AVAILABLE_IN_9_0
GAFlightInfo *
gaflight_client_get_flight_info(GAFlightClient *client,
GAFlightDescriptor *descriptor,
GAFlightCallOptions *options,
GError **error);

GARROW_AVAILABLE_IN_6_0
GAFlightStreamReader *
gaflight_client_do_get(GAFlightClient *client,
Expand Down
16 changes: 16 additions & 0 deletions c_glib/arrow-flight-glib/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ G_BEGIN_DECLS
* Since: 5.0.0
*/


/**
* GAFlightHeaderFunc:
* @name: A header name.
* @value: The value corresponding to the name.
* @user_data: User data passed to gaflight_call_options_foreach_header()
* and so on.
*
* It is called with each header name/value pair, together with the
* @user_data parameter which is passed to
* gaflight_call_options_foreach_header() and so on.
*
* Since: 9.0.0
*/


typedef struct GAFlightCriteriaPrivate_ {
arrow::flight::Criteria criteria;
GBytes *expression;
Expand Down
5 changes: 5 additions & 0 deletions c_glib/arrow-flight-glib/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
G_BEGIN_DECLS


typedef void(*GAFlightHeaderFunc)(const gchar *name,
const gchar *value,
gpointer user_data);


#define GAFLIGHT_TYPE_CRITERIA (gaflight_criteria_get_type())
G_DECLARE_DERIVABLE_TYPE(GAFlightCriteria,
gaflight_criteria,
Expand Down
1 change: 1 addition & 0 deletions c_glib/arrow-flight-glib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ if have_gi
'--warn-all',
'--include-uninstalled=./arrow-glib/Arrow-1.0.gir',
],
fatal_warnings: gi_fatal_warnings,
header: 'arrow-flight-glib/arrow-flight-glib.h',
identifier_prefix: 'GAFlight',
includes: [
Expand Down
52 changes: 52 additions & 0 deletions c_glib/arrow-flight-glib/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,30 @@ namespace gaflight {
return arrow::Status::OK();
}

arrow::Status
GetFlightInfo(const arrow::flight::ServerCallContext &context,
const arrow::flight::FlightDescriptor &request,
std::unique_ptr<arrow::flight::FlightInfo> *info) override {
auto gacontext = gaflight_server_call_context_new_raw(&context);
auto garequest = gaflight_descriptor_new_raw(&request);
GError *gerror = nullptr;
auto gainfo = gaflight_server_get_flight_info(gaserver_,
gacontext,
garequest,
&gerror);
g_object_unref(garequest);
g_object_unref(gacontext);
if (gerror) {
return garrow_error_to_status(gerror,
arrow::StatusCode::UnknownError,
"[flight-server][get-flight-info]");
}
*info = arrow::internal::make_unique<arrow::flight::FlightInfo>(
*gaflight_info_get_raw(gainfo));
g_object_unref(gainfo);
return arrow::Status::OK();
}

arrow::Status DoGet(
const arrow::flight::ServerCallContext &context,
const arrow::flight::Ticket &ticket,
Expand Down Expand Up @@ -666,6 +690,34 @@ gaflight_server_list_flights(GAFlightServer *server,
return (*(klass->list_flights))(server, context, criteria, error);
}

/**
* gaflight_server_get_flight_info:
* @server: A #GAFlightServer.
* @context: A #GAFlightServerCallContext.
* @request: A #GAFlightDescriptor.
* @error: (nullable): Return location for a #GError or %NULL.
*
* Returns: (transfer full): A #GAFlightInfo on success, %NULL on error.
*
* Since: 9.0.0
*/
GAFlightInfo *
gaflight_server_get_flight_info(GAFlightServer *server,
GAFlightServerCallContext *context,
GAFlightDescriptor *request,
GError **error)
{
auto klass = GAFLIGHT_SERVER_GET_CLASS(server);
if (!(klass && klass->get_flight_info)) {
g_set_error(error,
GARROW_ERROR,
GARROW_ERROR_NOT_IMPLEMENTED,
"not implemented");
return nullptr;
}
return (*(klass->get_flight_info))(server, context, request, error);
}

/**
* gaflight_server_do_get:
* @server: A #GAFlightServer.
Expand Down
10 changes: 10 additions & 0 deletions c_glib/arrow-flight-glib/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ struct _GAFlightServerClass
GAFlightServerCallContext *context,
GAFlightCriteria *criteria,
GError **error);
GAFlightInfo *(*get_flight_info)(GAFlightServer *server,
GAFlightServerCallContext *context,
GAFlightDescriptor *request,
GError **error);
GAFlightDataStream *(*do_get)(GAFlightServer *server,
GAFlightServerCallContext *context,
GAFlightTicket *ticket,
Expand Down Expand Up @@ -142,6 +146,12 @@ gaflight_server_list_flights(GAFlightServer *server,
GAFlightServerCallContext *context,
GAFlightCriteria *criteria,
GError **error);
GARROW_AVAILABLE_IN_9_0
GAFlightInfo *
gaflight_server_get_flight_info(GAFlightServer *server,
GAFlightServerCallContext *context,
GAFlightDescriptor *request,
GError **error);
GARROW_AVAILABLE_IN_6_0
GAFlightDataStream *
gaflight_server_do_get(GAFlightServer *server,
Expand Down
Loading

0 comments on commit c3b5774

Please sign in to comment.