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

Function processUnary

query/math.go:145–178  ·  view source on GitHub ↗

processUnary handles the unary operands like u-, log, exp, since, floor, ceil

(mNode *mathTree)

Source from the content-addressed store, hash-verified

143// processUnary handles the unary operands like
144// u-, log, exp, since, floor, ceil
145func processUnary(mNode *mathTree) error {
146 srcMap := mNode.Child[0].Val
147 destMap := types.NewShardedMap()
148 aggName := mNode.Fn
149 ch := mNode.Child[0]
150 ag := aggregator{
151 name: aggName,
152 }
153 if ch.Const.Value != nil {
154 // Use the constant value that was supplied.
155 err := ag.ApplyVal(ch.Const)
156 if err != nil {
157 return err
158 }
159 mNode.Const, err = ag.Value()
160 return err
161 }
162
163 srcMap.Iterate(func(k uint64, val types.Val) error {
164 err := ag.ApplyVal(val)
165 if err != nil {
166 return err
167 }
168 value, err := ag.Value()
169 if err != nil {
170 return err
171 }
172 destMap.Set(k, value)
173 return nil
174 })
175 mNode.Val = destMap
176 return nil
177
178}
179
180// processBinaryBoolean handles the binary operands which
181// return a boolean value.

Callers 2

evalMathTreeFunction · 0.85
TestProcessUnaryFunction · 0.85

Calls 5

ApplyValMethod · 0.95
ValueMethod · 0.95
SetMethod · 0.95
NewShardedMapFunction · 0.92
IterateMethod · 0.45

Tested by 1

TestProcessUnaryFunction · 0.68