Skip to content

Commit 9f24510

Browse files
committed
Add test
1 parent eafcccd commit 9f24510

File tree

9 files changed

+78
-621
lines changed

9 files changed

+78
-621
lines changed

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/aggregation/RateDoubleAggregator.java

+11-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/aggregation/RateFloatAggregator.java

+11-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/aggregation/RateIntAggregator.java

+11-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/aggregation/RateLongAggregator.java

+11-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/X-RateAggregator.java.st

+11-18
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,7 @@ public class Rate$Type$Aggregator {
7474
current.combineState(currentGroupId, otherState, otherGroupId);
7575
}
7676

77-
public static Block evaluateFinal(
78-
$Type$RateGroupingState state,
79-
IntVector selected,
80-
GroupingAggregatorEvaluationContext evalContext
81-
) {
77+
public static Block evaluateFinal($Type$RateGroupingState state, IntVector selected, GroupingAggregatorEvaluationContext evalContext) {
8278
return state.evaluateFinal(selected, evalContext);
8379
}
8480

@@ -357,17 +353,18 @@ public class Rate$Type$Aggregator {
357353
final double slope = (lastValue - firstValue) / sampleTS;
358354
double startGap = firstTS - rangeStart;
359355
if (startGap > 0) {
360-
if (startGap > averageSampleInterval * 1.1) {
361-
startGap = averageSampleInterval / 2.0; // limit to half of the average of the sample interval
362-
}
363-
firstValue = Math.max(0.0, firstValue - startGap * slope);
356+
if (startGap > averageSampleInterval * 1.1) {
357+
// limit to half of the average sample interval if samples are far from the boundary
358+
startGap = averageSampleInterval / 2.0;
359+
}
360+
firstValue = Math.max(0.0, firstValue - startGap * slope);
364361
}
365362
double endGap = rangeEnd - lastTS;
366363
if (endGap > 0) {
367-
if (endGap > averageSampleInterval * 1.1) {
368-
endGap = averageSampleInterval / 2.0;
369-
}
370-
lastValue = lastValue + endGap * slope;
364+
if (endGap > averageSampleInterval * 1.1) {
365+
endGap = averageSampleInterval / 2.0;
366+
}
367+
lastValue = lastValue + endGap * slope;
371368
}
372369
return (lastValue - firstValue) * unitInMillis / (rangeEnd - rangeStart);
373370
}
@@ -385,11 +382,7 @@ public class Rate$Type$Aggregator {
385382
int len = state.entries();
386383
final double rate;
387384
if (evalContext instanceof TimeSeriesGroupingAggregatorEvaluationContext tsContext) {
388-
rate = computeRate(
389-
state,
390-
tsContext.rangeStartInMillis(groupId),
391-
tsContext.rangeEndInMillis(groupId),
392-
unitInMillis);
385+
rate = computeRate(state, tsContext.rangeStartInMillis(groupId), tsContext.rangeEndInMillis(groupId), unitInMillis);
393386
} else {
394387
rate = computeRate(state, unitInMillis);
395388
}

0 commit comments

Comments
 (0)