Skip to content

Commit f09fd79

Browse files
committed
fixup
1 parent f7f7d1a commit f09fd79

File tree

6 files changed

+103
-0
lines changed

6 files changed

+103
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
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/DerivIntGroupingAggregatorFunction.java

Lines changed: 6 additions & 0 deletions
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/DerivLongGroupingAggregatorFunction.java

Lines changed: 6 additions & 0 deletions
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/SimpleLinearRegressionWithTimeseries.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
17
package org.elasticsearch.compute.aggregation;
28

39
class SimpleLinearRegressionWithTimeseries {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
package org.elasticsearch.compute.aggregation;
10+
11+
/*
12+
* Licensed to the Apache Software Foundation (ASF) under one
13+
* or more contributor license agreements. See the NOTICE file
14+
* distributed with this work for additional information
15+
* regarding copyright ownership. The ASF licenses this file
16+
* to you under the Apache License, Version 2.0 (the
17+
* "License"); you may not use this file except in compliance
18+
* with the License. You may obtain a copy of the License at
19+
*
20+
* http://www.apache.org/licenses/LICENSE-2.0
21+
*
22+
* Unless required by applicable law or agreed to in writing,
23+
* software distributed under the License is distributed on an
24+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
25+
* KIND, either express or implied. See the License for the
26+
* specific language governing permissions and limitations
27+
* under the License.
28+
*/
29+
30+
31+
class SimpleLinearRegressionWithTimeseries {
32+
long count;
33+
double sumVal;
34+
long sumTs;
35+
double sumTsVal;
36+
long sumTsSq;
37+
38+
SimpleLinearRegressionWithTimeseries() {
39+
this.count = 0;
40+
this.sumVal = 0.0;
41+
this.sumTs = 0;
42+
this.sumTsVal = 0.0;
43+
this.sumTsSq = 0;
44+
}
45+
46+
void add(long ts, double val) {
47+
count++;
48+
sumVal += val;
49+
sumTs += ts;
50+
sumTsVal += ts * val;
51+
sumTsSq += ts * ts;
52+
}
53+
54+
double slope() {
55+
if (count <= 1) {
56+
return Double.NaN;
57+
}
58+
double numerator = count * sumTsVal - sumTs * sumVal;
59+
double denominator = count * sumTsSq - sumTs * sumTs;
60+
if (denominator == 0) {
61+
return Double.NaN;
62+
}
63+
return numerator / denominator;
64+
}
65+
66+
double intercept() {
67+
if (count == 0) {
68+
return 0.0; // or handle as needed
69+
}
70+
return (sumVal - slope() * sumTs) / count;
71+
}
72+
73+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
17
package org.elasticsearch.compute.aggregation;
28

39
import org.elasticsearch.common.util.ObjectArray;

0 commit comments

Comments
 (0)