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

Support convert entry type on arrays #4925

Merged
merged 4 commits into from
Sep 27, 2024

Conversation

kkondaka
Copy link
Collaborator

@kkondaka kkondaka commented Sep 9, 2024

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

  • [X ] New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • [ X] 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.

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

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?

Copy link
Collaborator Author

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.

Copy link
Member

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;
Copy link
Member

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

Copy link
Collaborator Author

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

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.

Signed-off-by: Kondaka <krishkdk@amazon.com>
Signed-off-by: Kondaka <krishkdk@amazon.com>
Signed-off-by: Kondaka <krishkdk@amazon.com>
Copy link
Member

@dlvenable dlvenable left a comment

Choose a reason for hiding this comment

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

Thank you @kkondaka !

@kkondaka kkondaka merged commit 69b1f9a into opensearch-project:main Sep 27, 2024
46 of 47 checks passed
sb2k16 pushed a commit to sb2k16/data-prepper that referenced this pull request Oct 4, 2024
* 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>
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