applyPagination applies count and offset to lists inside uidMatrix.
(ctx context.Context)
| 2491 | |
| 2492 | // applyPagination applies count and offset to lists inside uidMatrix. |
| 2493 | func (sg *SubGraph) applyPagination(ctx context.Context) error { |
| 2494 | if sg.Params.Count == 0 && sg.Params.Offset == 0 { // No pagination. |
| 2495 | return nil |
| 2496 | } |
| 2497 | |
| 2498 | sg.updateUidMatrix() |
| 2499 | for i := range sg.uidMatrix { |
| 2500 | // Apply the offsets. |
| 2501 | start, end := x.PageRange(sg.Params.Count, sg.Params.Offset, len(sg.uidMatrix[i].Uids)) |
| 2502 | sg.uidMatrix[i].Uids = sg.uidMatrix[i].Uids[start:end] |
| 2503 | } |
| 2504 | // Re-merge the UID matrix. |
| 2505 | sg.DestUIDs = algo.MergeSorted(sg.uidMatrix) |
| 2506 | return nil |
| 2507 | } |
| 2508 | |
| 2509 | // applyOrderAndPagination orders each posting list by a given attribute |
| 2510 | // before applying pagination. |
no test coverage detected