Skip to content

Conversation

brbrown25
Copy link

@brbrown25 brbrown25 commented May 12, 2020

Addresses #9

…ed hashing algorithm to transform the targeted value. ISSUE-9.
@nick-zh
Copy link

nick-zh commented May 14, 2020

@brbrown25 thank you 👍
@ivanyu

@ivanyu ivanyu self-assigned this May 14, 2020

static final String hashString(final String hashAlg, final String input) {
try {
final MessageDigest md = MessageDigest.getInstance(hashAlg);
Copy link
Collaborator

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.

Copy link
Author

@brbrown25 brbrown25 May 14, 2020

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

@ivanyu
Copy link
Collaborator

ivanyu commented May 14, 2020

Thanks for your contribution @brbrown25. I'll go through it soon

@brbrown25
Copy link
Author

Thanks @ivanyu I based it off the topic replacement transformer for consistency and can tweak as needed. Thanks for the opportunity!

Copy link
Collaborator

@ivanyu ivanyu left a 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,
Copy link
Collaborator

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

Copy link
Author

@brbrown25 brbrown25 May 14, 2020

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() {
Copy link
Collaborator

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.

Copy link
Author

@brbrown25 brbrown25 May 14, 2020

Choose a reason for hiding this comment

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

  • return HashFunction here

@ivanyu
Copy link
Collaborator

ivanyu commented May 14, 2020

Would you consider adding skip.missing.or.null configuration? Might be a good protection from incomplete values.
An example:
https://github.com/aiven/aiven-kafka-connect-transforms/blob/master/src/main/java/io/aiven/kafka/connect/transforms/ExtractTopicConfig.java#L31

@brbrown25
Copy link
Author

brbrown25 commented May 14, 2020

Would you consider adding skip.missing.or.null configuration? Might be a good protection from incomplete values.
An example:
https://github.com/aiven/aiven-kafka-connect-transforms/blob/master/src/main/java/io/aiven/kafka/connect/transforms/ExtractTopicConfig.java#L31

Yeah I wasn't sure if that was a desired setting or not, I think it makes sense to add it.

  • add in skip.missing.or.null

@brbrown25
Copy link
Author

@ivanyu addressed all of the pr feedback, let me know what other changes you'd like and collapse this into a single commit.

@ivanyu ivanyu changed the title feat(HashField): Adding a HashField transformer that can use a suppli… Adding HashField transformer May 18, 2020
@ivanyu
Copy link
Collaborator

ivanyu commented May 18, 2020

Merging, thanks @brbrown25
I'll made some cosmetic changes, update README, and release soon.

@ivanyu ivanyu merged commit 1b7ebd6 into Aiven-Open:master May 18, 2020
@nick-zh
Copy link

nick-zh commented May 18, 2020

@brbrown25 @ivanyu thank you both very much 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants