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
Refactor .extend()
and .remove()
to use FExpr
#3393
Conversation
src/core/expr/fexpr_extend_remove.h
Outdated
private: | ||
ptrExpr arg_; | ||
ptrExpr values_; | ||
bool extend_; |
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.
Instead of a class attribute, we should use a template parameter bool EXTEND
like we just did for SUM
. This way compiler will create two classes: one for EXTEND == true
and another for EXTEND == false
, streamlining all the if (EXTEND) ...
conditions within those classes.
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.
@oleksiyskononenko could you kindly have a look at my latest commit. where am I getting it wrong with my knowledge of templates
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.
Sure, the way this template should be implemented is exactly the same as for many other classes we have recently created. Could you please explain me what is the issue you are facing?
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 is the error I am getting:
src/core/expr/fexpr_extend_remove.cc:28:1: error: invalid use of template-name ‘dt::expr::FExpr_Extend_Remove’ without an argument list
28 | FExpr_Extend_Remove::FExpr_Extend_Remove(ptrExpr&& arg, ptrExpr&& other) :
| ^~~~~~~~~~~~~~~~~~~
my google fu hasnt fetched me anything helpful
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.
i basically add the template<bool EXTEND>
to fexpr_extend_remove.h
and fexpr_extend_remove.cc
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.
Since you keep template declarations in the .h
file and all the definitions in .cc
, you need to explicitly specify for which EXTEND
values, i.e. true
and false
, you're creating implementations outside of the header file. Also, definitions of the class methods should all include the template parameter. Take a look at the changes I've just pushed.
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.
Thank you @oleksiyskononenko ... It was hard for me to decipher this solution based on the error message. Thanks agaon
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.
Yeah, error messages for templates are not really helpful. The standard way to implement it is to put everything in the header file. Once you split the declarations/definitions, some issues may arise. If you need more info on this, google for “C++ template instantiation”.
Co-authored-by: oleksiyskononenko <35204136+oleksiyskononenko@users.noreply.github.com>
extend
and remove
.extend()
and .remove()
to use FExpr
@samukweku I pushed some changes to this PR. See if they look good to you. |
Thanks for the review and update @oleksiyskononenko. Looks great |
WIP for #2562