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
()
| 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. |
| 1425 | func (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. |
no test coverage detected