MCPcopy Create free account
hub / github.com/facebook/time / prepareExpression

Function prepareExpression

fbclock/daemon/math.go:203–220  ·  view source on GitHub ↗
(exprStr string)

Source from the content-addressed store, hash-verified

201}
202
203func prepareExpression(exprStr string) (expr *govaluate.EvaluableExpression, err error) {
204 defer func() {
205 if r := recover(); r != nil {
206 expr = nil
207 err = fmt.Errorf("invalid expression %q: %v", exprStr, r)
208 }
209 }()
210 expr, err = govaluate.NewEvaluableExpressionWithFunctions(exprStr, functions)
211 if err != nil {
212 return nil, err
213 }
214 for _, v := range expr.Vars() {
215 if !isSupportedVar(v) {
216 return nil, fmt.Errorf("unsupported variable %q", v)
217 }
218 }
219 return expr, nil
220}
221
222func prepareMathParameters(lastN []*DataPoint) map[string][]float64 {
223 size := len(lastN)

Calls 1

isSupportedVarFunction · 0.70

Used in the wild real call sites across dependent graphs

searching dependent graphs…