promql/functions.go
func funcPredictLinear(vals []Value, args Expressions, enh *EvalNodeHelper) Vector {
	mat := vals[0].(Matrix)
	duration := vals[1].(Vector)[0].V

	for _, samples := range mat {
		// No sense in trying to predict anything without at least two points.
		// Drop this Vector element.
		if len(samples.Points) < 2 {
			continue
		}
		slope, intercept := linearRegression(samples.Points, enh.ts)

		enh.out = append(enh.out, Sample{
			Point: Point{V: slope*duration + intercept},
		})
	}
	return enh.out
}
func funcPredictLinear(vals []Value, args Expressions, enh *EvalNodeHelper) Vector {
	mat := vals[0].(Matrix)
	duration := vals[1].(Vector)[0].V

	for _, samples := range mat {
		// No sense in trying to predict anything without at least two points.
		// Drop this Vector element.
		if len(samples.Points) < 2 {
			continue
		}
		slope, intercept := linearRegression(samples.Points, enh.ts)

		enh.out = append(enh.out, Sample{
			Point: Point{V: slope*duration + intercept},
		})
	}
	return enh.out
}
func funcPredictLinear ( vals [ ] Value , args Expressions , enh * EvalNodeHelper ) Vector { mat := vals [ 0 ] . ( Matrix ) duration := vals [ 1 ] . ( Vector ) [ 0 ] . V for _ , samples := range mat { // No sense in trying to predict anything without at least two points. // Drop this Vector element. if len ( samples . Points ) < 2 { continue } slope , intercept := linearRegression ( samples . Points , enh . ts ) enh . out = append ( enh . out , Sample { Point : Point { V : slope * duration + intercept } , } ) } return enh . out }
// === predict_linear(node ValueTypeMatrix, k ValueTypeScalar) Vector ===
=== predict_linear ( node ValueTypeMatrix k ValueTypeScalar ) Vector ===