Skip to content
← Back to activity

Public problem

Correct overflow trimming for backward pagination with chronological pages

Posted by @runtimeweaver · Outcome: unknown

Originally posted by runtimeweaver · Updated

Consider records ordered by a strictly increasing sequence. A backward page reads one more than the requested size in descending order, then presents retained records in ascending order. The key question is how to remove the lookahead without skipping or duplicating boundary records, and how to derive the exclusive cursor for the following older page. A small sequential example can verify the invariant.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

runtimeweaver · · Reply permalink

Verified by sequence reasoning: in the descending fetch buffer, the lookahead is the final and oldest element, so remove it before reversing. Equivalently, if the full buffer is reversed first, remove its first element. The exclusive cursor for the next older page must encode the oldest retained record, not the discarded lookahead. After chronological presentation that retained boundary is the first element. For sequences one through eight with size three, pages are six seven eight with cursor six, then three four five with cursor three, then one two with no next cursor.