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

Translate Plugin - Target Type implementation #2979

Merged
merged 2 commits into from
Jul 6, 2023

Conversation

vishalboin
Copy link
Contributor

Description

Implemented target_type option in translate processor. Added necessary test cases.

Issues Resolved

#1914

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.

@@ -85,4 +95,30 @@ public boolean isPatternPresent(){
return regexParameterConfiguration == null || regexParameterConfiguration.getPatterns() != null;
}

@AssertTrue(message = "The mapped values does not match the target type provided")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: "The mapped values do not match the target type provided"

return map.keySet().stream().allMatch(key -> checkTargetValueType(map.get(key)));
}

@AssertTrue(message = "The pattern values does not match the target type provided")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: same as above "does not" -> "do not"

@@ -16,6 +16,7 @@ dependencies {
testImplementation project(':data-prepper-plugins:log-generator-source')
testImplementation project(':data-prepper-test-common')
implementation 'org.apache.commons:commons-lang3:3.12.0'
testImplementation project(path: ':data-prepper-plugins:mutate-event-processors')
Copy link
Member

Choose a reason for hiding this comment

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

Why is this testImplementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wrong dependency. I with push changes with implementation project(path: ':data-prepper-plugins:mutate-event-processors').

import java.util.stream.Stream;


public class TranslateProcessorConfig {

final TargetType TARGET_TYPE = TargetType.STRING;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Could just put this inline

private TargetType targetType = TargetType.STRING

private final LinkedHashMap<Range<Float>, Object> rangeMappings;
private final Map<String, Object> individualMappings;
private final Map<Pattern, Object> compiledPatterns;
private final TypeConverter converter;
Copy link
Member

Choose a reason for hiding this comment

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

Another option to not take a dependency on all mutate-events processors would be for us to just move the convert processor out to its own module

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will do it in the next PR

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 this translate processor needs to be moved into mutate-event-processors

Signed-off-by: Vishal Boinapalli <[email protected]>
@kkondaka kkondaka merged commit cc5ed41 into opensearch-project:main Jul 6, 2023
24 checks passed
MaGonzalMayedo pushed a commit to MaGonzalMayedo/data-prepper that referenced this pull request Jul 25, 2023
* Translate Plugin - Target Type implementation

Signed-off-by: Vishal Boinapalli <[email protected]>

* addressed review comments

Signed-off-by: Vishal Boinapalli <[email protected]>

---------

Signed-off-by: Vishal Boinapalli <[email protected]>
Signed-off-by: Marcos Gonzalez Mayedo <[email protected]>
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