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

Method updateUidMatrix

query/query.go:1425–1439  ·  view source on GitHub ↗

updateUidMatrix is used to filter out the uids in uidMatrix which are not part of DestUIDs anymore. Some uids might have been removed from DestUids after application of filters, we remove them from the uidMatrix as well. If the query didn't specify sorting, we can just intersect the DestUids with li

()

Source from the content-addressed store, hash-verified

1423// uidMatrix since they are both sorted. Otherwise we must filter out the uids within the
1424// lists in uidMatrix which are not in DestUIDs.
1425func (sg *SubGraph) updateUidMatrix() {
1426 sg.updateFacetMatrix()
1427 for _, l := range sg.uidMatrix {
1428 if len(sg.Params.Order) > 0 || len(sg.Params.FacetsOrder) > 0 {
1429 // We can't do intersection directly as the list is not sorted by UIDs.
1430 // So do filter.
1431 algo.ApplyFilter(l, func(uid uint64, idx int) bool {
1432 return algo.IndexOf(sg.DestUIDs, uid) >= 0 // Binary search.
1433 })
1434 } else {
1435 // If we didn't order on UIDmatrix, it'll be sorted.
1436 algo.IntersectWith(l, sg.DestUIDs, l)
1437 }
1438 }
1439}
1440
1441// populateVarMap stores the value of the variable defined in this SubGraph into req.Vars so that it
1442// is available to other queries as well. It is called after a query has been executed.

Callers 7

populateVarMapMethod · 0.95
applyPaginationMethod · 0.95
expandOutMethod · 0.80
ProcessGraphFunction · 0.80
ProcessQueryMethod · 0.80
expandRecurseMethod · 0.80

Calls 4

updateFacetMatrixMethod · 0.95
ApplyFilterFunction · 0.92
IndexOfFunction · 0.92
IntersectWithFunction · 0.92

Tested by

no test coverage detected