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

MAINT: StringPrepper use Event model #753

Conversation

chenqi0805
Copy link
Collaborator

Signed-off-by: Chen [email protected]

Description

This PR migrates StringPrepper to use Event model.

Issues Resolved

Resolves #608

Check List

  • New functionality includes testing.
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@chenqi0805 chenqi0805 requested a review from a team as a code owner December 16, 2021 16:27
final Collection<Record<Event>> modifiedRecords = new ArrayList<>(records.size());
for (Record<Event> record : records) {
final Event recordEvent = record.getData();
final String recordData = recordEvent.toJsonString();
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is the correct approach. This will capitalize keys as well, which is incorrect.

I'd think the closest feature parity here is to iterate over every key. For each string-value, make it uppercase.

This processor should probably be obsoleted and replaced with the one being created for #697. But, that is a breaking change and we still need something in 1.3.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd think the closest feature parity here is to iterate over every key. For each string-value, make it uppercase.

I agree this might make more sense. Yeah, the Prepper itself is a bit outdated.

Copy link
Member

Choose a reason for hiding this comment

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

There seems to be some overlap between the mutate processor and the string_converter proposed here. I think separating out between string mutations and generic mutations makes some sense, but it is possible that doing so could lead to a worse user experience as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IMO, for the long term, we need to check how much overlap there is between #697 and #508. This Prepper will be transient.

Copy link
Member

Choose a reason for hiding this comment

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

I added a comment in #508. We should discuss in that issue how granular we want these different plugins to be. Please read and comment.

@chenqi0805 chenqi0805 requested a review from dlvenable December 16, 2021 20:58
Signed-off-by: Chen <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Dec 16, 2021

Codecov Report

Merging #753 (95d7047) into main (2d71354) will decrease coverage by 0.02%.
The diff coverage is 82.60%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #753      +/-   ##
============================================
- Coverage     91.59%   91.56%   -0.03%     
- Complexity      624      630       +6     
============================================
  Files            75       75              
  Lines          1844     1862      +18     
  Branches        158      159       +1     
============================================
+ Hits           1689     1705      +16     
- Misses          117      120       +3     
+ Partials         38       37       -1     
Impacted Files Coverage Δ
...zon/dataprepper/plugins/prepper/StringPrepper.java 88.88% <82.60%> (-11.12%) ⬇️
...com/amazon/dataprepper/pipeline/ProcessWorker.java 91.42% <0.00%> (+5.71%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2d71354...95d7047. Read the comment docs.

}
return modifiedRecords;
}

private Map<String, Object> processEventJson(final String data) throws JsonProcessingException {
Copy link
Member

Choose a reason for hiding this comment

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

We probably need some new features in Event if this is the necessary approach! But, this is fine for this processor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree. Did not find an API to iterate through the keys in Event data, neither the Event::toMap() method.

@chenqi0805 chenqi0805 merged commit 1ba7711 into opensearch-project:main Dec 16, 2021
@chenqi0805 chenqi0805 deleted the maint/608-string-prepper-use-event-model branch December 16, 2021 21:45
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.

StringPrepper to use Event model
4 participants