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

Fix some type checks that were always false #27706

Merged
merged 1 commit into from
Dec 11, 2017
Merged

Fix some type checks that were always false #27706

merged 1 commit into from
Dec 11, 2017

Conversation

rneatherway
Copy link
Contributor

  • CustomFieldQuery: this was added in:
    https://lgtm.com/projects/g/elastic/elasticsearch/rev/4756c9a884f3e5341db0cf7799e7e8656c7338d0
    but there was already a type check higher up in the same if/else
    chain. I opted to keep the new one, as it contains a null check that
    the earlier one does not.
  • PrioritizedEsThreadPoolExecutor: This check was simply a duplicate
    of one earlier and would never have been true. The behaviour would
    have been the same if it was reached.
  • DocumentParser: The checks for Text and Keyword were masked by the
    earlier check for String, which they are child classes of. I changed
    the order to have the more specific checks first so that they are
    all now possible.

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@cbuescher
Copy link
Member

@rneatherway thanks for digging up more of these. I'll kick of a CI run first and will take a look in a bit.
@elasticmachine test this please

@cbuescher cbuescher self-assigned this Dec 8, 2017
Copy link
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

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

@rneatherway I took a look, the first two changes look pretty straight forward to me but the last one I want to double check the impact of so I'm waiting for replies before pulling this in.

@@ -75,9 +75,6 @@ void flatten(Query sourceQuery, IndexReader reader, Collection<Query> flatQuerie
} else if (sourceQuery instanceof BlendedTermQuery) {
final BlendedTermQuery blendedTermQuery = (BlendedTermQuery) sourceQuery;
flatten(blendedTermQuery.rewrite(reader), reader, flatQueries, boost);
} else if (sourceQuery instanceof ESToParentBlockJoinQuery) {
ESToParentBlockJoinQuery blockJoinQuery = (ESToParentBlockJoinQuery) sourceQuery;
flatten(blockJoinQuery.getChildQuery(), reader, flatQueries, boost);
Copy link
Member

Choose a reason for hiding this comment

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

+1,
This indeed looks similar to the later else-if branch which I would prefer for its null check. I only wonder if the order of clauses matters, but I checked BoostingQuery and SynonymQuery and they both don't seem to by supertypes of ESToParentBlockJoinQuery. Maybe @jimczi can check if I missed anything?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1, this is not needed.

return command;
}
Priority priority = ((PrioritizedRunnable) command).priority();
return new TieBreakingPrioritizedRunnable(super.wrapRunnable(command), priority, insertionOrder.incrementAndGet());
} else if (command instanceof PrioritizedFutureTask) {
return command;
} else { // it might be a callable wrapper...
if (command instanceof TieBreakingPrioritizedRunnable) {
return command;
}
Copy link
Member

Choose a reason for hiding this comment

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

+1 looks redundant to me

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 from my side as well

@@ -618,16 +618,16 @@ private static void parseNullValue(ParseContext context, ObjectMapper parentMapp

private static Mapper.Builder<?,?> createBuilderFromFieldType(final ParseContext context, MappedFieldType fieldType, String currentFieldName) {
Mapper.Builder builder = null;
if (fieldType instanceof StringFieldType) {
Copy link
Member

@cbuescher cbuescher Dec 8, 2017

Choose a reason for hiding this comment

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

This change also makes sense to me, but I'd like @jpountz to take a look at this because I wonder what we might have missed here in terms of tests and also to determine if we should backport this change to other branches. It looks like we never reached the TextFieldType-case in the past and I'm wondering what that means and if it is harmless on the long run.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I have amended my commit here. I will open another PR with just this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done at #27726

Copy link
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

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

I just had a chat with @jimczi about the third change in DocumentParser and though it seems like something we need to change indeed, its not immediately clear what side effects this might have, so we'd like to zoom in on that in a bit more detail. Could you open a separate PR for only that change and remove it from this PR, then I can merge the other two changes in more quickly.

* CustomFieldQuery: this was added in:
  https://lgtm.com/projects/g/elastic/elasticsearch/rev/4756c9a884f3e5341db0cf7799e7e8656c7338d0
  but there was already a type check higher up in the same if/else
  chain. I opted to keep the new one, as it contains a null check that
  the earlier one does not.
* PrioritizedEsThreadPoolExecutor: This check was simply a duplicate
  of one earlier and would never have been true. The behaviour would
  have been the same if it was reached.
Copy link
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

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

@rneatherway thanks, I will merge the first two changes after the test run has finished.

@cbuescher
Copy link
Member

@elasticmachine test this please

@cbuescher cbuescher merged commit 85dd188 into elastic:master Dec 11, 2017
cbuescher pushed a commit that referenced this pull request Dec 11, 2017
* CustomFieldQuery: removed a redundant type check that was 
already done higher up in the same if/else chain.
* PrioritizedEsThreadPoolExecutor: removed a check that was 
simply a duplicate of one earlier one and would never have been true.
@cbuescher
Copy link
Member

@rneatherway thanks a lot, I merged the first two changes in, the other will be reviewed in #27726.

@rneatherway rneatherway deleted the unneeded-type-checks branch December 11, 2017 10:37
@rneatherway
Copy link
Contributor Author

Cool, happy to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants