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

Method addGroupby

query/outputnode.go:1014–1038  ·  view source on GitHub ↗
(enc *encoder, fj fastJsonNode,
	res *groupResults, fname string)

Source from the content-addressed store, hash-verified

1012}
1013
1014func (sg *SubGraph) addGroupby(enc *encoder, fj fastJsonNode,
1015 res *groupResults, fname string) error {
1016
1017 // Don't add empty groupby
1018 if len(res.group) == 0 {
1019 return nil
1020 }
1021 g := enc.newNode(enc.idForAttr(fname))
1022 for _, grp := range res.group {
1023 uc := enc.newNode(enc.idForAttr("@groupby"))
1024 for _, it := range grp.keys {
1025 if err := enc.AddValue(uc, enc.idForAttr(it.attr), it.key); err != nil {
1026 return err
1027 }
1028 }
1029 for _, it := range grp.aggregates {
1030 if err := enc.AddValue(uc, enc.idForAttr(it.attr), it.key); err != nil {
1031 return err
1032 }
1033 }
1034 enc.AddListChild(g, uc)
1035 }
1036 enc.AddListChild(fj, g)
1037 return nil
1038}
1039
1040func (sg *SubGraph) addAggregations(enc *encoder, fj fastJsonNode) error {
1041 for _, child := range sg.Children {

Callers 2

processNodeUidsFunction · 0.80
preTraverseMethod · 0.80

Calls 4

newNodeMethod · 0.80
idForAttrMethod · 0.80
AddValueMethod · 0.80
AddListChildMethod · 0.80

Tested by

no test coverage detected