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

Method merge

query/outputnode.go:886–918  ·  view source on GitHub ↗
(parent, child []fastJsonNode)

Source from the content-addressed store, hash-verified

884}
885
886func (enc *encoder) merge(parent, child []fastJsonNode) ([]fastJsonNode, error) {
887 if len(parent) == 0 {
888 return child, nil
889 }
890
891 // Here we merge two slices of maps.
892 mergedList := make([]fastJsonNode, 0)
893 cnt := 0
894 for _, pa := range parent {
895 for _, ca := range child {
896 paCopy, paNodeCount := enc.copyFastJsonList(pa)
897 caCopy, caNodeCount := enc.copyFastJsonList(ca)
898
899 cnt += paNodeCount + caNodeCount
900 if cnt > x.Config.LimitNormalizeNode {
901 return nil, errors.Errorf(
902 "Couldn't evaluate @normalize directive - too many results")
903 }
904
905 if paCopy == nil {
906 paCopy = caCopy
907 } else {
908 temp := paCopy
909 for temp.next != nil {
910 temp = temp.next
911 }
912 temp.next = caCopy
913 }
914 mergedList = append(mergedList, paCopy)
915 }
916 }
917 return mergedList, nil
918}
919
920// normalize returns all attributes of fj and its children (if any).
921func (enc *encoder) normalize(fj fastJsonNode) ([]fastJsonNode, error) {

Callers 1

normalizeMethod · 0.95

Calls 2

copyFastJsonListMethod · 0.95
ErrorfMethod · 0.45

Tested by

no test coverage detected