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

Modify transformationPlugins contract to return Object to support One to Many transformations #1206

Conversation

AndreKurait
Copy link
Member

Description

Modify transformationPlugins contract to return Object to support One to Many transformations.

Initial step in plugin framework, applications (RFS, Metadata, Replayer) still need to be updated to support

Issues Resolved

Testing

Check List

  • New functionality includes testing
  • Public documentation issue/PR created, if applicable.

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.

@AndreKurait AndreKurait force-pushed the TransformationPluginObjectContract branch from 86a29fa to 4452d8c Compare December 18, 2024 23:01
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.55%. Comparing base (3d6b0ad) to head (4452d8c).
Report is 3 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1206      +/-   ##
============================================
- Coverage     80.64%   80.55%   -0.09%     
+ Complexity     3076     3075       -1     
============================================
  Files           421      421              
  Lines         15610    15629      +19     
  Branches       1053     1057       +4     
============================================
+ Hits          12588    12590       +2     
- Misses         2381     2394      +13     
- Partials        641      645       +4     
Flag Coverage Δ
unittests 80.55% <ø> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

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

Thanks for the quick turn around

return MAPPER.writeValueAsString(map);
}

@SuppressWarnings("unchecked")
private MigrationItem transformMigrationItem(MigrationItem migrationItem) {
// Keep untouched original for logging
final Map<String, Object> originalMap = MAPPER.convertValue(migrationItem, Map.class);
var transformedMigrationItem = transformer.transformJson(MAPPER.convertValue(migrationItem, Map.class));
Object transformedMigrationItem = transformer.transformJson(MAPPER.convertValue(migrationItem, Map.class));
Copy link
Member

Choose a reason for hiding this comment

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

Could you switch back to var?

Suggested change
Object transformedMigrationItem = transformer.transformJson(MAPPER.convertValue(migrationItem, Map.class));
var transformedMigrationItem = transformer.transformJson(MAPPER.convertValue(migrationItem, Map.class));

@@ -142,7 +142,7 @@ public void accept(SourceTargetCaptureTuple tuple, ParsedHttpMessagesAsDicts par
if (tupleLogger.isInfoEnabled()) {
try {
var originalTuple = toJSONObject(tuple, parsedMessages);
var transformedTuple = tupleTransformer.transformJson(originalTuple);
Object transformedTuple = tupleTransformer.transformJson(originalTuple);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Object transformedTuple = tupleTransformer.transformJson(originalTuple);
var transformedTuple = tupleTransformer.transformJson(originalTuple);

Copy link
Member

Choose a reason for hiding this comment

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

Seems to be in a number of other places in this PR too. Seems like it might reduce the change surface area, your call.

var headers = (Map<String, Object>) incomingJson.get(JsonKeysForHttpMessage.HEADERS_KEY);
public Object transformJson(Object incomingJson) {
@SuppressWarnings("unchecked")
var headers = (Map<String, Object>) ((Map<String, Object>) incomingJson).get(JsonKeysForHttpMessage.HEADERS_KEY);
Copy link
Member

Choose a reason for hiding this comment

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

Could we make a function that encapsulates (read as 'hides') the casting cases?

@AndreKurait AndreKurait merged commit 06ae3ca into opensearch-project:main Dec 20, 2024
22 checks passed
@AndreKurait AndreKurait deleted the TransformationPluginObjectContract branch December 20, 2024 17:09
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.

2 participants