-
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
Disable optimization if we aren't sure its faster #74260
Changes from 6 commits
c65a2f2
0c0dd51
cfdd7e5
da7e9ff
c7e13ae
293858f
99fcff8
7e1e67b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ public abstract class AdaptingAggregator extends Aggregator { | |
public AdaptingAggregator( | ||
Aggregator parent, | ||
AggregatorFactories subAggregators, | ||
CheckedFunction<AggregatorFactories, Aggregator, IOException> delegate | ||
CheckedFunction<AggregatorFactories, ? extends Aggregator, IOException> delegate | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This delegate thing is required so we can "pin" the parent references in the sub aggregators. I wish we didn't have to do that stuff, but here we are. |
||
) throws IOException { | ||
// Its important we set parent first or else when we build the sub-aggregators they can fail because they'll call this.parent. | ||
this.parent = parent; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ | |
import org.apache.lucene.search.DocValuesFieldExistsQuery; | ||
import org.apache.lucene.search.IndexSearcher; | ||
import org.apache.lucene.util.Bits; | ||
import org.elasticsearch.common.CheckedSupplier; | ||
|
||
import java.io.IOException; | ||
import java.util.function.BiConsumer; | ||
|
@@ -43,14 +42,6 @@ long count(LeafReaderContext ctx, FiltersAggregator.Counter counter, Bits live) | |
return super.count(ctx, counter, live); | ||
} | ||
|
||
@Override | ||
long estimateCountCost(LeafReaderContext ctx, CheckedSupplier<Boolean, IOException> canUseMetadata) throws IOException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No more estimate*Cost methods because we use heuristics on query type. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem with estimate*Cost methods was that they couldn't detect when a query was slow to prepare because you had to prepare to get the cost. And, now that we disable the optimization if the top level is non-match-all there isn't really any complex heuristics to do. We have a lot more control over which queries come in on the filters, at least in the "optimize" route. |
||
if (canUseMetadata.get() && canCountFromMetadata(ctx)) { | ||
return 0; | ||
} | ||
return super.estimateCountCost(ctx, canUseMetadata); | ||
} | ||
|
||
private boolean canCountFromMetadata(LeafReaderContext ctx) throws IOException { | ||
FieldInfo info = ctx.reader().getFieldInfos().fieldInfo(query().getField()); | ||
if (info == null) { | ||
|
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 have to go through a ton of mocking without this and I'm explicitly trying to test runtime fields so I think its probably worth it to just make it public. There is a private builder factory thing but it goes through a lot of parsing infrastructure we don't have in the tests.
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 may be a dumb question, but can you not just use the public constructor above? Particularly as it looks like your use of this is just doing a source lookup, which is what the name-only constructor gives you.
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.
No, it's a good question. I could use it if I built the _source but all the rest of those tests operate on doc values so I don't really have the infrastructure in them to build the source. Maybe that's simpler than I though and I should just do it. I'll have a look.
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 gave this a shot and it didn't work. I think those public ctors don't currently make useful fields. That's worth fixing, I think, but probably not in this PR.