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

Add assertion that all field mapper names are interned #87238

Conversation

original-brownbear
Copy link
Member

Follow up to #86301. Assert that all field names are interned so we don't
lose this optimization and fix FieldAliasMapper.name for it not to trip.

Follow up to elastic#86301. Assert that all field names are interned so we don't
lose this optimization and fix `FieldAliasMapper.name` for it not to trip.
@original-brownbear original-brownbear added >non-issue :Search Foundations/Mapping Index mappings, including merging and defining field types v8.4.0 labels May 31, 2022
@elasticmachine elasticmachine added the Team:Search Meta label for search team label May 31, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

assert mapper.simpleName() == mapper.simpleName().intern();
if (mapper instanceof ObjectMapper) {
((ObjectMapper) mapper).mappers.forEach(MappingLookup::assertNamesInterned);
}
Copy link
Member

Choose a reason for hiding this comment

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

thanks a lot for working on this. Maybe silly question, but could this be instead a new test method added to MapperTestCase instead of an assertion?

Copy link
Member Author

Choose a reason for hiding this comment

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

I figured that a test will always only cover a portion of our parsing (and wouldn't have caught the alias field case fixed here for example) while an assertion gives us full coverage?

Copy link
Member

Choose a reason for hiding this comment

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

@romseygeek do you have opinions here? Do you mind giving this a quick look?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think an assertion is fine, all of the MapperTestCase tests will build a MappingLookup so this assertion will trip there as well.

assert mapper.simpleName() == mapper.simpleName().intern();
if (mapper instanceof ObjectMapper) {
((ObjectMapper) mapper).mappers.forEach(MappingLookup::assertNamesInterned);
}
Copy link
Member

Choose a reason for hiding this comment

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

thanks a lot for working on this. Maybe silly question, but could this be instead a new test method added to MapperTestCase instead of an assertion?

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

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

Thanks for your patience @original-brownbear

@original-brownbear
Copy link
Member Author

Thanks Luca!

@original-brownbear original-brownbear merged commit f15b414 into elastic:master Jun 9, 2022
@original-brownbear original-brownbear deleted the assert-field-mapper-names-all-interned branch June 9, 2022 08:37
@original-brownbear original-brownbear restored the assert-field-mapper-names-all-interned branch April 18, 2023 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants