-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-5892 : [C++][Gandiva] Support function aliases #4835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
praveenbingo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also add a test from gandiva java..
| auto gandiva_native_function = | ||
| ggandiva_native_function_get_raw(native_function); | ||
| auto gandiva_function_signature = gandiva_native_function->signature(); | ||
| auto gandiva_function_signature = gandiva_native_function->signatures().back(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wont they missing the aliases now if we do this..
| class GANDIVA_EXPORT ExpressionRegistry { | ||
| public: | ||
| using iterator = const NativeFunction*; | ||
| using nf_iterator = const NativeFunction*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better names please..its hard to follow otherwise..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed nf_iterator to native_func_iterator_type and fs_iterator to func_sig_iterator_type.
thanks for reviewing
Codecov Report
@@ Coverage Diff @@
## master #4835 +/- ##
==========================================
+ Coverage 87.43% 89.08% +1.65%
==========================================
Files 997 720 -277
Lines 139841 100216 -39625
Branches 1418 0 -1418
==========================================
- Hits 122273 89282 -32991
+ Misses 17206 10934 -6272
+ Partials 362 0 -362
Continue to review full report at Codecov.
|
cpp/src/gandiva/native_function.h
Outdated
| result_nullable_type_(result_nullable_type), | ||
| pc_name_(pc_name) {} | ||
| pc_name_(pc_name) { | ||
| aliases.insert(aliases.begin(), base_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't modify this, instead, make aliases a const-ref, and call signatures_.push_back(Func..(base_name, ...)) before the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. thanks for reviewing.
| const NativeFunction* function = registry_.LookupSignature(add_i32_i32); | ||
| EXPECT_NE(function, nullptr); | ||
| EXPECT_EQ(function->signature(), add_i32_i32); | ||
| EXPECT_TRUE(std::find(function->signatures().begin(), function->signatures().end(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should do the trick EXPECT_THAT(add_i32_i32, In(function->signatures()).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using Contains matcher from gmock. couldn't find In.
|
I'll push a commit for GLib related part to this branch in a few days. |
| NativeFunction(#NAME, DataTypeVector{TYPE(), TYPE()}, TYPE(), kResultNullIfNull, \ | ||
| ARROW_STRINGIFY(NAME##_##TYPE##_##TYPE)) | ||
| #define BINARY_SYMMETRIC_SAFE_NULL_IF_NULL(NAME, ALIASES, TYPE) \ | ||
| NativeFunction(#NAME, ALIASES, DataTypeVector{TYPE(), TYPE()}, TYPE(), \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Macros which take initializer_lists are tricky because the lack of a paren means that an initializer_list with more than one element is considered two tokens. For example:
#define VECTOR(T, elements) ::std::vector<T>(elements)
VECTOR(int, {1, 2, 3}); // error: the macro's arguments are "int", " {1", " 2", " 3}"If you add the container type explicitly then it should work to just enclose the initializer_list in parens:
| NativeFunction(#NAME, ALIASES, DataTypeVector{TYPE(), TYPE()}, TYPE(), \ | |
| NativeFunction(#NAME, | |
| std::vector<std::string> ALIASES, DataTypeVector{TYPE(), TYPE()}, TYPE(), \ |
Please add a function with at least two aliases (in a test would be acceptable) to demonstrate how the macro can be used with plural aliases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed. Thanks for reviewing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify: you don't need to wrap all initializer lists in parentheses, just those with more than a single element
Access precompiled functions with different names. Author: Prudhvi Porandla <prudhvi.porandla@icloud.com> Author: pprudhvi <30983614+pprudhvi@users.noreply.github.com> Closes apache#4835 from pprudhvi/func-aliases and squashes the following commits: 39bc74f <Prudhvi Porandla> enclose in parens only when required a5ad80e <Prudhvi Porandla> lint 8eb9cc1 <Prudhvi Porandla> do not pass initializer list through macros directly 430b97f <Prudhvi Porandla> refactor: make aliases const-ref, use gmock matcher 727bbd0 <pprudhvi> Merge branch 'master' into func-aliases 0610288 <Prudhvi Porandla> add base name at front. add get_all_signatures method in glib 0376231 <Prudhvi Porandla> add java test, rename iterator pointer names e0d02b1 <Prudhvi Porandla> use nullptr instead of NULLPTR 3540703 <Prudhvi Porandla> use native funciton's last func signature in glib ee2ef21 <Prudhvi Porandla> refactor: descriptive member names in func_registry 61c29a2 <Prudhvi Porandla> add aliases to truncate, divide, mod 090b6a7 <Prudhvi Porandla> support function aliases
This is follow-up for ARROW-5892: apache#4835
This is follow-up for ARROW-5892: #4835 Author: Sutou Kouhei <kou@clear-code.com> Closes #4874 from kou/glib-gandiva-function-aliases and squashes the following commits: 306d064 <Sutou Kouhei> Add symbol list for 1.0.0 5f173d6 <Sutou Kouhei> Add support for function aliases
Access precompiled functions with different names. Author: Prudhvi Porandla <prudhvi.porandla@icloud.com> Author: pprudhvi <30983614+pprudhvi@users.noreply.github.com> Closes #4835 from pprudhvi/func-aliases and squashes the following commits: 39bc74f <Prudhvi Porandla> enclose in parens only when required a5ad80e <Prudhvi Porandla> lint 8eb9cc1 <Prudhvi Porandla> do not pass initializer list through macros directly 430b97f <Prudhvi Porandla> refactor: make aliases const-ref, use gmock matcher 727bbd0 <pprudhvi> Merge branch 'master' into func-aliases 0610288 <Prudhvi Porandla> add base name at front. add get_all_signatures method in glib 0376231 <Prudhvi Porandla> add java test, rename iterator pointer names e0d02b1 <Prudhvi Porandla> use nullptr instead of NULLPTR 3540703 <Prudhvi Porandla> use native funciton's last func signature in glib ee2ef21 <Prudhvi Porandla> refactor: descriptive member names in func_registry 61c29a2 <Prudhvi Porandla> add aliases to truncate, divide, mod 090b6a7 <Prudhvi Porandla> support function aliases
This is follow-up for ARROW-5892: #4835 Author: Sutou Kouhei <kou@clear-code.com> Closes #4874 from kou/glib-gandiva-function-aliases and squashes the following commits: 306d064 <Sutou Kouhei> Add symbol list for 1.0.0 5f173d6 <Sutou Kouhei> Add support for function aliases
Access precompiled functions with different names. Author: Prudhvi Porandla <prudhvi.porandla@icloud.com> Author: pprudhvi <30983614+pprudhvi@users.noreply.github.com> Closes apache#4835 from pprudhvi/func-aliases and squashes the following commits: 39bc74f <Prudhvi Porandla> enclose in parens only when required a5ad80e <Prudhvi Porandla> lint 8eb9cc1 <Prudhvi Porandla> do not pass initializer list through macros directly 430b97f <Prudhvi Porandla> refactor: make aliases const-ref, use gmock matcher 727bbd0 <pprudhvi> Merge branch 'master' into func-aliases 0610288 <Prudhvi Porandla> add base name at front. add get_all_signatures method in glib 0376231 <Prudhvi Porandla> add java test, rename iterator pointer names e0d02b1 <Prudhvi Porandla> use nullptr instead of NULLPTR 3540703 <Prudhvi Porandla> use native funciton's last func signature in glib ee2ef21 <Prudhvi Porandla> refactor: descriptive member names in func_registry 61c29a2 <Prudhvi Porandla> add aliases to truncate, divide, mod 090b6a7 <Prudhvi Porandla> support function aliases
Access precompiled functions with different names.