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

Method handleCountUIDNodes

query/outputnode.go:1067–1094  ·  view source on GitHub ↗
(enc *encoder, n fastJsonNode, count int)

Source from the content-addressed store, hash-verified

1065}
1066
1067func (sg *SubGraph) handleCountUIDNodes(enc *encoder, n fastJsonNode, count int) (bool, error) {
1068 addedNewChild := false
1069 fieldName := sg.fieldName()
1070 sgFieldID := enc.idForAttr(fieldName)
1071 for _, child := range sg.Children {
1072 uidCount := child.Attr == "uid" && child.Params.DoCount && child.IsInternal()
1073 normWithoutAlias := child.Params.Alias == "" && child.Params.Normalize
1074 if uidCount && !normWithoutAlias {
1075 addedNewChild = true
1076
1077 c := types.ValueForType(types.IntID)
1078 c.Value = int64(count)
1079
1080 field := child.Params.Alias
1081 if field == "" {
1082 field = "count"
1083 }
1084
1085 fjChild := enc.newNode(sgFieldID)
1086 if err := enc.AddValue(fjChild, enc.idForAttr(field), c); err != nil {
1087 return false, err
1088 }
1089 enc.AddListChild(n, fjChild)
1090 }
1091 }
1092
1093 return addedNewChild, nil
1094}
1095
1096func processNodeUids(fj fastJsonNode, enc *encoder, sg *SubGraph) error {
1097 if sg.Params.IsEmpty {

Callers 2

processNodeUidsFunction · 0.80
preTraverseMethod · 0.80

Calls 7

fieldNameMethod · 0.95
ValueForTypeFunction · 0.92
idForAttrMethod · 0.80
IsInternalMethod · 0.80
newNodeMethod · 0.80
AddValueMethod · 0.80
AddListChildMethod · 0.80

Tested by

no test coverage detected