(ul *pb.List)
| 193 | } |
| 194 | |
| 195 | func (sg *SubGraph) formResult(ul *pb.List) (*groupResults, error) { |
| 196 | var dedupMap dedup |
| 197 | res := new(groupResults) |
| 198 | |
| 199 | for _, child := range sg.Children { |
| 200 | if !child.Params.IgnoreResult { |
| 201 | continue |
| 202 | } |
| 203 | |
| 204 | attr := child.Params.Alias |
| 205 | if attr == "" { |
| 206 | attr = child.Attr |
| 207 | } |
| 208 | if len(child.DestUIDs.GetUids()) > 0 { |
| 209 | // It's a UID node. |
| 210 | for i := range child.uidMatrix { |
| 211 | srcUid := child.SrcUIDs.Uids[i] |
| 212 | // Ignore uids which are not part of srcUid. |
| 213 | if algo.IndexOf(ul, srcUid) < 0 { |
| 214 | continue |
| 215 | } |
| 216 | |
| 217 | ul := child.uidMatrix[i] |
| 218 | for _, uid := range ul.GetUids() { |
| 219 | dedupMap.addValue(attr, types.Val{Tid: types.UidID, Value: uid}, srcUid) |
| 220 | } |
| 221 | } |
| 222 | } else { |
| 223 | // It's a value node. |
| 224 | for i, v := range child.valueMatrix { |
| 225 | srcUid := child.SrcUIDs.Uids[i] |
| 226 | if len(v.Values) == 0 || algo.IndexOf(ul, srcUid) < 0 { |
| 227 | continue |
| 228 | } |
| 229 | val, err := convertTo(v.Values[0]) |
| 230 | if err != nil { |
| 231 | continue |
| 232 | } |
| 233 | dedupMap.addValue(attr, val, srcUid) |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | // Create all the groups here. |
| 239 | res.formGroups(dedupMap, &pb.List{}, []groupPair{}) |
| 240 | |
| 241 | // Go over the groups and aggregate the values. |
| 242 | for _, child := range sg.Children { |
| 243 | if child.Params.IgnoreResult { |
| 244 | continue |
| 245 | } |
| 246 | // This is a aggregation node. |
| 247 | for _, grp := range res.group { |
| 248 | err := grp.aggregateChild(child) |
| 249 | if err != nil && err != ErrEmptyVal { |
| 250 | return res, err |
| 251 | } |
| 252 | } |
no test coverage detected