Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions c_glib/arrow-flight-glib/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,7 @@ G_BEGIN_DECLS
struct GAFlightServerPrivate
{
gaflight::Server server;
GAFlightServerOptions *options;
};

G_END_DECLS
Expand All @@ -1179,6 +1180,10 @@ gaflight_server_servable_interface_init(GAFlightServableInterface *iface)
iface->get_raw = gaflight_server_servable_get_raw;
}

enum {
PROP_OPTIONS = 1,
};

G_DEFINE_ABSTRACT_TYPE_WITH_CODE(
GAFlightServer, gaflight_server, G_TYPE_OBJECT, G_ADD_PRIVATE(GAFlightServer);
G_IMPLEMENT_INTERFACE(GAFLIGHT_TYPE_SERVABLE, gaflight_server_servable_interface_init))
Expand All @@ -1196,6 +1201,19 @@ gaflight_server_servable_get_raw(GAFlightServable *servable)
}
G_BEGIN_DECLS

static void
gaflight_server_dispose(GObject *object)
{
auto priv = GAFLIGHT_SERVER_GET_PRIVATE(object);

if (priv->options) {
g_object_unref(priv->options);
priv->options = nullptr;
}
Comment on lines +1209 to +1212
Comment on lines +1207 to +1212

Comment on lines +1209 to +1213
G_OBJECT_CLASS(gaflight_server_parent_class)->dispose(object);
}

static void
gaflight_server_finalize(GObject *object)
{
Expand All @@ -1205,6 +1223,24 @@ gaflight_server_finalize(GObject *object)
G_OBJECT_CLASS(gaflight_server_parent_class)->finalize(object);
}

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

switch (prop_id) {
case PROP_OPTIONS:
g_value_set_object(value, priv->options);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}

static void
gaflight_server_init(GAFlightServer *object)
{
Expand All @@ -1216,7 +1252,24 @@ static void
gaflight_server_class_init(GAFlightServerClass *klass)
{
auto gobject_class = G_OBJECT_CLASS(klass);
gobject_class->dispose = gaflight_server_dispose;
gobject_class->finalize = gaflight_server_finalize;
gobject_class->get_property = gaflight_server_get_property;

GParamSpec *spec;
/**
* GAFlightServer:options:
*
* The options used in this server.
*
* Since: 26.0.0
*/
spec = g_param_spec_object("options",
"Options",
"The options used in this server",
GAFLIGHT_TYPE_SERVER_OPTIONS,
static_cast<GParamFlags>(G_PARAM_READABLE));
g_object_class_install_property(gobject_class, PROP_OPTIONS, spec);
}

/**
Expand All @@ -1236,6 +1289,14 @@ gaflight_server_listen(GAFlightServer *server,
{
auto flight_server = gaflight_servable_get_raw(GAFLIGHT_SERVABLE(server));
const auto flight_options = gaflight_server_options_get_raw(options);
auto priv = GAFLIGHT_SERVER_GET_PRIVATE(server);
if (priv->options != options) {
g_object_ref(options);
if (priv->options) {
g_object_unref(priv->options);
}
priv->options = options;
}
return garrow::check(error,
flight_server->Init(*flight_options),
"[flight-server][listen]");
Expand Down
5 changes: 3 additions & 2 deletions c_glib/test/flight/test-client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def setup
@server = nil
omit("Arrow Flight is required") unless defined?(ArrowFlight)
omit("Unstable on Windows") if Gem.win_platform?
omit("Unstable on x86_64 macOS") if /x86_64-darwin/.match?(RUBY_PLATFORM)
omit("Unstable on macOS") if /darwin/.match?(RUBY_PLATFORM)
require_gi_bindings(3, 4, 7)
Comment on lines 23 to 26
Comment on lines 23 to 26
@server = Helper::FlightServer.new
host = "127.0.0.1"
Expand Down Expand Up @@ -80,8 +80,9 @@ def test_success

def test_error
client = ArrowFlight::Client.new(@location)
invalid_data = GLib::Bytes.new("invalid")
assert_raise(Arrow::Error::Invalid) do
client.do_get(ArrowFlight::Ticket.new("invalid"))
client.do_get(ArrowFlight::Ticket.new(invalid_data))
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion c_glib/test/flight/test-criteria.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def setup

def test_expression
expression = "expression"
criteria = ArrowFlight::Criteria.new(expression)
expression_bytes = GLib::Bytes.new(expression)
criteria = ArrowFlight::Criteria.new(expression_bytes)
assert_equal(expression,
Comment on lines 24 to 27
criteria.expression.to_s)
end
Expand Down
12 changes: 8 additions & 4 deletions c_glib/test/flight/test-endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def setup
end

def test_ticket
ticket = ArrowFlight::Ticket.new("data")
data = GLib::Bytes.new("data")
ticket = ArrowFlight::Ticket.new(data)
locations = [
ArrowFlight::Location.new("grpc://127.0.0.1:2929"),
ArrowFlight::Location.new("grpc+tcp://127.0.0.1:12929"),
Expand All @@ -32,7 +33,8 @@ def test_ticket
end

def test_locations
ticket = ArrowFlight::Ticket.new("data")
data = GLib::Bytes.new("data")
ticket = ArrowFlight::Ticket.new(data)
locations = [
ArrowFlight::Location.new("grpc://127.0.0.1:2929"),
ArrowFlight::Location.new("grpc+tcp://127.0.0.1:12929"),
Expand All @@ -44,7 +46,8 @@ def test_locations

sub_test_case("#==") do
def test_true
ticket = ArrowFlight::Ticket.new("data")
data = GLib::Bytes.new("data")
ticket = ArrowFlight::Ticket.new(data)
location = ArrowFlight::Location.new("grpc://127.0.0.1:2929")
endpoint1 = ArrowFlight::Endpoint.new(ticket, [location])
endpoint2 = ArrowFlight::Endpoint.new(ticket, [location])
Expand All @@ -54,7 +57,8 @@ def test_true
end

def test_false
ticket = ArrowFlight::Ticket.new("data")
data = GLib::Bytes.new("data")
ticket = ArrowFlight::Ticket.new(data)
location1 = ArrowFlight::Location.new("grpc://127.0.0.1:2929")
location2 = ArrowFlight::Location.new("grpc://127.0.0.1:1129")
endpoint1 = ArrowFlight::Endpoint.new(ticket, [location1])
Expand Down
15 changes: 10 additions & 5 deletions c_glib/test/flight/test-ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,28 @@ def setup

def test_data
data = "data"
ticket = ArrowFlight::Ticket.new(data)
data_bytes = GLib::Bytes.new(data)
ticket = ArrowFlight::Ticket.new(data_bytes)
assert_equal(data,
Comment on lines 24 to 27
ticket.data.to_s)
end
Comment on lines 23 to 29

sub_test_case("#==") do
def test_true
ticket1 = ArrowFlight::Ticket.new("data")
ticket2 = ArrowFlight::Ticket.new("data")
data1 = GLib::Bytes.new("data")
data2 = GLib::Bytes.new("data")
ticket1 = ArrowFlight::Ticket.new(data1)
ticket2 = ArrowFlight::Ticket.new(data2)
assert do
ticket1 == ticket2
end
end

def test_false
ticket1 = ArrowFlight::Ticket.new("data1")
ticket2 = ArrowFlight::Ticket.new("data2")
data1 = GLib::Bytes.new("data1")
data2 = GLib::Bytes.new("data2")
ticket1 = ArrowFlight::Ticket.new(data1)
ticket2 = ArrowFlight::Ticket.new(data2)
assert do
not (ticket1 == ticket2)
end
Expand Down
6 changes: 5 additions & 1 deletion ci/scripts/c_glib_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ fi

pushd "${source_dir}"

ruby test/run-test.rb
run_test_args=()
if [ -n "${RUNNER_DEBUG}" ]; then
run_test_args+=(-v)
fi
ruby test/run-test.rb "${run_test_args[@]}"

if [[ "$(uname -s)" == "Linux" ]]; then
# TODO(kszucs): on osx it fails to load 'lgi.corelgilua51' despite that lgi
Expand Down
4 changes: 3 additions & 1 deletion ruby/red-arrow-cuda/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ task :test do
cd("dependency-check") do
ruby("-S", "rake")
end
ruby("test/run-test.rb")
args = []
args << "-v" if ENV["RUNNER_DEBUG"]
ruby("test/run-test.rb", *args)
end
end

Expand Down
4 changes: 3 additions & 1 deletion ruby/red-arrow-dataset/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ task :test do
cd("dependency-check") do
ruby("-S", "rake")
end
ruby("test/run-test.rb")
args = []
args << "-v" if ENV["RUNNER_DEBUG"]
ruby("test/run-test.rb", *args)
end
end

Expand Down
4 changes: 3 additions & 1 deletion ruby/red-arrow-flight-sql/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ task :test do
cd("dependency-check") do
ruby("-S", "rake")
end
ruby("test/run-test.rb")
args = []
args << "-v" if ENV["RUNNER_DEBUG"]
ruby("test/run-test.rb", *args)
end
end

Expand Down
2 changes: 1 addition & 1 deletion ruby/red-arrow-flight-sql/test/test-client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TestClient < Test::Unit::TestCase
def setup
@server = nil
omit("Unstable on Windows") if Gem.win_platform?
omit("Unstable on x86_64 macOS") if /x86_64-darwin/.match?(RUBY_PLATFORM)
omit("Unstable on macOS") if /darwin/.match?(RUBY_PLATFORM)
@server = Helper::Server.new
@server.listen("grpc://127.0.0.1:0")
@location = "grpc://127.0.0.1:#{@server.port}"
Expand Down
4 changes: 3 additions & 1 deletion ruby/red-arrow-flight/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ task :test do
cd("dependency-check") do
ruby("-S", "rake")
end
ruby("test/run-test.rb")
args = []
args << "-v" if ENV["RUNNER_DEBUG"]
ruby("test/run-test.rb", *args)
end
end

Expand Down
39 changes: 39 additions & 0 deletions ruby/red-arrow-flight/lib/arrow-flight/criteria.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

module ArrowFlight
class Criteria
class << self
def try_convert(value)
case value
when String, GLib::Bytes
new(value)
else
nil
end
end
end

alias_method :initialize_raw, :initialize
private :initialize_raw
def initialize(expression)
expression = GLib::Bytes.new(expression) if expression.is_a?(String)
initialize_raw(expression)
@expression = expression
end
end
Comment on lines +18 to +38
end
1 change: 1 addition & 0 deletions ruby/red-arrow-flight/lib/arrow-flight/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def require_libraries
require "arrow-flight/call-options"
require "arrow-flight/client"
require "arrow-flight/client-options"
require "arrow-flight/criteria"
require "arrow-flight/location"
require "arrow-flight/record-batch-reader"
require "arrow-flight/server-call-context"
Expand Down
8 changes: 8 additions & 0 deletions ruby/red-arrow-flight/lib/arrow-flight/ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,13 @@ def try_convert(value)
end
end
end

alias_method :initialize_raw, :initialize
private :initialize_raw
def initialize(data)
data = GLib::Bytes.new(data) if data.is_a?(String)
initialize_raw(data)
@data = data
end
end
end
27 changes: 27 additions & 0 deletions ruby/red-arrow-flight/test/test-criteria.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

class TestCriteria < Test::Unit::TestCase
sub_test_case(".try_convert") do
def test_string
expression = "expression"
criteria = ArrowFlight::Criteria.try_convert(expression)
assert_equal(expression,
criteria.expression.to_s)
end
end
end
1 change: 1 addition & 0 deletions ruby/red-arrow-flight/test/test-record-batch-reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TestRecordBatchReader < Test::Unit::TestCase
def setup
@server = nil
omit("Unstable on Windows") if Gem.win_platform?
omit("Unstable on macOS") if /darwin/.match?(RUBY_PLATFORM)
@server = Helper::Server.new
@server.listen("grpc://127.0.0.1:0")
@location = "grpc://127.0.0.1:#{@server.port}"
Expand Down
4 changes: 3 additions & 1 deletion ruby/red-arrow-format/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ task default: :test
desc "Run tests"
task :test do
cd(base_dir.to_s) do
ruby("test/run.rb")
args = []
args << "-v" if ENV["RUNNER_DEBUG"]
ruby("test/run.rb", *args)
end
end

Expand Down
4 changes: 3 additions & 1 deletion ruby/red-arrow/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ end
desc "Run tests"
task :test do
cd(base_dir) do
ruby("test/run-test.rb")
args = []
args << "-v" if ENV["RUNNER_DEBUG"]
ruby("test/run-test.rb", *args)
end
end

Expand Down
Loading
Loading