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

Decode max and min optimization more carefully #52336

Merged
merged 4 commits into from
Feb 14, 2020

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Feb 13, 2020

Fixes the the no-query optimization for min and max aggregations
for date_nanos fields by delegating decoding dates "through" their
resolution member.

Closes #52220

Fixes the the no-query optimization for `min` and `max` aggregations
for `date_nanos` fields by delegating decoding dates "through" their
`resolution` member.

Closes elastic#52220
@elasticmachine
Copy link
Collaborator

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

@@ -98,7 +98,7 @@ public LeafBucketCollector getLeafCollector(LeafReaderContext ctx,
if (pointConverter != null) {
Number segMax = findLeafMaxValue(ctx.reader(), pointField, pointConverter);
if (segMax != null) {
/**
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 was a javadoc comment in an invalid spot for javadoc.

@@ -799,21 +815,6 @@ public void testMinShortcutRandom() throws Exception {
(v) -> DoublePoint.decodeDimension(v, 0));
}

private void testMinCase(IndexSearcher searcher,
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 isn't used any more.

@@ -889,12 +890,17 @@ private Aggregator mockAggregator() {
return config;
}

private ValuesSourceConfig<ValuesSource.Numeric> mockDateValuesSourceConfig(String fieldName, boolean indexed) {
private ValuesSourceConfig<ValuesSource.Numeric> mockDateValuesSourceConfig(String fieldName, boolean indexed,
Copy link
Member Author

Choose a reason for hiding this comment

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

There is a ton more ceremony here because resolution is only set when you call build. Bleh.

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

assertNull(
MinAggregator.getPointReaderOrNull(
mockSearchContext(new MatchAllDocsQuery()),
mockAggregator(),
mockDateValuesSourceConfig("number", true)
mockDateValuesSourceConfig("number", true, randomFrom(DateFieldMapper.Resolution.values()))
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little uncomfortable using a randomization for coverage here. I'd rather loop over the possible resolution values like we loop over the possible numeric types above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure!

@nik9000 nik9000 merged commit cd50922 into elastic:master Feb 14, 2020
@nik9000
Copy link
Member Author

nik9000 commented Feb 14, 2020

Thanks @not-napoleon !

nik9000 added a commit to nik9000/elasticsearch that referenced this pull request Feb 14, 2020
Fixes the the no-query optimization for `min` and `max` aggregations
for `date_nanos` fields by delegating decoding dates "through" their
`resolution` member.

Closes elastic#52220
nik9000 added a commit to nik9000/elasticsearch that referenced this pull request Feb 14, 2020
Fixes the the no-query optimization for `min` and `max` aggregations
for `date_nanos` fields by delegating decoding dates "through" their
`resolution` member.

Closes elastic#52220
nik9000 added a commit that referenced this pull request Feb 14, 2020
Fixes the the no-query optimization for `min` and `max` aggregations
for `date_nanos` fields by delegating decoding dates "through" their
`resolution` member.

Closes #52220
nik9000 added a commit that referenced this pull request Feb 14, 2020
Fixes the the no-query optimization for `min` and `max` aggregations
for `date_nanos` fields by delegating decoding dates "through" their
`resolution` member.

Closes #52220
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.

Unexpected behaviour for min - max aggregations on date_nanos type
4 participants