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

Use stream optional enum set from core in MLStatsInput #3648

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!

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