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

Method addChildren

query/outputnode.go:363–389  ·  view source on GitHub ↗

addChildren appends attrs to existing fj's attrs.

(fj, head fastJsonNode)

Source from the content-addressed store, hash-verified

361
362// addChildren appends attrs to existing fj's attrs.
363func (enc *encoder) addChildren(fj, head fastJsonNode) {
364 if fj.child == nil {
365 fj.child = head
366 return
367 }
368
369 tail := head
370 for tail.next != nil {
371 tail = tail.next
372 }
373
374 // We're inserting the node in between. This would need to be fixed later via fixOrder.
375 // Single child additions:
376 // Child 1
377 // Child 2 -> 1
378 // Child 3 -> 2 -> 1
379 // Child 4 -> 3 -> 2 -> 1
380 // Child 5 -> 4 -> 3 -> 2 -> 1
381 //
382 // If child has siblings, then it could look like this.
383 // addChildren(13 -> 12 -> 11)
384 // Child 5 -> 4 -> 3 -> 2 -> 1
385 //
386 // What we want:
387 // 13 -> 12 -> 11 -> 5 -> 4 -> 3 -> 2 -> 1
388 fj.child, tail.next = head, fj.child
389}
390
391// fixOrder would recursively fix the ordering issue caused by addChildren, across the entire
392// tree.

Callers 8

appendAttrsMethod · 0.95
AddListValueMethod · 0.95
AddMapChildMethod · 0.95
AddListChildMethod · 0.95
SetUIDMethod · 0.95
processNodeUidsFunction · 0.80
preTraverseMethod · 0.80
TestChildrenOrderFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestChildrenOrderFunction · 0.64