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

Method getCost

query/shortest.go:105–139  ·  view source on GitHub ↗
(matrix, list int)

Source from the content-addressed store, hash-verified

103}
104
105func (sg *SubGraph) getCost(matrix, list int) (cost float64,
106 fcs *pb.Facets, rerr error) {
107
108 cost = 1.0
109 if len(sg.facetsMatrix) <= matrix {
110 return cost, fcs, rerr
111 }
112 fcsList := sg.facetsMatrix[matrix].FacetsList
113 if len(fcsList) <= list {
114 rerr = errFacet
115 return cost, fcs, rerr
116 }
117 fcs = fcsList[list]
118 if len(fcs.Facets) == 0 {
119 rerr = errFacet
120 return cost, fcs, rerr
121 }
122 if len(fcs.Facets) > 1 {
123 rerr = errors.Errorf("Expected 1 but got %d facets", len(fcs.Facets))
124 return cost, fcs, rerr
125 }
126 tv, err := facets.ValFor(fcs.Facets[0])
127 if err != nil {
128 return 0.0, nil, err
129 }
130 switch {
131 case tv.Tid == types.IntID:
132 cost = float64(tv.Value.(int64))
133 case tv.Tid == types.FloatID:
134 cost = tv.Value.(float64)
135 default:
136 rerr = errFacet
137 }
138 return cost, fcs, rerr
139}
140
141func (sg *SubGraph) expandOut(ctx context.Context,
142 adjacencyMap map[uint64]map[uint64]mapItem, next chan bool, rch chan error) {

Callers 1

expandOutMethod · 0.80

Calls 2

ValForFunction · 0.92
ErrorfMethod · 0.45

Tested by

no test coverage detected