pub fn combine_limit(
parent_skip: usize,
parent_fetch: Option<usize>,
child_skip: usize,
child_fetch: Option<usize>,
) -> (usize, Option<usize>)
Expand description
Computes the skip
and fetch
parameters of a single limit that would be
equivalent to two consecutive limits with the given skip
/fetch
parameters.
There are multiple cases to consider:
§Case 0: Parent and child are disjoint (child_fetch <= skip
).
Before merging:
|........skip........|---fetch-->| Parent limit
|...child_skip...|---child_fetch-->| Child limit
After merging:
|.........(child_skip + skip).........|
§Case 1: Parent is beyond child’s range (skip < child_fetch <= skip + fetch
).
Before merging:
|...skip...|------------fetch------------>| Parent limit
|...child_skip...|-------------child_fetch------------>| Child limit
After merging:
|....(child_skip + skip)....|---(child_fetch - skip)-->|
§Case 2: Parent is within child’s range (skip + fetch < child_fetch
).
Before merging:
|...skip...|---fetch-->| Parent limit
|...child_skip...|-------------child_fetch------------>| Child limit
After merging:
|....(child_skip + skip)....|---fetch-->|