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

Method applyPagination

query/query.go:2493–2507  ·  view source on GitHub ↗

applyPagination applies count and offset to lists inside uidMatrix.

(ctx context.Context)

Source from the content-addressed store, hash-verified

2491
2492// applyPagination applies count and offset to lists inside uidMatrix.
2493func (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.

Callers 1

ProcessGraphFunction · 0.80

Calls 3

updateUidMatrixMethod · 0.95
PageRangeFunction · 0.92
MergeSortedFunction · 0.92

Tested by

no test coverage detected