dimas-b commented on code in PR #1528:
URL: https://github.com/apache/polaris/pull/1528#discussion_r2078546138


##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/pagination/ReadEverythingPageToken.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.core.persistence.pagination;
+
+import java.util.List;
+
+/**
+ * A {@link PageToken} implementation for readers who want to read everything. 
The behavior when
+ * using this token should be the same as when reading without a token.
+ */
+public class ReadEverythingPageToken extends PageToken {
+
+  private ReadEverythingPageToken() {
+    this.pageSize = Integer.MAX_VALUE;
+    validate();
+  }
+
+  /** Get a {@link ReadEverythingPageToken} */
+  public static ReadEverythingPageToken get() {
+    return new ReadEverythingPageToken();
+  }
+
+  public static PageTokenBuilder<ReadEverythingPageToken> builder() {
+    return new ReadEverythingPageTokenBuilder();
+  }
+
+  @Override
+  protected PageTokenBuilder<?> getBuilder() {
+    return builder();
+  }
+
+  /** A {@link PageTokenBuilder} implementation for {@link 
ReadEverythingPageToken} */
+  public static class ReadEverythingPageTokenBuilder
+      extends PageTokenBuilder<ReadEverythingPageToken> {
+
+    private ReadEverythingPageTokenBuilder() {}
+
+    @Override
+    public String tokenPrefix() {
+      return "polaris-read-everything";
+    }
+
+    @Override
+    public int expectedComponents() {
+      return 0;
+    }
+
+    @Override
+    protected ReadEverythingPageToken fromStringComponents(List<String> 
components) {
+      return ReadEverythingPageToken.get();

Review Comment:
   We can certainly have a hierarchy of page token implementations and share 
common code. My idea is that the entry into the parsing logic does not have to 
be polymorphic. For example, JDBC Persistence uses an "offset page token", so 
it'd call `OffsetToken t = OffsetToken.parse(String)`. A NoSQL impl might use a 
"previous name in index" token, it would call `NameToken t = 
NameToken.parse(String)`. Internally both `OffsetToken` and `NameToken` could 
extend a common base class, or simply share common static utility methods.
   
   The key here is that input is converted to a simple `PageToken(String, int)` 
without parsing. Parsing happens at the persistence layer where we know the 
expected token type.
   
   If we ever have to change token encoding, the parsing methods can still 
return the appropriate sub-class by analysing the token structure.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to