-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Add rate aggregation function #106703
Add rate aggregation function #106703
Conversation
ab2c377
to
c24b30f
Compare
e4071c3
to
576ddfe
Compare
Pinging @elastic/es-analytical-engine (Team:Analytics) |
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
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.
small suggestion to keep idiomatic gradle syntaix in build scripts
Co-authored-by: Rene Groeschke <[email protected]>
Co-authored-by: Rene Groeschke <[email protected]>
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 @dnhatn! I've scrolled through this change and I think this looks in the direction of how rate would be implemented in compute engine.
@@ -261,29 +261,20 @@ void consume() throws IOException { | |||
} | |||
} else { | |||
int previousTsidOrd = leaf.timeSeriesHashOrd; | |||
boolean breakOnNextTsidChange = false; |
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 this will be fixed when the other pr you opened is merged?
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.
Yes, I have merged this fix in another PR.
The magic that makes it so you don't have to test it all. Neat. |
@IntermediateState(name = "value", type = "DOUBLE_BLOCK"), | ||
@IntermediateState(name = "compensation", type = "DOUBLE") } | ||
) | ||
public class RateDoubleAggregator { |
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'm somehow totally unsurpised we've started to use one code generation tool to kick off another code generation tool.
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'm somehow totally unsurpised we've started to use one code generation tool to kick off another code generation tool.
Yeah, I was inspired by your values function and I found it's less error-prone. Do you think we should convert existing functions and tests to use templates as well?
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.
Maybe the next time we find something interesting to do there. I'm not sure it's worth doing without some kind of excuse.
...mpute/src/main/generated-src/org/elasticsearch/compute/aggregation/RateDoubleAggregator.java
Outdated
Show resolved
Hide resolved
...mpute/src/main/generated-src/org/elasticsearch/compute/aggregation/RateDoubleAggregator.java
Show resolved
Hide resolved
|
||
private int dv(int v0, int v1) { | ||
return v0 > v1 ? v1 : v1 - v0; | ||
} |
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'm curious if we'd be better off assuming that a reset is a wrap instead. I'm sure there's literature on the topic. It can wait for later though.
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.
++
value = { | ||
@IntermediateState(name = "timestamp", type = "LONG_BLOCK"), | ||
@IntermediateState(name = "value", type = "INT_BLOCK"), | ||
@IntermediateState(name = "compensation", type = "DOUBLE") } |
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.
Do we need a compensation
for int
and long
rates? It looks a little like a Kahan sum we shouldn't need that for int
and long
.
I was going to ask if we need a rate
flavor for int
and long
at all but I think it's right and proper to have one, at least for long
. Lots of stuff is going to read it's values as long
. And if we can avoid having compensation, all the better.
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.
Do we need a compensation for int and long rates?
I might be missing something here. But the compensation
is the sum of all reset values within this group's range. Perhaps, the term compensation
is confusing? Should we consider renaming it to totalReset
?
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.
Yeah! Let's rename it so I don't think it's kahan.
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've renamed compensation
to reset
in 89880d4.
@breskeby @martijnvg @nik9000 Thanks for reviews. |
We should track the memory usage of the individual state in the rate aggregation function. Relates #106703
Add support for ordinal grouping in the rate aggregation function. Relates #106703
This PR introduces a rate aggregation function to ESQL, with two main changes:
I have left out some parts of this PR to minimize its PR to make reviewing easier. I plan to follow-up these items:
Relates #106415