minimal API changes for 0-based offsets#1482
Conversation
Good catch - I rearranged some text that was there previously and you spotted an error in it. Co-authored-by: Stéphane Épardaud <stef@inforealm.org>
| Messages.get("004.arg.negative", "offset")); | ||
| } | ||
|
|
||
| if (offset == Long.MAX_VALUE) { |
There was a problem hiding this comment.
I am not sure about this one here.
- the Long.MAX_VALUE still a valid number right?
Why is this not supported?
There was a problem hiding this comment.
1. the Long.MAX_VALUE still a valid number right?Why is this not supported?
Of course it's a valid number. But an offset of Long.MAX_VALUE from the first result has a page number (Long.MAX_VALUE + 1) that is not representable as a positive long value. If we allowed it, what would you propose to return when a user/Data provider asks the API for the page number?
There was a problem hiding this comment.
10^19 is an implausible number of rows.
There was a problem hiding this comment.
You know, that's precisely how many rows I have. Make it work.
|
Includes additional changes that were agreed to on the Jakarta Data meeting:
Usage for page requests is now: PageRequest.ofSize(10).pageNumber(1);or PageRequest.ofSize(10).pageOffset(0);depending on whether you want 1-based or 0-based. |
This PR starts with some of Gavin's updates from #1479 and pares down to a minimum the amount of API updates needed to accommodate a developer that wants to think about making PageRequests as a 0-based offset from the first page and defining Limits in terms of a 0-based offset from first result.
To achieve this, we really only need 2 methods.
pageOffset(offset)forPageRequest:limit.of(maxResults, offset)forLimit: