MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / expandOut

Method expandOut

query/shortest.go:141–273  ·  view source on GitHub ↗
(ctx context.Context,
	adjacencyMap map[uint64]map[uint64]mapItem, next chan bool, rch chan error)

Source from the content-addressed store, hash-verified

139}
140
141func (sg *SubGraph) expandOut(ctx context.Context,
142 adjacencyMap map[uint64]map[uint64]mapItem, next chan bool, rch chan error) {
143
144 var numEdges uint64
145 var exec []*SubGraph
146 var err error
147 in := []uint64{sg.Params.From}
148 sg.SrcUIDs = &pb.List{Uids: in}
149 sg.uidMatrix = []*pb.List{{Uids: in}}
150 sg.DestUIDs = sg.SrcUIDs
151
152 for _, child := range sg.Children {
153 child.SrcUIDs = sg.DestUIDs
154 exec = append(exec, child)
155 }
156 dummy := &SubGraph{}
157 for {
158 isNext := <-next
159 if !isNext {
160 return
161 }
162 rrch := make(chan error, len(exec))
163 for _, subgraph := range exec {
164 go ProcessGraph(ctx, subgraph, dummy, rrch)
165 }
166
167 for range exec {
168 select {
169 case err = <-rrch:
170 if err != nil {
171 rch <- err
172 return
173 }
174 case <-ctx.Done():
175 rch <- ctx.Err()
176 return
177 }
178 }
179
180 for _, subgraph := range exec {
181 select {
182 case <-ctx.Done():
183 rch <- ctx.Err()
184 return
185 default:
186 if subgraph.UnknownAttr {
187 continue
188 }
189
190 // Call updateUidMatrix to ensure that entries in the uidMatrix are updated after
191 // intersecting with DestUIDs. This should ideally be called during query
192 // processing but doesn't seem to be called for shortest path queries. So we call
193 // it explicitly here to ensure the results are correct.
194 subgraph.updateUidMatrix()
195 // Send the destuids in res chan.
196 for mIdx, fromUID := range subgraph.SrcUIDs.Uids {
197 // This can happen when trying to go traverse a predicate of type password
198 // for example.

Callers 2

runKShortestPathsFunction · 0.80
shortestPathFunction · 0.80

Calls 7

ApplyFilterFunction · 0.92
ProcessGraphFunction · 0.85
updateUidMatrixMethod · 0.80
getCostMethod · 0.80
copyFiltersRecurseMethod · 0.80
DoneMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected