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

Method attachFacets

query/outputnode.go:745–773  ·  view source on GitHub ↗
(fj fastJsonNode, fieldName string, isList bool,
	fList []*api.Facet, facetIdx int)

Source from the content-addressed store, hash-verified

743}
744
745func (enc *encoder) attachFacets(fj fastJsonNode, fieldName string, isList bool,
746 fList []*api.Facet, facetIdx int) error {
747
748 idxFieldID := enc.idForAttr(strconv.Itoa(facetIdx))
749 for _, f := range fList {
750 fName := facetName(fieldName, f)
751 fVal, err := facets.ValFor(f)
752 if err != nil {
753 return err
754 }
755
756 if !isList {
757 if err := enc.AddValue(fj, enc.idForAttr(fName), fVal); err != nil {
758 return err
759 }
760 } else {
761 facetNode := enc.newNode(enc.idForAttr(fName))
762 err := enc.AddValue(facetNode, idxFieldID, fVal)
763 if err != nil {
764 return err
765 }
766 // Mark this node as facetsParent.
767 enc.setFacetsParent(facetNode)
768 enc.AddMapChild(fj, facetNode)
769 }
770 }
771
772 return nil
773}
774
775func (enc *encoder) encode(fj fastJsonNode) error {
776 child := enc.children(fj)

Callers 1

preTraverseMethod · 0.80

Calls 7

idForAttrMethod · 0.95
AddValueMethod · 0.95
newNodeMethod · 0.95
setFacetsParentMethod · 0.95
AddMapChildMethod · 0.95
ValForFunction · 0.92
facetNameFunction · 0.85

Tested by

no test coverage detected