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

Improves doc values format deprecation message #33576

Merged
merged 5 commits into from
Sep 11, 2018
Merged

Improves doc values format deprecation message #33576

merged 5 commits into from
Sep 11, 2018

Conversation

colings86
Copy link
Contributor

This changes the deprecation message when doc values fields do not
supply a format form logging a deprecation warning for each offending
field individually to logging a single message which lists all
offending fields

Closes #33572

@colings86 colings86 added >bug blocker :Search/Search Search-related issues that do not fall into other categories v7.0.0 v6.5.0 v6.4.1 labels Sep 10, 2018
@colings86 colings86 self-assigned this Sep 10, 2018
@colings86 colings86 requested a review from jpountz September 10, 2018 17:49
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@colings86 colings86 requested a review from jimczi September 10, 2018 17:51
Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

I left some comments.

@@ -76,6 +76,7 @@ public void hitsExecute(SearchContext context, SearchHit[] hits) throws IOExcept

hits = hits.clone(); // don't modify the incoming hits
Arrays.sort(hits, Comparator.comparingInt(SearchHit::docId));
List<String> noFormatFields = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

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

It is a shame to allocate this for every search request that needs to fetch in this sub-phase. The escape analysis will not be able to elide the allocation because the list escapes the method in the deprecation logger invocation. Can we collect these differently?

Also, there is a REST test that exposes this deprecation message. Would you update it to include two fields and ensure the format is correct?

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 not too worried about the allocation, but I have a different concern which is that we collect into a list and then log 80 lines below if this list is not empty - I'd rather like to loop twice and have everything in a single place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a shame to allocate this for every search request that needs to fetch in this sub-phase. The escape analysis will not be able to elide the allocation because the list escapes the method in the deprecation logger invocation. Can we collect these differently?

Do you have something particular in mind?

Also, there is a REST test that exposes this deprecation message. Would you update it to include two fields and ensure the format is correct?

Noted. I didn't see where the test was to start with but no you pointed it out (offline) and the PR CI highlighted it too I'll address it

DEPRECATION_LOGGER.deprecated("There are doc-value field which are not using a format. The output will "
+ "change in 7.0 when doc value fields get formatted based on mappings by default. It is recommended to pass "
+ "[format={}] with a doc value field in order to opt in for the future behaviour and ease the migration to "
+ "7.0: [{}]", DocValueFieldsContext.USE_DEFAULT_FORMAT, noFormatFields);
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really need the outer brackets, there will be double brackets in the string because of the list, right?

@colings86
Copy link
Contributor Author

@jpountz I pushed a commit that should address your concerns.

Not sure that it addresses @jasontedor's concern though

List<String> noFormatFields = context.docValueFieldsContext().fields().stream().filter(f -> f.format == null).map(f -> f.field)
.collect(Collectors.toList());
if (noFormatFields.isEmpty() == false) {
DEPRECATION_LOGGER.deprecated("There are doc-value field which are not using a format. The output will "
Copy link
Contributor

Choose a reason for hiding this comment

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

fieldS?

This changes the deprecation message when doc values fields do not
supply a format form logging a deprecation warning for each offending
field individually to logging a single message which lists all
offending fields

Closes #33572
Also adds a test to ensure multiple deprecation warnings are collated
into one message
Moves the collection of fields that don't have a format to a separate
loop and moves the logging of the deprecation warning to be next to it
at the expesnse of looping through the field list twice
@colings86 colings86 merged commit 624b84f into elastic:master Sep 11, 2018
colings86 added a commit that referenced this pull request Sep 11, 2018
* Improves doc values format deprecation message

This changes the deprecation message when doc values fields do not
supply a format form logging a deprecation warning for each offending
field individually to logging a single message which lists all
offending fields

Closes #33572

* Updates YAML test with new deprecation message

Also adds a test to ensure multiple deprecation warnings are collated
into one message

* Condenses collection of fields without format check

Moves the collection of fields that don't have a format to a separate
loop and moves the logging of the deprecation warning to be next to it
at the expesnse of looping through the field list twice

* fixes typo

* Fixes test
colings86 added a commit that referenced this pull request Sep 11, 2018
* Improves doc values format deprecation message

This changes the deprecation message when doc values fields do not
supply a format form logging a deprecation warning for each offending
field individually to logging a single message which lists all
offending fields

Closes #33572

* Updates YAML test with new deprecation message

Also adds a test to ensure multiple deprecation warnings are collated
into one message

* Condenses collection of fields without format check

Moves the collection of fields that don't have a format to a separate
loop and moves the logging of the deprecation warning to be next to it
at the expesnse of looping through the field list twice

* fixes typo

* Fixes test
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Sep 11, 2018
* master:
  Remove debug logging in full cluster restart tests (elastic#33612)
  Expose CCR to the transport client (elastic#33608)
  Mute testIndexDeletionWhenNodeRejoins
  SQL: Make Literal a NamedExpression (elastic#33583)
  [DOCS] Adds missing built-in user information (elastic#33585)
  Improves doc values format deprecation message (elastic#33576)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker >bug :Search/Search Search-related issues that do not fall into other categories v6.4.1 v6.5.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants