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

Function aggregateGroup

query/groupby.go:130–155  ·  view source on GitHub ↗
(grp *groupResult, child *SubGraph)

Source from the content-addressed store, hash-verified

128}
129
130func aggregateGroup(grp *groupResult, child *SubGraph) (types.Val, error) {
131 ag := aggregator{
132 name: child.SrcFunc.Name,
133 }
134 for _, uid := range grp.uids {
135 idx := sort.Search(len(child.SrcUIDs.Uids), func(i int) bool {
136 return child.SrcUIDs.Uids[i] >= uid
137 })
138 if idx == len(child.SrcUIDs.Uids) || child.SrcUIDs.Uids[idx] != uid {
139 continue
140 }
141
142 if len(child.valueMatrix[idx].Values) == 0 {
143 continue
144 }
145 v := child.valueMatrix[idx].Values[0]
146 val, err := convertWithBestEffort(v, child.Attr)
147 if err != nil {
148 continue
149 }
150 if err := ag.Apply(val); err != nil {
151 return types.Val{}, err
152 }
153 }
154 return ag.Value()
155}
156
157// formGroup creates all possible groups with the list of uids that belong to that
158// group.

Callers 1

aggregateChildMethod · 0.85

Calls 4

ApplyMethod · 0.95
ValueMethod · 0.95
convertWithBestEffortFunction · 0.85
SearchMethod · 0.65

Tested by

no test coverage detected