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

Removed ValuesSourceRegistry.registerAny() #55747

Merged
merged 6 commits into from
Apr 27, 2020

Conversation

csoulios
Copy link
Contributor

ValuesSourcesRegistry implemented method registerAny() that would automatically register a default aggregator implementation for any ValuesSourceType. Although, this was a very powerful feature, it was not very flexible, as there was no way to override the default aggregator for one or more ValuesSourceTypes.

The aggregations that used the registerAny() method so far were: missing, value_count and cardinality.

In this PR we remove the registerAny() method and replace it with explicitly registering all ValuesSourceType with their aggregator. This means that all CoreValuesSourceType classes are registered explicitly with their aggregators (for missing, value_count and cardinality).

For the sub-classes of ValuesSourceType that live in plugins, registering their aggregator is delegated to the plugins. This allows plugins to register their own implementation of common aggregations.

All ValuesSourceTypes must be registered
explicitly
@elasticmachine
Copy link
Collaborator

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

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, thanks for doing this! Now that we don't need to support ANY, we should have a follow-up PR to get rid of the lambdas in ValuesSourceRegistry. Let me know if you want to do that, otherwise I'll get to it as soon as I can.

Copy link
Contributor

@imotov imotov left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -288,4 +291,6 @@ public String value() {
return name().toLowerCase(Locale.ROOT);
}

/** List containing all members of the enumeration. */
public static List<ValuesSourceType> ALL = Arrays.asList(CoreValuesSourceType.values());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think ALL might be a bit confusing here. I wonder if renaming it into ALL_CORE or using Arrays.asList(CoreValuesSourceType.values()) instead of the constant will better demonstrate the actual scope here for future readers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To me it seemed clear that CoreValuesSourceType.ALL is about all core VST. I renamed it to CoreValuesSourceType.ALL_CORE hoping that this can't be misunderstood.

@csoulios
Copy link
Contributor Author

@not-napoleon please check commit 2c709d3

Is that ok? Did I miss anything?

@csoulios
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/bwc

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.

We can simplify the registry even more by just using a map of maps. Other than that, looks good. Thanks for doing this!

@@ -42,99 +41,67 @@
*/
public class ValuesSourceRegistry {
public static class Builder {
private Map<String, List<Map.Entry<Predicate<ValuesSourceType>, AggregatorSupplier>>> aggregatorRegistry = new HashMap<>();
private Map<String, List<Map.Entry<ValuesSourceType, AggregatorSupplier>>> aggregatorRegistry = new HashMap<>();
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't need to be a List now. We can just make it Map<String, Map<ValuesSourceType, AggregatorSupplier>>.  The list was only necessary because lambdas make bad hash keys.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can I do it later in a separate PR? This will really mess me up if it is done in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem @imotov if you are both ok with this, I will merge this PR and you can change this List to Map later.

@csoulios csoulios merged commit ee9b492 into elastic:master Apr 27, 2020
@csoulios csoulios deleted the vsregistry-remove-any branch April 27, 2020 21:47
csoulios added a commit that referenced this pull request Apr 28, 2020
* Backports #55747 to 7.x
* All ValuesSourceTypes must be registered
explicitly
* Removed lambdas in ValuesSourceRegistry
imotov added a commit to imotov/elasticsearch that referenced this pull request May 4, 2020
imotov added a commit that referenced this pull request May 5, 2020
imotov added a commit to imotov/elasticsearch that referenced this pull request May 5, 2020
imotov added a commit that referenced this pull request May 5, 2020
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.

6 participants