MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / evalMathTree

Function evalMathTree

query/math.go:250–304  ·  view source on GitHub ↗
(mNode *mathTree)

Source from the content-addressed store, hash-verified

248}
249
250func evalMathTree(mNode *mathTree) error {
251 if mNode.Const.Value != nil {
252 return nil
253 }
254 if mNode.Var != "" {
255 if mNode.Val.IsEmpty() {
256 glog.V(2).Infof("Variable %v not yet populated or missing.", mNode.Var)
257 }
258 // This is a leaf node whose value is already populated. So return.
259 return nil
260 }
261
262 for _, child := range mNode.Child {
263 // Process the child nodes first.
264 if err := evalMathTree(child); err != nil {
265 return err
266 }
267 }
268
269 aggName := mNode.Fn
270
271 if isUnary(aggName) {
272 if len(mNode.Child) != 1 {
273 return errors.Errorf("Function %v expects 1 argument. But got: %v", aggName,
274 len(mNode.Child))
275 }
276 return processUnary(mNode)
277 }
278
279 if isBinary(aggName) {
280 if len(mNode.Child) != 2 {
281 return errors.Errorf("Function %v expects 2 argument. But got: %v", aggName,
282 len(mNode.Child))
283 }
284 return processBinary(mNode)
285 }
286
287 if isBinaryBoolean(aggName) {
288 if len(mNode.Child) != 2 {
289 return errors.Errorf("Function %v expects 2 argument. But got: %v", aggName,
290 len(mNode.Child))
291 }
292 return processBinaryBoolean(mNode)
293 }
294
295 if isTernary(aggName) {
296 if len(mNode.Child) != 3 {
297 return errors.Errorf("Function %v expects 3 argument. But got: %v", aggName,
298 len(mNode.Child))
299 }
300 return processTernary(mNode)
301 }
302
303 return errors.Errorf("Unhandled Math operator: %v", aggName)
304}

Callers 2

valueVarAggregationMethod · 0.85
TestVectorFunction · 0.85

Calls 11

processUnaryFunction · 0.85
isBinaryFunction · 0.85
processBinaryFunction · 0.85
isBinaryBooleanFunction · 0.85
processBinaryBooleanFunction · 0.85
processTernaryFunction · 0.85
InfofMethod · 0.80
isUnaryFunction · 0.70
isTernaryFunction · 0.70
IsEmptyMethod · 0.45
ErrorfMethod · 0.45

Tested by 1

TestVectorFunction · 0.68