processUnary handles the unary operands like u-, log, exp, since, floor, ceil
(mNode *mathTree)
| 143 | // processUnary handles the unary operands like |
| 144 | // u-, log, exp, since, floor, ceil |
| 145 | func 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. |