Skip to content
Closed
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
4 changes: 4 additions & 0 deletions c_glib/doc/gandiva-glib/gandiva-glib-docs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
58 changes: 23 additions & 35 deletions c_glib/gandiva-glib/native-function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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
Expand All @@ -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);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion c_glib/gandiva-glib/native-function.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we add GARROW_AVAILABLE_IN_1_0 in another pull request after #4841 is merged?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

gboolean
ggandiva_native_function_equal(GGandivaNativeFunction *native_function,
GGandivaNativeFunction *other_native_function);
Expand Down
2 changes: 1 addition & 1 deletion c_glib/test/gandiva/test-function-registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def setup
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
Expand Down
15 changes: 9 additions & 6 deletions c_glib/test/gandiva/test-native-function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def lookup(name, param_types, return_type)
@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

Expand All @@ -52,8 +52,11 @@ def test_false
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
Expand Down
4 changes: 4 additions & 0 deletions c_glib/test/helper/data-type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def int32_data_type
Arrow::Int32DataType.new
end

def int64_data_type
Arrow::Int64DataType.new
end

def string_data_type
Arrow::StringDataType.new
end
Expand Down