Skip to content

Use stream optional enum set from core in MLStatsInput #3648

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

q-andy
Copy link

@q-andy q-andy commented Mar 13, 2025

Description

Refactors MLStatsInput to use StreamInput::readOptionalEnumSet and StreamOutput::writeOptionalEnumSet from OpenSearch core, added in this recent PR: opensearch-project/OpenSearch#17556

The currently this is implemented in ml-commons using a private helper. I added this functionality to core using ml-commons as a reference so it could be reused in neural search, so the implementation is identical. While I made this change so other plugins could use the same function, I figure it might make sense to use it in ml-commons as well.

Compare
ml-commons implmentation

private void writeEnumSet(StreamOutput out, EnumSet<?> set) throws IOException {
    if (set != null && set.size() > 0) {
        out.writeBoolean(true);
        out.writeEnumSet(set);
    } else {
        out.writeBoolean(false);
    }
}

Core implementation

public <E extends Enum<E>> void writeOptionalEnumSet(@Nullable EnumSet<E> enumSet) throws IOException {
    if (enumSet != null && enumSet.size() > 0) {
        writeBoolean(true);
        writeEnumSet(enumSet);
    } else {
        writeBoolean(false);
    }
}

Related Issues

n/a

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

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.

@q-andy q-andy had a problem deploying to ml-commons-cicd-env-require-approval March 13, 2025 22:27 — with GitHub Actions Failure
@q-andy q-andy had a problem deploying to ml-commons-cicd-env-require-approval March 13, 2025 22:27 — with GitHub Actions Failure
@q-andy q-andy had a problem deploying to ml-commons-cicd-env-require-approval March 13, 2025 22:27 — with GitHub Actions Error
@q-andy q-andy had a problem deploying to ml-commons-cicd-env-require-approval March 13, 2025 22:27 — with GitHub Actions Error
@akolarkunnu
Copy link
Contributor

Changes look good.

Copy link
Contributor

@pyek-bot pyek-bot left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks for the change!

@pyek-bot
Copy link
Contributor

can we get some maintainer reviews here and merge this PR please?

@q-andy q-andy had a problem deploying to ml-commons-cicd-env-require-approval April 2, 2025 21:08 — with GitHub Actions Failure
@q-andy q-andy temporarily deployed to ml-commons-cicd-env-require-approval April 2, 2025 21:08 — with GitHub Actions Inactive
@q-andy q-andy had a problem deploying to ml-commons-cicd-env-require-approval April 2, 2025 21:08 — with GitHub Actions Failure
@q-andy q-andy had a problem deploying to ml-commons-cicd-env-require-approval April 2, 2025 21:08 — with GitHub Actions Error
@mingshl
Copy link
Collaborator

mingshl commented Apr 2, 2025

thanks for bringing over this change to mlcommons, rerunning CI, please make sure the changes doesn't break any existing tests. Don't merge before the tests pass

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.

4 participants