This is an automated email from the ASF dual-hosted git repository.
shiro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new f05f647 ARROW-5943: [GLib][Gandiva] Add support for function aliases
f05f647 is described below
commit f05f6474c8736dde342ccfe716c11182fecbf773
Author: Sutou Kouhei <[email protected]>
AuthorDate: Mon Jul 15 10:07:45 2019 +0900
ARROW-5943: [GLib][Gandiva] Add support for function aliases
This is follow-up for ARROW-5892: https://github.com/apache/arrow/pull/4835
Author: Sutou Kouhei <[email protected]>
Closes #4874 from kou/glib-gandiva-function-aliases and squashes the
following commits:
306d06450 <Sutou Kouhei> Add symbol list for 1.0.0
5f173d646 <Sutou Kouhei> Add support for function aliases
---
c_glib/doc/gandiva-glib/gandiva-glib-docs.xml | 4 ++
c_glib/gandiva-glib/native-function.cpp | 58 +++++++++++----------------
c_glib/gandiva-glib/native-function.h | 3 +-
c_glib/test/gandiva/test-function-registry.rb | 2 +-
c_glib/test/gandiva/test-native-function.rb | 15 ++++---
c_glib/test/helper/data-type.rb | 4 ++
6 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/c_glib/doc/gandiva-glib/gandiva-glib-docs.xml
b/c_glib/doc/gandiva-glib/gandiva-glib-docs.xml
index 81bbb08..ac9f686 100644
--- a/c_glib/doc/gandiva-glib/gandiva-glib-docs.xml
+++ b/c_glib/doc/gandiva-glib/gandiva-glib-docs.xml
@@ -84,6 +84,10 @@
<title>Index of deprecated API</title>
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback
/></xi:include>
</index>
+ <index id="api-index-1-0-0" role="1.0.0">
+ <title>Index of new symbols in 1.0.0</title>
+ <xi:include href="xml/api-index-1.0.0.xml"><xi:fallback /></xi:include>
+ </index>
<index id="api-index-0-14-0" role="0.14.0">
<title>Index of new symbols in 0.14.0</title>
<xi:include href="xml/api-index-0.14.0.xml"><xi:fallback /></xi:include>
diff --git a/c_glib/gandiva-glib/native-function.cpp
b/c_glib/gandiva-glib/native-function.cpp
index f2f15ac..5ff265f 100644
--- a/c_glib/gandiva-glib/native-function.cpp
+++ b/c_glib/gandiva-glib/native-function.cpp
@@ -93,46 +93,25 @@
ggandiva_native_function_class_init(GGandivaNativeFunctionClass *klass)
}
/**
- * ggandiva_native_function_get_signature:
+ * ggandiva_native_function_get_signatures:
* @native_function: A #GGandivaNativeFunction.
*
- * Returns: (transfer full): A #GGandivaFunctionSignature that represents
- * the signature of the native function.
+ * Returns: (element-type GGandivaFunctionSignature) (transfer full):
+ * A list of #GGandivaFunctionSignature supported by the native function.
*
- * Since: 0.14.0
- */
-GGandivaFunctionSignature *
-ggandiva_native_function_get_signature(GGandivaNativeFunction *native_function)
-{
- auto gandiva_native_function =
- ggandiva_native_function_get_raw(native_function);
- auto &gandiva_function_signature =
gandiva_native_function->signatures().front();
- return ggandiva_function_signature_new_raw(&gandiva_function_signature);
-}
-
-/**
- * ggandiva_native_function_get_all_signatures:
- * @native_function: A #GGandivaNativeFunction.
- *
- * Returns: (transfer full): A List of #GGandivaFunctionSignature supported by
- * the native function.
- *
- * Since: ??
+ * Since: 1.0.0
*/
GList *
-ggandiva_native_function_get_all_signatures(GGandivaNativeFunction
*native_function)
+ggandiva_native_function_get_signatures(GGandivaNativeFunction
*native_function)
{
auto gandiva_native_function =
- ggandiva_native_function_get_raw(native_function);
-
- GList *function_signatures = nullptr;
- for (auto& function_sig_raw : gandiva_native_function->signatures()) {
- auto function_sig = ggandiva_function_signature_new_raw(&function_sig_raw);
- function_signatures = g_list_prepend(function_signatures, function_sig);
+ ggandiva_native_function_get_raw(native_function);
+ GList *signatures = nullptr;
+ for (auto &gandiva_signature : gandiva_native_function->signatures()) {
+ auto signature = ggandiva_function_signature_new_raw(&gandiva_signature);
+ signatures = g_list_prepend(signatures, signature);
}
- function_signatures = g_list_reverse(function_signatures);
-
- return function_signatures;
+ return g_list_reverse(signatures);
}
/**
@@ -160,7 +139,7 @@ ggandiva_native_function_equal(GGandivaNativeFunction
*native_function,
* @native_function: A #GGandivaNativeFunction.
*
* Returns: (transfer full):
- * The string representation of the signature of the native function.
+ * The string representation of the signatures of the native function.
* It should be freed with g_free() when no longer needed.
*
* Since: 0.14.0
@@ -170,8 +149,17 @@ ggandiva_native_function_to_string(GGandivaNativeFunction
*native_function)
{
auto gandiva_native_function =
ggandiva_native_function_get_raw(native_function);
- auto gandiva_function_signature =
gandiva_native_function->signatures().front();
- return g_strdup(gandiva_function_signature.ToString().c_str());
+ auto string = g_string_new(NULL);
+ for (auto &gandiva_signature : gandiva_native_function->signatures()) {
+ if (string->len > 0) {
+ g_string_append(string, ", ");
+ }
+ const auto &signature_string = gandiva_signature.ToString();
+ g_string_append_len(string,
+ signature_string.data(),
+ signature_string.length());
+ }
+ return g_string_free(string, FALSE);
}
/**
diff --git a/c_glib/gandiva-glib/native-function.h
b/c_glib/gandiva-glib/native-function.h
index a7ffb60..8b4d6a4 100644
--- a/c_glib/gandiva-glib/native-function.h
+++ b/c_glib/gandiva-glib/native-function.h
@@ -51,7 +51,8 @@ struct _GGandivaNativeFunctionClass
GObjectClass parent_class;
};
-GGandivaFunctionSignature
*ggandiva_native_function_get_signature(GGandivaNativeFunction
*native_function);
+GList *
+ggandiva_native_function_get_signatures(GGandivaNativeFunction
*native_function);
gboolean
ggandiva_native_function_equal(GGandivaNativeFunction *native_function,
GGandivaNativeFunction *other_native_function);
diff --git a/c_glib/test/gandiva/test-function-registry.rb
b/c_glib/test/gandiva/test-function-registry.rb
index 85b0307..25bac66 100644
--- a/c_glib/test/gandiva/test-function-registry.rb
+++ b/c_glib/test/gandiva/test-function-registry.rb
@@ -27,7 +27,7 @@ class TestGandivaFunctionRegistry < Test::Unit::TestCase
def test_found
native_function = @registry.native_functions[0]
assert_equal(native_function,
- @registry.lookup(native_function.signature))
+ @registry.lookup(native_function.signatures[0]))
end
def test_not_found
diff --git a/c_glib/test/gandiva/test-native-function.rb
b/c_glib/test/gandiva/test-native-function.rb
index f2546da..7888f96 100644
--- a/c_glib/test/gandiva/test-native-function.rb
+++ b/c_glib/test/gandiva/test-native-function.rb
@@ -32,15 +32,15 @@ class TestGandivaNativeFunction < Test::Unit::TestCase
@registry.lookup(signature)
end
- def test_get_signature
- assert_kind_of(Gandiva::FunctionSignature,
- @not.signature)
+ def test_signatures
+ assert_equal([Gandiva::FunctionSignature],
+ @not.signatures.collect(&:class).uniq)
end
sub_test_case("equal") do
def test_true
assert do
- @not == @registry.lookup(@not.signature)
+ @not == @registry.lookup(@not.signatures[0])
end
end
@@ -52,8 +52,11 @@ class TestGandivaNativeFunction < Test::Unit::TestCase
end
def test_to_string
- assert_equal(@not.signature.to_s,
- @not.to_s)
+ modulo = lookup("modulo",
+ [int64_data_type, int64_data_type],
+ int64_data_type)
+ assert_equal(modulo.signatures.collect(&:to_s).join(", "),
+ modulo.to_s)
end
sub_test_case("get_result_nullbale_type") do
diff --git a/c_glib/test/helper/data-type.rb b/c_glib/test/helper/data-type.rb
index 5716f7e..b822440 100644
--- a/c_glib/test/helper/data-type.rb
+++ b/c_glib/test/helper/data-type.rb
@@ -48,6 +48,10 @@ module Helper
Arrow::Int32DataType.new
end
+ def int64_data_type
+ Arrow::Int64DataType.new
+ end
+
def string_data_type
Arrow::StringDataType.new
end