-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Document aggregation code generation #121644
base: main
Are you sure you want to change the base?
Document aggregation code generation #121644
Conversation
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.
nice
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.
Added some remarks that could be worth adding. Maybe.
It looks good for now, thanks for improving this 🙏
* As a result we could not rely on interfaces implementation and generics. | ||
* </p> | ||
* <p> | ||
* In order to implement aggregation logic create your class (typically named "${FunctionName}${Type}Aggregator"). |
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.
The aggregator name format must be followed for it to work.
The AggregateMapper discovers it based on the name, with reflection, given the Function class name + the type:
Lines 256 to 264 in 1378b59
private static String determineAggName(Class<?> clazz, String type, String extra, boolean grouping) { | |
return "org.elasticsearch.compute.aggregation." | |
+ (clazz.getSimpleName().startsWith("Spatial") ? "spatial." : "") | |
+ clazz.getSimpleName() | |
+ type | |
+ extra | |
+ (grouping ? "Grouping" : "") | |
+ "AggregatorFunction"; | |
} |
So maybe we should rephrase this a bit? If the name has something unexpected, the AggregateMapper must be changed accordingly. Or maybe this isn't that important here anyway
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.
Yet more stuff not to like about AggregateMapper
....
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.
After some thinking about this, and some sync with Ievgen, I'll try to remove AggMapper now. I think we can safely move the reflection to a Supplier method without "much" change. Let's see!
* when both input type I and mutable accumulator state SS and GS are primitive (DOUBLE, INT). | ||
* </li> | ||
* <li>TBD explain {@code IntermediateState}</li> | ||
* <li>TBD explain special internal state `seen`</li> |
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.
With the warnings feature, there's also the "failed" state. Identical to seen. Never used in main though, only here: https://github.com/elastic/elasticsearch/pull/116170/files#diff-8a408014887a6dc87eed1f71346536fc77636245d5411714b6ba2cf265812538R18
Maybe worth mentioning, with the warnExceptions attribute
* Grouping aggregation expects: | ||
* <ul> | ||
* <li>type GS (a mutable state used to accumulate result of the grouping aggregation) to be public, not inner and implements {@link org.elasticsearch.compute.aggregation.GroupingAggregatorState}</li> | ||
* <li>type I (input to your aggregation function), usually primitive types and {@link org.apache.lucene.util.BytesRef}</li> |
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 think you mean:
* <li>type I (input to your aggregation function), usually primitive types and {@link org.apache.lucene.util.BytesRef}</li> | |
* <li>type T (input to your aggregation function), usually primitive types and {@link org.apache.lucene.util.BytesRef}</li> |
From the following comments.
Pinging @elastic/es-analytical-engine (Team:Analytics) |
Update code generation documentation with Aggs method signatures expected to be seen/used by the generated code