-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Conversation
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 |
There was a problem hiding this comment.
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); | ||
} |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 | ||
); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice work
Thanks for reviewing! |
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.
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.
We've been trying to shrink the big, mutable
SearchContext
. I'm doingmy part by removing
BigArrays
from it. Doing that required reworkinghow we test
Aggregator
s to not needSearchContext
. So I did thattoo. Mostly.
top_hits
still needs aSubSearchContext
which we canstill build, but it is now quite contained.