(attr string, value types.Val, uid uint64)
| 102 | } |
| 103 | |
| 104 | func (d *dedup) addValue(attr string, value types.Val, uid uint64) { |
| 105 | cur := d.getGroup(attr) |
| 106 | // Create the string key. |
| 107 | var strKey string |
| 108 | if value.Tid == types.UidID { |
| 109 | strKey = strconv.FormatUint(value.Value.(uint64), 10) |
| 110 | } else { |
| 111 | valC := types.Val{Tid: types.StringID, Value: ""} |
| 112 | err := types.Marshal(value, &valC) |
| 113 | if err != nil { |
| 114 | return |
| 115 | } |
| 116 | strKey = valC.Value.(string) |
| 117 | } |
| 118 | |
| 119 | if _, ok := cur.elements[strKey]; !ok { |
| 120 | // If this is the first element of the group. |
| 121 | cur.elements[strKey] = groupElements{ |
| 122 | key: value, |
| 123 | entities: &pb.List{Uids: []uint64{}}, |
| 124 | } |
| 125 | } |
| 126 | curEntity := cur.elements[strKey].entities |
| 127 | curEntity.Uids = append(curEntity.Uids, uid) |
| 128 | } |
| 129 | |
| 130 | func aggregateGroup(grp *groupResult, child *SubGraph) (types.Val, error) { |
| 131 | ag := aggregator{ |
no test coverage detected