eric-maynard commented on code in PR #1838: URL: https://github.com/apache/polaris/pull/1838#discussion_r2145659867
########## polaris-core/src/main/java/org/apache/polaris/core/persistence/pagination/PageToken.java: ########## @@ -18,82 +18,85 @@ */ package org.apache.polaris.core.persistence.pagination; -import java.util.List; -import java.util.Objects; +import static com.google.common.base.Preconditions.checkState; -/** - * Represents a page token that can be used by operations like `listTables`. Clients that specify a - * `pageSize` (or a `pageToken`) may receive a `next-page-token` in the response, the content of - * which is a serialized PageToken. - * - * <p>By providing that in the next query's `pageToken`, the client can resume listing where they - * left off. If the client provides a `pageToken` or `pageSize` but `next-page-token` is null in the - * response, that means there is no more data to read. - */ -public abstract class PageToken { +import jakarta.annotation.Nullable; - /** Build a new PageToken that reads everything */ - public static PageToken readEverything() { - return build(null, null); - } +/** A wrapper for pagination information passed in as part of a request. */ +public class PageToken { + private final @Nullable String encodedDataReference; + private final int pageSize; - /** Build a new PageToken from an input String, without a specified page size */ - public static PageToken fromString(String token) { - return build(token, null); + PageToken(@Nullable String encodedDataReference, int pageSize) { + this.encodedDataReference = encodedDataReference; + this.pageSize = pageSize; } - /** Build a new PageToken from a limit */ - public static PageToken fromLimit(Integer pageSize) { - return build(null, pageSize); + /** Represents a non-paginated request. */ + public static PageToken readEverything() { + return new PageToken(null, -1); } - /** Build a {@link PageToken} from the input string and page size */ - public static PageToken build(String token, Integer pageSize) { - if (token == null || token.isEmpty()) { - if (pageSize != null) { - return new LimitPageToken(pageSize); - } else { - return new ReadEverythingPageToken(); - } - } else { - // TODO implement, split out by the token's prefix - throw new IllegalArgumentException("Unrecognized page token: " + token); - } + /** Represents a request to start paginating with a particular page size. */ + public static PageToken fromLimit(int limit) { + return new PageToken(null, limit); } - /** Serialize a {@link PageToken} into a string */ - public abstract String toTokenString(); + /** + * Reconstructs a page token from the API-level page token string (returned to the client in the + * response to a previous request for similar data) and an API-level new requested page size. Review Comment: Isn't it just "a page token string"? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@polaris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org