Skip to content

Move getPointReaderOrNull into AggregatorBase #58769

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

Merged
merged 10 commits into from
Jul 13, 2020

Conversation

not-napoleon
Copy link
Member

@not-napoleon not-napoleon commented Jun 30, 2020

This is a pretty straight forward refactoring to move the point reader optimization that min and max use up to the aggregator base, and move the values source config related logic into values source config. Hopefully that makes it easier to reuse, and also puts the check for if it can be applied in a more visible place.

Closes #55552

@elasticmachine
Copy link
Collaborator

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

@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jun 30, 2020
*
* @param config The config for the values source metric.
*/
public Function<byte[], Number> getPointReaderOrNull(ValuesSourceConfig config) {
Copy link
Member

Choose a reason for hiding this comment

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

Do you think now'd be a good time to change the name? I always thought something like pointReaderIfSafe or something is a little more clear about why you might get null back.

And it isn't so much "if early termination is applicable" as "if there are no filters and the underlying index is in the same order as the values produced by the config"

Copy link
Member

Choose a reason for hiding this comment

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

Could you make the method final?

Copy link
Member Author

Choose a reason for hiding this comment

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

the underlying index is in the same order as the values produced by the config

Out of curiosity, what in the current logic looks at index ordering?

* @param fieldType The field type we want to get a reader for
* @return null if we can't get a reader (e.g. because the field is the wrong type), otherwise a point reader function.
*/
default Function<byte[], Number> getPointReader(MappedFieldType fieldType) { return 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.

I'm not convinced this is the right place to add extensibility here. The other option I'm considering, we could make parsePoint a method on MappedFieldType (or, maybe a method that returns a reference to parsePoint or null, depending on if it's implemented for that field). That would let us get rid of the instance type checking, and provide a way for plugins that add fields which use CoreVSTs to add custom point readers.

Copy link
Member

Choose a reason for hiding this comment

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

I agree that it should be the MappedFieldType's responsibility. It is built by the FieldMapper which is ultimately the only thing that actually knows how the index was built.

@not-napoleon
Copy link
Member Author

@elasticmachine update branch

@nik9000
Copy link
Member

nik9000 commented Jul 6, 2020

@not-napoleon I edited your description to say that this closes #58769 which I believe it does, in that it creates the abstraction that other aggs can use to read the points. It doesn't link them all in. At least, it didn't when I last looked, but I think that is ok.

@not-napoleon
Copy link
Member Author

@nik9000 am I missing something? This is #58769. Do you mean that it should close #55552 ?

@nik9000
Copy link
Member

nik9000 commented Jul 9, 2020

@nik9000 am I missing something? This is #58769. Do you mean that it should close #55552 ?

Yes! Sorry.

 Conflicts:
	server/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceConfig.java
Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

LGTM

@not-napoleon not-napoleon merged commit dc91a30 into elastic:master Jul 13, 2020
@not-napoleon not-napoleon deleted the vs-config-raw-data-flag branch July 13, 2020 18:20
not-napoleon added a commit to not-napoleon/elasticsearch that referenced this pull request Jul 13, 2020
 Conflicts:
	server/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceConfig.java
	server/src/test/java/org/elasticsearch/search/aggregations/metrics/MinAggregatorTests.java
@jakelandis jakelandis removed the v8.0.0 label Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations >non-issue >refactoring Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v7.9.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ValuesSource support for reading points
4 participants