Skip to content

Replace the SearchContext with QueryShardContext when building aggregator factories#46527

Merged
jimczi merged 4 commits intoelastic:masterfrom
jimczi:features/reader_context
Sep 11, 2019
Merged

Replace the SearchContext with QueryShardContext when building aggregator factories#46527
jimczi merged 4 commits intoelastic:masterfrom
jimczi:features/reader_context

Conversation

@jimczi
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

Pinging @elastic/es-analytics-geo

Copy link
Copy Markdown
Contributor

@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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

@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