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

Remove QueryParseContext #25486

Merged
merged 2 commits into from
Jul 3, 2017

Conversation

cbuescher
Copy link
Member

QueryParseContext is currently only used as a wrapper for an XContentParser, so
this change removes it entirely and changes the appropriate APIs that use it so
far to only accept a parser instead.

@@ -53,7 +53,7 @@
public static final ParseField IGNORE_UNMAPPED = new ParseField("ignore_unmapped");
public static final QueryBuilder DEFAULT_INNER_HIT_QUERY = new MatchAllQueryBuilder();

private static final ObjectParser<InnerHitBuilder, QueryParseContext> PARSER = new ObjectParser<>("inner_hits", InnerHitBuilder::new);
Copy link
Member

Choose a reason for hiding this comment

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

❤️

* Internal: Registers sub-factories with this factory. The sub-factory will
* be responsible for the creation of sub-aggregators under the aggregator
* created by this factory. This is only for use by
* {@link AggregatorFactories#parseAggregators(org.elasticsearch.common.xcontent.XContentParser)}.
Copy link
Member

Choose a reason for hiding this comment

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

I think it is ok to import XContentParser to make the javadoc shorter if you like.

@@ -57,15 +57,15 @@
private String separator = DEFAULT_SEPARATOR;

public static Aggregator.Parser getParser() {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be

public static final Aggregator.Parser PARSER;
static {
  ObjectParser objectParser = new ObjectParser();
  // build the parser
  PARSER = (name, parser) -> {
    // Stuff
  };
}

I think that'd be closer to how we parse other things. Not the same, but closer.

Copy link
Member Author

Choose a reason for hiding this comment

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

to be honest, I don't know the reason why this is constructed the way it is. Will see if I can change this.

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 changed this to a more "standard" approach of constructing the parser.

IncludeExclude::parseInclude, IncludeExclude.INCLUDE_FIELD, ObjectParser.ValueType.OBJECT_ARRAY_OR_STRING);

parser.declareField((b, v) -> b.includeExclude(IncludeExclude.merge(b.includeExclude(), v)),
Copy link
Member

Choose a reason for hiding this comment

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

Same question as for the adjacency matrix one.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is more tricky to untangle because of the significanceHeuristicParserRegistry that needs to be passed in. No idea why, but I tried changing this but it gets a bit to involved to do it in this PR I think.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough. I wouldn't change the capitalization though.

Copy link
Member

Choose a reason for hiding this comment

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

I had a quick look and opened #25519 with what I imagine the strategy is. It certainly looks big enough to be worth doing in its own PR.

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 wouldn't change the capitalization though

Thats done because of naming conflicts I otherwise get in https://github.com/elastic/elasticsearch/pull/25486/files#diff-e5532441d96af10726cd20f6b653e3e9R101
I could rename the XContentparser there I guess, but we user capital case for ObjectParser quiet often.

Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't name it in capital case because it isn't a constant. Otherwise I'm fine with whatever rename you like.

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense, sorry it took me so long to understand what you mean, but I'm so used to see these parsers as constants (because they usually are) that I didn't see this one isn't.

@nik9000
Copy link
Member

nik9000 commented Jun 30, 2017

Yes!

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.

LGTM thanks @cbuescher for taking care of this

@@ -276,6 +275,9 @@ public final QueryBuilder rewrite(QueryRewriteContext queryShardContext) throws
return rewritten;
}

/**
* @throws IOException exception on rewrite
Copy link
Member

Choose a reason for hiding this comment

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

nit: if we add javadocs maybe we should also say what the method is for?

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 removed this docs, they serve no real purpose

@cbuescher cbuescher force-pushed the remove-QueryParseContext-p2 branch 3 times, most recently from dd496c7 to 7d6ffcc Compare July 3, 2017 12:42
QueryParseContext is currently only used as a wrapper for an XContentParser, so
this change removes it entirely and changes the appropriate APIs that use it so
far to only accept a parser instead.
@cbuescher cbuescher force-pushed the remove-QueryParseContext-p2 branch from 7d6ffcc to d1f7a44 Compare July 3, 2017 13:18
IncludeExclude::parseInclude, IncludeExclude.INCLUDE_FIELD, ObjectParser.ValueType.OBJECT_ARRAY_OR_STRING);

parser.declareField((b, v) -> b.includeExclude(IncludeExclude.merge(b.includeExclude(), v)),
Copy link
Member

Choose a reason for hiding this comment

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

I had a quick look and opened #25519 with what I imagine the strategy is. It certainly looks big enough to be worth doing in its own PR.

};
private static final ObjectParser<AdjacencyMatrixAggregationBuilder, Void> PARSER = new ObjectParser<>(
AdjacencyMatrixAggregationBuilder.NAME);
static {
Copy link
Member

Choose a reason for hiding this comment

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

👍 Much more like the others. nice. And less lines!

@cbuescher cbuescher merged commit f576c98 into elastic:master Jul 3, 2017
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jul 4, 2017
* master: (52 commits)
  Include shared/attributes.asciidoc from docs master
  Fixed page breaks for ICU Collation Keyword Fields
  Remove QueryParseContext (elastic#25486)
  [Test] Use a common testing class for all XContent filtering tests (elastic#25491)
  Tests fix - Significant terms/text aggs  (elastic#25499)
  [DOCS] add docs for REST high level client index method (elastic#25501)
  Tests: Add Debian 9 (Stretch) to the packaging tests
  test: Run flush before upgrade and refresh after upgrade.
  Fix third party audit for repository-hdfs
  [TEST] Expect nodes getting disconnected quickly
  testPrimaryFailureIncreasesTerm should use assertBusy to wait for yellow
  Cleanup network / transport related settings (elastic#25489)
  Fix repository-hdfs plugin packaging test
  Remove allocation id from replica replication response (elastic#25488)
  Adjust BWC version on bad allocation request test
  Upgrading HDFS Repository Plugin to use HDFS 2.8.1 Client (elastic#25497)
  Adjust status on bad allocation explain requests
  Preliminary support for ARM
  Add doc note regarding explicit publish host
  Fix typo in name of test
  ...
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Query DSL labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>breaking-java :Search/Search Search-related issues that do not fall into other categories v6.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants