-
Notifications
You must be signed in to change notification settings - Fork 281
Persistence implementation for pagination in some requests #1838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the approach LGTM.
Some places however could be simplified and clarified though.
polaris-core/src/main/java/org/apache/polaris/core/persistence/pagination/PageTokenUtil.java
Outdated
Show resolved
Hide resolved
polaris-core/src/main/java/org/apache/polaris/core/persistence/pagination/Page.java
Outdated
Show resolved
Hide resolved
* @param requestedPageSize optional page size for the next page. If not set, the page size of the | ||
* previus page (encoded in the previous page token) will be reused. | ||
*/ | ||
public static PageRequest nextPage( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function name and phrase 'from the previous API-level...are a bit confusing: what's "next"? What's "previous"? Why's there no "current"? All it does is constructing a
PageRequest` from the two pagination-parameters.
Why not call this function constructFromParameters
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored to PageToken.decode()
... Is it better?
} | ||
|
||
/** Represents a request to start paginating with a particular page size. */ | ||
public static PageRequest firstPage(int limit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the general use case of this one? It's only used in some drop*()
implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now PageToken.fromLimit()
(same name as before).
The use case is for handling initial paged requests where a size is provided, but a token in not. For API-based calls that is taken care of by the decode()
method. This method is a convenience entry point for internal calls.
polaris-core/src/main/java/org/apache/polaris/core/persistence/pagination/PageRequest.java
Outdated
Show resolved
Hide resolved
...ris-core/src/main/java/org/apache/polaris/core/persistence/pagination/EntityIdPageToken.java
Outdated
Show resolved
Hide resolved
...ris-core/src/main/java/org/apache/polaris/core/persistence/pagination/EntityIdPageToken.java
Outdated
Show resolved
Hide resolved
...ris-core/src/main/java/org/apache/polaris/core/persistence/pagination/EntityIdPageToken.java
Outdated
Show resolved
Hide resolved
...ris-core/src/main/java/org/apache/polaris/core/persistence/pagination/EntityIdPageToken.java
Outdated
Show resolved
Hide resolved
polaris-core/src/main/java/org/apache/polaris/core/persistence/pagination/PageTokenUtil.java
Outdated
Show resolved
Hide resolved
Squashed, rebased, resolved conflicts and addressed some feedback. Please review again. |
Following up on apache#1555 * Refactor pagination code to delineate API-level page tokens and internal "pointers to data" * Requests deal with the "previous" token, user-provided page size (optional) and the previous request's page size. * Concentrate the logic of combining page size requests and previous tokens in PageTokenUtil * PageToken subclasses are no longer necessary. EntityIdPaging handles pagination over ordered result sets with static helper methods. Co-authored-by: Eric Maynard <eric.maynard+oss@snowflake.com>
if (pageToken.paginationRequested()) { | ||
hql += " order by m.id asc"; | ||
|
||
if (pageToken.hasDataReference()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still polymorphism, we're just not taking advantage of the fact that this is built into the language already:
if (pageToken isinstanceof EntityIdPageToken e) {
tokenId = e.getEntityId();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Polymorphism at the java type level is not necessary in this case. Users of the "data pointer" know how to parse it based on the API method called. It is not a matter of providing a sub-type, but about understanding the format.
Currently parsing is achieved via static methods in EntityIdPaging
.
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Based on apache#1838, following up on apache#1555 * Allows multiple implementations of `Token` referencing the "next page", encapsulated in `PageToken`. No changes to `polaris-core` needed to add custom `Token` implementations. * Extensible to (later) support (cryptographic) signatures to prevent tampered page-token * Refactor pagination code to delineate API-level page tokens and internal "pointers to data" * Requests deal with the "previous" token, user-provided page size (optional) and the previous request's page size. * Concentrate the logic of combining page size requests and previous tokens in `PageTokenUtil` * `PageToken` subclasses are no longer necessary. * Serialzation of `PageToken` uses Jackson serialization (smile format) Since no (metastore level) implementation handling pagination existed before, no backwards compatibility is needed. Co-authored-by: Dmitri Bourlatchkov <dmitri.bourlatchkov@gmail.com> Co-authored-by: Eric Maynard <eric.maynard+oss@snowflake.com>
Based on #1838, following up on #1555 * Allows multiple implementations of `Token` referencing the "next page", encapsulated in `PageToken`. No changes to `polaris-core` needed to add custom `Token` implementations. * Extensible to (later) support (cryptographic) signatures to prevent tampered page-token * Refactor pagination code to delineate API-level page tokens and internal "pointers to data" * Requests deal with the "previous" token, user-provided page size (optional) and the previous request's page size. * Concentrate the logic of combining page size requests and previous tokens in `PageTokenUtil` * `PageToken` subclasses are no longer necessary. * Serialzation of `PageToken` uses Jackson serialization (smile format) Since no (metastore level) implementation handling pagination existed before, no backwards compatibility is needed. Co-authored-by: Dmitri Bourlatchkov <dmitri.bourlatchkov@gmail.com> Co-authored-by: Eric Maynard <eric.maynard+oss@snowflake.com>
IIUC #1938 supersedes this |
Following up on #1555
Refactor pagination code to delineate API-level page tokens and
internal "pointers to data"
Requests deal with the "previous" token, user-provided page size
(optional) and the previous request's page size.
Concentrate the logic of combining page size requests
and previous tokens in PageTokenUtil
PageToken subclasses are no longer necessary. EntityIdPaging handles
pagination over ordered result sets with static helper methods.