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

Replace the SearchContext with QueryShardContext when building aggregator factories #46527

Merged
merged 4 commits into from
Sep 11, 2019

Conversation

jimczi
Copy link
Contributor

@jimczi jimczi commented Sep 10, 2019

This commit replaces the SearchContext with the QueryShardContext when building aggregator factories.
Aggregator factories are part of the SearchContext so they shouldn't require a SearchContext to create them.The main changes here are the signatures of AggregationBuilder#build that now takes a QueryShardContext and AggregatorFactory#createInternal that passes the SearchContext to build the Aggregator.

Relates #46523

…ator factories

This commit replaces the `SearchContext` with the `QueryShardContext` when building aggregator factories.
Aggregator factories are part of the `SearchContext` so they shouldn't require a `SearchContext` to create them.
The main changes here are the signatures of `AggregationBuilder#build` that now takes a `QueryShardContext` and
`AggregatorFactory#createInternal` that passes the `SearchContext` to build the `Aggregator`.

Relates elastic#46523
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo

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.

the idea makes sense to me, it is not trivial to follow all that happens in this PR due to its size. I trust you though :)

final long absoluteStartMillis = System.currentTimeMillis();
QueryShardContext context =
indexService.newQueryShardContext(0, indexReader, () -> absoluteStartMillis, null);
indexService.newQueryShardContext(0, searcher, () -> absoluteStartMillis, null);
Copy link
Member

Choose a reason for hiding this comment

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

out of curiosity: was this change necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For simplicity the QueryShardContext should expose an IndexSearcher that is configured with the correct similarity, cache, ... I can make this change in a different pr if you like ?

Copy link
Member

Choose a reason for hiding this comment

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

it would be nice, unless that cause too much extra work on your end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opened #46584 to split this pr a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I merged #46584 and incorporated the changes in this pr, can you take another look ?

@jimczi
Copy link
Contributor Author

jimczi commented Sep 10, 2019

run elasticsearch-ci/1

jimczi added a commit to jimczi/elasticsearch that referenced this pull request Sep 11, 2019
This change adds an IndexSearcher and the node's BigArrays in the QueryShardContext.
It's a spin off of elastic#46527 as this change is required to allow aggregation builder to solely use the
query shard context.

Relates elastic#46523
jimczi added a commit that referenced this pull request Sep 11, 2019
This change adds an IndexSearcher and the node's BigArrays in the QueryShardContext.
It's a spin off of #46527 as this change is required to allow aggregation builder to solely use the
query shard context.

Relates #46523
jimczi added a commit that referenced this pull request Sep 11, 2019
This change adds an IndexSearcher and the node's BigArrays in the QueryShardContext.
It's a spin off of #46527 as this change is required to allow aggregation builder to solely use the
query shard context.

Relates #46523
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.

still LGTM thanks @jimczi

@jimczi jimczi merged commit 5eeb3c5 into elastic:master Sep 11, 2019
@jimczi jimczi deleted the features/reader_context branch September 11, 2019 14:12
jimczi added a commit that referenced this pull request Sep 11, 2019
…ator factories (#46527)

This commit replaces the `SearchContext` with the `QueryShardContext` when building aggregator factories. Aggregator factories are part of the `SearchContext` so they shouldn't require a `SearchContext` to create them.
The main changes here are the signatures of `AggregationBuilder#build` that now takes a `QueryShardContext` and `AggregatorFactory#createInternal` that passes the `SearchContext` to build the `Aggregator`.

Relates #46523
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.

4 participants