MCPcopy
hub / github.com/dgraph-io/dgraph / addValue

Method addValue

query/groupby.go:104–128  ·  view source on GitHub ↗
(attr string, value types.Val, uid uint64)

Source from the content-addressed store, hash-verified

102}
103
104func (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
130func aggregateGroup(grp *groupResult, child *SubGraph) (types.Val, error) {
131 ag := aggregator{

Callers 2

formResultMethod · 0.95
fillGroupedVarsMethod · 0.95

Calls 2

getGroupMethod · 0.95
MarshalFunction · 0.92

Tested by

no test coverage detected