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
Conversation
00ffa48
to
4dddeab
Compare
@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(); |
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 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(); |
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.
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(); |
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.
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(); |
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.
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(); |
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.
Again, no need to check instanceof here - can just call toString()
Thanks @markap14 I'll fix these and push a new version. |
@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. |
@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. |
4dddeab
to
5ea6b35
Compare
Ok, code review notes should all be addressed now. |
5ea6b35
to
a58bf5c
Compare
a58bf5c
to
caa1bc1
Compare
@markap14 Have you had a chance to think more this? FWIW, it doesn't seem to break any of the unit tests. |
@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 :) |
…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:
For documentation related changes:
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.