-
Notifications
You must be signed in to change notification settings - Fork 27
Adding HashField transformer #12
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
…ed hashing algorithm to transform the targeted value. ISSUE-9.
2a81075
to
d8aa4cb
Compare
@brbrown25 thank you 👍 |
|
||
static final String hashString(final String hashAlg, final String input) { | ||
try { | ||
final MessageDigest md = MessageDigest.getInstance(hashAlg); |
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.
Could you please initialize this somewhere in configure
? MessageDigest.getInstance
might be costly enough to not want to call it on each message.
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 that’s a good call out I’ll make that change.
- initialize in the configure to be more efficient
Thanks for your contribution @brbrown25. I'll go through it soon |
Thanks @ivanyu I based it off the topic replacement transformer for consistency and can tweak as needed. Thanks for the opportunity! |
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.
Some notes on function
configuration
.define( | ||
FUNCTION_CONFIG, | ||
ConfigDef.Type.STRING, | ||
null, |
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 think it should be ConfigDef.NO_DEFAULT_VALUE
here, since we don't want to have null
as the function 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.
- switch to
ConfigDef.NO_DEFAULT_VALUE
return Optional.of(rawFieldName); | ||
} | ||
|
||
Optional<String> hashFunction() { |
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.
The empty string is excluded by the validator, null
we can also exclude. Thus, Optional
won't be needed.
And since the set of possible values is limited, HashFunction
could be returned from here.
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.
- return HashFunction here
src/main/java/io/aiven/kafka/connect/transforms/HashFieldConfig.java
Outdated
Show resolved
Hide resolved
Would you consider adding |
Yeah I wasn't sure if that was a desired setting or not, I think it makes sense to add it.
|
@ivanyu addressed all of the pr feedback, let me know what other changes you'd like and collapse this into a single commit. |
Merging, thanks @brbrown25 |
@brbrown25 @ivanyu thank you both very much 👍 |
Addresses #9