Skip to content
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

MINIFICPP-14: Prune class names. Add option to config #643

Merged
merged 2 commits into from Sep 9, 2019

Conversation

phrocker
Copy link
Contributor

@phrocker phrocker commented Sep 6, 2019

Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically master)?

  • Is your initial contribution a single, squashed commit?

For code changes:

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file?
  • If applicable, have you updated the NOTICE file?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.

@phrocker
Copy link
Contributor Author

phrocker commented Sep 6, 2019

This is an old PR I created a while ago. I rebased, but should probably go through it myself to clean it up.

Here is the example output

[2019-09-06 16:45:52.582] [o::a::n::m::FlowController] [info] Started Flow Controller

versus

[2019-09-06 16:47:14.379] [org::apache::nifi::minifi::FlowController] [info] Stop Flow Controller

namespace minifi {
namespace utils {

void ClassUtils::shortenClassName(const std::string &class_name, std::string &out) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In case it's void, what's the motivation behind an output parameter, why not just return it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are several pros and cons but following suit for some of the other API calls I should have returned true/false if shortening occurred. I like the idea of using output variables and since I'm already following other API utils classes I'll make that change. Thanks!

* @param class_name input class name
* @param out output class name that is shortened.
*/
extern void shortenClassName(const std::string &class_name, std::string &out);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need extern here? Libminifi build should be wholearchive anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out! It's not needed as is superfluous in header files.

It was copied from the original location ( the source file ), in which case the use of wholarchive didn't help locate during the linking phase -- but when rebasing this PR I moved this to the header, at which point it's actually already externalized across translation units.

namespace nifi {
namespace minifi {
namespace utils {
namespace ClassUtils {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is cool to have, I like it!
I also think some of the tempalte functions we already have (getClassName<T> and getClassNames<T>) could also be moved to here from classloader.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. made a follow on.

// if no update can be performed, return false to let the developer know
// this. Out will have no updates
return false;
}
}
for (auto &elem : class_split) {
if (&elem != &class_split.back() && elem.size() > 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Tricky :)

Copy link
Contributor

@arpadboda arpadboda left a comment

Choose a reason for hiding this comment

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

LGTM

@phrocker phrocker merged commit ad917bb into apache:master Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants