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 BigArrays from SearchContext #65981

Merged
merged 4 commits into from
Dec 8, 2020

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Dec 7, 2020

We've been trying to shrink the big, mutable SearchContext. I'm doing
my part by removing BigArrays from it. Doing that required reworking
how we test Aggregators to not need SearchContext. So I did that
too. Mostly. top_hits still needs a SubSearchContext which we can
still build, but it is now quite contained.

@nik9000 nik9000 requested a review from not-napoleon December 7, 2020 20:45
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Dec 7, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

We've been trying to shrink the big, mutable `SearchContext`. I'm doing
my part by removing `BigArrays` from it. Doing that required reworking
how we test `Aggregator`s to not need `SearchContext`. So I did that
too. Mostly. `top_hits` still needs a `SubSearchContext` which we can
still build, but it is now quite contained.
searchContext = new DefaultSearchContext(reader, request, shardTarget, clusterService,
bigArrays, threadPool::relativeTimeInMillis, timeout, fetchPhase, lowLevelCancellation);
searchContext = new DefaultSearchContext(reader, request, shardTarget,
threadPool::relativeTimeInMillis, timeout, fetchPhase, lowLevelCancellation);
// we clone the query shard context here just for rewriting otherwise we
Copy link
Member Author

Choose a reason for hiding this comment

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

clusterService was unused so I removed it while I was clearing bigArrays.

@Override
protected AggregationBuilder doRewrite(QueryRewriteContext queryShardContext) throws IOException {
return super.doRewrite(queryShardContext);
}
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 didn't do anything....

* Is this request cacheable? Requests that have
* non-deterministic queries or scripts aren't cachable.
*/
public abstract boolean isCacheable();
Copy link
Member Author

Choose a reason for hiding this comment

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

These are required by tests. I could avoid adding it with some terrible casting stuff in tests but I think it is better to be up front about it.

@@ -277,6 +284,7 @@ public ProductionAggregationContext(
Supplier<Boolean> isCancelled
) {
this.context = context;
this.bigArrays = context.bigArrays().withCircuitBreaking(); // We can break in searches.
Copy link
Member Author

Choose a reason for hiding this comment

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

Had to move with withCircuitBreaking from SearchContext.

randomInt(),
() -> 0L,
() -> false
);
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'd love to use a specialized testing subclass but this change is large enough as it is without me changing it.

IndexShard indexShard = mock(IndexShard.class);
when(indexShard.shardId()).thenReturn(new ShardId("test", "test", 0));
when(ctx.indexShard()).thenReturn(indexShard);
return new SubSearchContext(ctx);
Copy link
Member Author

Choose a reason for hiding this comment

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

Now all of this is contained to only be called for top_hits.

Copy link
Member

@not-napoleon not-napoleon left a comment

Choose a reason for hiding this comment

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

LGTM, nice work

@nik9000 nik9000 merged commit 3e45318 into elastic:master Dec 8, 2020
@nik9000
Copy link
Member Author

nik9000 commented Dec 8, 2020

LGTM, nice work

Thanks for reviewing!

nik9000 added a commit to nik9000/elasticsearch that referenced this pull request Dec 8, 2020
We've been trying to shrink the big, mutable `SearchContext`. I'm doing
my part by removing `BigArrays` from it. Doing that required reworking
how we test `Aggregator`s to not need `SearchContext`. So I did that
too. Mostly. `top_hits` still needs a `SubSearchContext` which we can
still build, but it is now quite contained.
nik9000 added a commit that referenced this pull request Dec 8, 2020
We've been trying to shrink the big, mutable `SearchContext`. I'm doing
my part by removing `BigArrays` from it. Doing that required reworking
how we test `Aggregator`s to not need `SearchContext`. So I did that
too. Mostly. `top_hits` still needs a `SubSearchContext` which we can
still build, but it is now quite contained.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations >refactoring Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v7.11.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants