-
Notifications
You must be signed in to change notification settings - Fork 202
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
Support convert entry type on arrays #4925
Support convert entry type on arrays #4925
Conversation
Signed-off-by: Kondaka <krishkdk@amazon.com>
@@ -80,7 +83,18 @@ public Collection<Record<Event>> doExecute(final Collection<Record<Event>> recor | |||
if (keyVal != null) { | |||
if (!nullValues.contains(keyVal.toString())) { | |||
try { | |||
recordEvent.put(key, converter.convert(keyVal, converterArguments)); | |||
if (keyVal instanceof ArrayList || keyVal.getClass().isArray()) { |
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.
Should we check for List
instead of just ArrayList
? Or will we only support ArrayList?
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.
Do we need to support other list types? Since this is supporting "arrays", I thought "ArrayList" and not generic "List" is better.
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.
List
is the interface for any ordered Collection
in Java. The ArrayList
is a specific implementation. Some situations may have a LinkedList
instead. I agree with @graytaylor0 - we should check for List
.
@@ -80,7 +83,18 @@ public Collection<Record<Event>> doExecute(final Collection<Record<Event>> recor | |||
if (keyVal != null) { | |||
if (!nullValues.contains(keyVal.toString())) { | |||
try { | |||
recordEvent.put(key, converter.convert(keyVal, converterArguments)); | |||
if (keyVal instanceof ArrayList || keyVal.getClass().isArray()) { | |||
ArrayList<Object> inputList; |
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.
should probably be List<> 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.
Do we need to support other list types? Since this is supporting "arrays", I thought "ArrayList" and not generic "List" is better.
@@ -80,7 +83,18 @@ public Collection<Record<Event>> doExecute(final Collection<Record<Event>> recor | |||
if (keyVal != null) { | |||
if (!nullValues.contains(keyVal.toString())) { | |||
try { | |||
recordEvent.put(key, converter.convert(keyVal, converterArguments)); | |||
if (keyVal instanceof ArrayList || keyVal.getClass().isArray()) { |
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.
List
is the interface for any ordered Collection
in Java. The ArrayList
is a specific implementation. Some situations may have a LinkedList
instead. I agree with @graytaylor0 - we should check for List
.
...java/org/opensearch/dataprepper/plugins/processor/mutateevent/ConvertEntryTypeProcessor.java
Outdated
Show resolved
Hide resolved
...org/opensearch/dataprepper/plugins/processor/mutateevent/ConvertEntryTypeProcessorTests.java
Show resolved
Hide resolved
Signed-off-by: Kondaka <krishkdk@amazon.com>
Signed-off-by: Kondaka <krishkdk@amazon.com>
Signed-off-by: Kondaka <krishkdk@amazon.com>
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.
Thank you @kkondaka !
* Support convert entry type on arrays Signed-off-by: Kondaka <krishkdk@amazon.com> * Addressed review comments Signed-off-by: Kondaka <krishkdk@amazon.com> * Fixed failing tests Signed-off-by: Kondaka <krishkdk@amazon.com> * Addressed review comments Signed-off-by: Kondaka <krishkdk@amazon.com> --------- Signed-off-by: Kondaka <krishkdk@amazon.com>
Description
Support convert entry type on arrays. Each array element is converted to target type.
Issues Resolved
Resolves #[Issue number to be closed when this PR is merged]
Check List
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.