Skip to content

Encode field attributes as predicates #48864

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

Open
not-napoleon opened this issue Nov 5, 2019 · 10 comments
Open

Encode field attributes as predicates #48864

not-napoleon opened this issue Nov 5, 2019 · 10 comments
Labels
:Analytics/Aggregations Aggregations >refactoring Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) >tech debt

Comments

@not-napoleon
Copy link
Member

Currently, the aggregations framework uses instanceof operations in many places to figure out what type of values we are getting. For example:

        if (indexFieldData instanceof IndexOrdinalsFieldData) {
            dataSource = new ValuesSource.Bytes.WithOrdinals.FieldData((IndexOrdinalsFieldData) indexFieldData);
        } else {
            dataSource = new ValuesSource.Bytes.FieldData(indexFieldData);
        }

(

if (indexFieldData instanceof IndexOrdinalsFieldData) {
dataSource = new ValuesSource.Bytes.WithOrdinals.FieldData((IndexOrdinalsFieldData) indexFieldData);
} else {
dataSource = new ValuesSource.Bytes.FieldData(indexFieldData);
}
)

As part of our effort to get away from hard coding type information in the core aggregations framework, we'd like to explore replacing these with predicates on the Field Data classes. For example, the above case could use a hasOrdinals() predicate instead of the instanceof check.

@not-napoleon not-napoleon added :Analytics/Aggregations Aggregations :Search Foundations/Mapping Index mappings, including merging and defining field types >refactoring labels Nov 5, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Mapping)

@elasticmachine
Copy link
Collaborator

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

@rjernst rjernst added Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) Team:Search Meta label for search team labels May 4, 2020
@iverase
Copy link
Contributor

iverase commented Jul 14, 2020

@not-napoleon This seems to have been mostly dealt with the value source refactoring, does it make sense to have it opened or we can close it now?

@not-napoleon
Copy link
Member Author

@iverase I didn't actually address either the specific case quoted in this ticket, or the general behavior, when I did the refactor. I just moved where we do it. The code block quoted above is now found in CoreValuesSourceType: https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/search/aggregations/support/CoreValuesSourceType.java#L119-L123

So, I vote to keep this open for now.

@nik9000
Copy link
Member

nik9000 commented Mar 24, 2021

I think I just merged a hasOrdinals method. We don't use it in all the places though.

@nik9000
Copy link
Member

nik9000 commented Mar 24, 2021

Ah, but that this instanceof is what gets us to my hasOrdinals in the first place.

@not-napoleon
Copy link
Member Author

Yeah, we've made a lot of progress getting rid of instanceofs around the various ValuesSource classes. This ticket is more about the level above that, where we're selecting which ValuesSource subclass to build based on the IndexFieldData &c.

@GrayFox1
Copy link
Contributor

I am interested to pick this Issue, can i start to work on this?

@not-napoleon
Copy link
Member Author

@GrayFox1 This is a pretty tricky and involved refactoring that touches a lot of the code. I would not suggest this as a starting point for contributing to Elasticsearch. If you're interested in getting some experience contributing to projects, might I suggest taking a look at our good first issue list: https://github.com/elastic/elasticsearch/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22

@javanna javanna removed :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team labels Feb 10, 2023
@elasticsearchmachine
Copy link
Collaborator

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

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) >tech debt
Projects
None yet
Development

No branches or pull requests

9 participants