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

Function processBinaryBoolean

query/math.go:183–208  ·  view source on GitHub ↗

processBinaryBoolean handles the binary operands which return a boolean value. All the inequality operators (<, >, <=, >=, !=, ==)

(mNode *mathTree)

Source from the content-addressed store, hash-verified

181// return a boolean value.
182// All the inequality operators (<, >, <=, >=, !=, ==)
183func processBinaryBoolean(mNode *mathTree) error {
184 srcMap := mNode.Child[0].Val
185 destMap := types.NewShardedMap()
186 aggName := mNode.Fn
187
188 ch := mNode.Child[1]
189 curMap := ch.Val
190 srcMap.Iterate(func(k uint64, val types.Val) error {
191 curVal, _ := curMap.Get(k)
192 if ch.Const.Value != nil {
193 // Use the constant value that was supplied.
194 curVal = ch.Const
195 }
196 res, err := compareValues(aggName, val, curVal)
197 if err != nil {
198 return errors.Wrapf(err, "Wrong values in comparison function.")
199 }
200 destMap.Set(k, types.Val{
201 Tid: types.BoolID,
202 Value: res,
203 })
204 return nil
205 })
206 mNode.Val = destMap
207 return nil
208}
209
210// processTernary handles the ternary operand cond()
211func processTernary(mNode *mathTree) error {

Callers 3

evalMathTreeFunction · 0.85
TestProcessBinaryBooleanFunction · 0.85
TestBigFloatMathsBooleanFunction · 0.85

Calls 5

SetMethod · 0.95
NewShardedMapFunction · 0.92
compareValuesFunction · 0.85
GetMethod · 0.65
IterateMethod · 0.45

Tested by 2

TestProcessBinaryBooleanFunction · 0.68
TestBigFloatMathsBooleanFunction · 0.68