-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Document aggregation code generation #121644
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
Changes from 1 commit
b3a89d7
f0e3938
e9087c5
4ec362f
10722e1
71fa03b
52b7e2e
587c800
c19125f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -105,7 +105,53 @@ | |||||
* | ||||||
* <h3>Creating aggregators for your function</h3> | ||||||
* <p> | ||||||
* Aggregators contain the core logic of your aggregation. That is, how to combine values, what to store, how to process data, etc. | ||||||
* Aggregators contain the core logic of how to combine values, what to store, how to process data, etc. | ||||||
* Currently, we rely on code generation (per aggregation per type) in order to implement such functionality. | ||||||
* This approach was picked for performance reasons (namely to avoid virtual method calls and boxing types). | ||||||
* 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"). | ||||||
ivancea marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
* Annotate it with {@link org.elasticsearch.compute.ann.Aggregator} and {@link org.elasticsearch.compute.ann.GroupingAggregator} | ||||||
* The first one is responsible for an entire data set aggregation, while the second one is responsible for grouping within buckets. | ||||||
* </p> | ||||||
* <p> | ||||||
* Before you start implementing it, please note that: | ||||||
* <ul> | ||||||
* <li>All methods must be public static</li> | ||||||
* <li> | ||||||
* combine, combineStates, combineIntermediate, evaluateFinal methods (see below) could be omitted and generated automatically | ||||||
* 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> | ||||||
|
||||||
* </ul> | ||||||
* </p> | ||||||
* <p> | ||||||
* Aggregation expects: | ||||||
* <ul> | ||||||
* <li>type SS (a mutable state used to accumulate result of the aggregation) to be public, not inner and implements {@link org.elasticsearch.compute.aggregation.AggregatorState}</li> | ||||||
* <li>type I (input to your aggregation function), usually primitive types and {@link org.apache.lucene.util.BytesRef}</li> | ||||||
* <li>{@code SS init()} or {@code SS initSingle()} returns empty initialized aggregation state</li> | ||||||
* <li>{@code void combine(SS state, I input)} or {@code SS combine(SS state, I input)} adds input entry to the aggregation state</li> | ||||||
* <li>{@code void combineIntermediate(SS state, intermediate states)} adds serialized aggregation state to the current aggregation state (used to combine results across different nodes)</li> | ||||||
* <li>{@code Block evaluateFinal(SS state, BigArrays? DriverContext?)} converts the inner state of the aggregation to the result column</li> | ||||||
* </ul> | ||||||
* </p> | ||||||
* <p> | ||||||
* 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> | ||||||
|
* <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.
Uh oh!
There was an error while loading. Please reload this page.