Skip to content

[Rest Api Compatibility] Make query registration easier #75722

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

Merged

Conversation

pgomulka
Copy link
Contributor

Refactoring to NamedXContentRegistry to make it easier to register new
query builders. It removes the concept of separate compatibel
namedXContentRegistry and adds a second dimension - restApiVersion - to
registry in NamedXContentRegistry.
This makes the design similar to the solution in ObjectParser where the
field parser lookup map also needs has a restApiVersion

relates #51816

  • Have you signed the contributor license agreement?
  • Have you followed the contributor guidelines?
  • If submitting code, have you built your formula locally prior to submission with gradle check?
  • If submitting code, is your pull request against master? Unless there is a good reason otherwise, we prefer pull requests against master and will backport as needed.
  • If submitting code, have you checked that your submission is for an OS and architecture that we support?
  • If you are submitting this code for a class then read our policy for that.

Refactoring to NamedXContentRegistry to make it easier to register new
query builders. It removes the concept of separate compatibel
namedXContentRegistry and adds a second dimension - restApiVersion - to
registry in NamedXContentRegistry.
This makes the design similar to the solution in ObjectParser where the
field parser lookup map also needs has a restApiVersion

relates elastic#51816
@pgomulka pgomulka added the :Core/Infra/REST API REST infrastructure and utilities label Jul 27, 2021
@pgomulka pgomulka requested review from joegallo and jakelandis July 27, 2021 07:47
@pgomulka pgomulka self-assigned this Jul 27, 2021
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Jul 27, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@pgomulka
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/bwc

@@ -738,9 +738,9 @@ protected Node(final Environment initialEnvironment,
}

// package scope for testing
List<NamedXContentRegistry.Entry> getCompatibleNamedXContents() {
Stream<NamedXContentRegistry.Entry> getCompatibleNamedXContents() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit suspicious about this switch from List to Stream -- can you walk it back or convince me that it's a great idea?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the reason is that when NamedXContentRegistry is created here https://github.com/elastic/elasticsearch/pull/75722/files#diff-d01b960cab84fe2338f230b5e7535bc8efa9f9778ecf61c9f527067351dca895R413
it aggregates all streams before converting to a list. I was thinking this could avoid unnecessary list creation in getCompatibleNamedXContents
but.. It made me thinking if we even need this now. We can register both compatible and current NamedXContentEntries in the same registry..
I guess I should just remove that Node#getCompatibleNamedXContents and Plugin#getNamedXContentForCompatibility

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is how usage of shared registry for compatible and current NamedXContentRegistry.Entry entries will look like
draft for type query:
https://github.com/elastic/elasticsearch/pull/75453/files#diff-57f10f7614a75787774b36d41833688a0474b84eb239e4c84499feec9634eefbR845

@pgomulka pgomulka requested a review from joegallo July 30, 2021 12:49
Copy link
Contributor

@joegallo joegallo left a comment

Choose a reason for hiding this comment

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

👍

@pgomulka pgomulka merged commit c8c5d22 into elastic:master Aug 3, 2021
lockewritesdocs pushed a commit to lockewritesdocs/elasticsearch that referenced this pull request Aug 3, 2021
Refactoring to NamedXContentRegistry to make it easier to register new
query builders. It removes the concept of separate compatibel
namedXContentRegistry and adds a second dimension - restApiVersion - to
registry in NamedXContentRegistry.
This makes the design similar to the solution in ObjectParser where the
field parser lookup map also needs has a restApiVersion

relates elastic#51816
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/REST API REST infrastructure and utilities Team:Core/Infra Meta label for core/infra team v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants