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

NIFI-4644 Fixed LookupService API to allow for more than String/Strin… #2304

Closed
wants to merge 1 commit into from

Conversation

MikeThomsen
Copy link
Contributor

@MikeThomsen MikeThomsen commented Nov 28, 2017

…g lookup pairs.

Thank you for submitting a contribution to Apache NiFi.

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 NIFI-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:

  • Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
  • Have you written or updated unit tests to verify your 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, including the main LICENSE file under nifi-assembly?
  • If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
  • If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?

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.

@MikeThomsen
Copy link
Contributor Author

@m-hogue I think on the mailing list it said you did a lot of work on the Record API. Do you think you could take a look at this? It's an API change that was necessitated by the String,String limitation.

return Optional.empty();
}

final String rowKey = coordinates.get(ROW_KEY_KEY) instanceof String ? (String)coordinates.get(ROW_KEY_KEY) : coordinates.get(ROW_KEY_KEY).toString();
Copy link
Contributor

@markap14 markap14 Nov 29, 2017

Choose a reason for hiding this comment

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

I don't think we need to be checking any instanceof here -- just call coordinates.get(ROW_KEY_KEY).toString() -- if it is a String, then toString() will simply return 'this'.

if (coordinates == null) {
return Optional.empty();
}

final String key = coordinates.get(KEY);
final String key = coordinates.get(KEY) instanceof String ? (String)coordinates.get(KEY) : coordinates.get(KEY).toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, no need to check instanceof here - can just call toString()

if (coordinates == null) {
return Optional.empty();
}

final String key = coordinates.get(KEY);
final String key = coordinates.get(KEY) instanceof String ? (String)coordinates.get(KEY) : coordinates.get(KEY).toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, no need to check instanceof here - can just call toString()

if (coordinates == null) {
return Optional.empty();
}

final String key = coordinates.get(KEY);
final String key = coordinates.get(KEY) instanceof String ? (String)coordinates.get(KEY) : coordinates.get(KEY).toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, no need to check instanceof here - can just call toString()

private Optional<Record> doLookup(final DatabaseReader databaseReader, final Map<String, String> coordinates) throws LookupFailureException, InvalidDatabaseException {
final String ipAddress = coordinates.get(IP_KEY);
private Optional<Record> doLookup(final DatabaseReader databaseReader, final Map<String, Object> coordinates) throws LookupFailureException, InvalidDatabaseException {
final String ipAddress = coordinates.get(IP_KEY) instanceof String ? (String)coordinates.get(IP_KEY) : coordinates.get(IP_KEY).toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, no need to check instanceof here - can just call toString()

@MikeThomsen
Copy link
Contributor Author

Thanks @markap14 I'll fix these and push a new version.

@markap14
Copy link
Contributor

@MikeThomsen I am just a bit concerned about potential implications of this change... at first glance I don't see any particular problem with it, but I feel like there may be a condition that I am overlooking... It is probably okay, but I would like to think about this just a bit more.

@MikeThomsen
Copy link
Contributor Author

@markap14 That's fine. I posted on the mailing list that someone already found a real case where it broke their flow because it converted an integer to a string and MongoDB couldn't do the lookup. The ticket reference for that particular problem is in there if you want to take a look.

@MikeThomsen
Copy link
Contributor Author

Ok, code review notes should all be addressed now.

@MikeThomsen
Copy link
Contributor Author

@markap14 Have you had a chance to think more this? FWIW, it doesn't seem to break any of the unit tests.

@markap14
Copy link
Contributor

@MikeThomsen thanks for the 'bump'. I did think about it quite a bit and decided that all does appear to be okay. But to be honest, I had forgotten to merge. Sorry about that! Did some verifications manually just now and am happy with all that I'm seeing, using LookupRecord with the IP Enrichment lookup service and the SimpleKeyValueLookup Service. Thanks for the update and for hanging in there, even when I dropped the ball on the review :)

@asfgit asfgit closed this in d7347a2 Dec 13, 2017
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