eric-maynard commented on code in PR #1838:
URL: https://github.com/apache/polaris/pull/1838#discussion_r2143215921


##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/pagination/Page.java:
##########
@@ -18,25 +18,96 @@
  */
 package org.apache.polaris.core.persistence.pagination;
 
+import static java.util.Spliterators.iterator;
+
+import jakarta.annotation.Nullable;
+import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
- * An immutable page of items plus their paging cursor. The {@link PageToken} 
here can be used to
- * continue the listing operation that generated the `items`.
+ * An immutable page of items plus their paging cursor. The {@link 
#encodedResponseToken()} here can
+ * be used to continue the listing operation that generated the `items`.
  */
 public class Page<T> {
-  public final PageToken pageToken;
-  public final List<T> items;
+  private final PageToken request;
+  private final List<T> items;
+  @Nullable private final String encodedDataReference;
 
-  public Page(PageToken pageToken, List<T> items) {
-    this.pageToken = pageToken;
+  private Page(PageToken request, @Nullable String encodedDataReference, 
List<T> items) {
+    this.request = request;
+    this.encodedDataReference = encodedDataReference;
     this.items = items;
   }
 
   /**
-   * Used to wrap a {@link List<T>} of items into a {@link Page <T>} when 
there are no more pages
+   * Builds a complete response page for the full list of relevant items. No 
subsequence pages of
+   * related data exist.
    */
   public static <T> Page<T> fromItems(List<T> items) {
-    return new Page<>(new DonePageToken(), items);
+    return new Page<>(PageToken.readEverything(), null, items);
+  }
+
+  /**
+   * Produces a response page by consuming the number of items from the 
provided stream according to
+   * the {@code request} parameter. Source items can be converted to a 
different type by providing a
+   * {@code mapper} function. The page token for the response will be produced 
from the request data
+   * combined with the pointer to the next page of data provided by the {@code 
dataPointer}
+   * function.
+   *
+   * @param request defines pagination parameters that were uses to produce 
this page of data.
+   * @param items stream of source data
+   * @param mapper converter from source data types to response data types.
+   * @param dataPointer determines the internal pointer to the next page of 
data given the last item

Review Comment:
   I think we need a Java type for what you're calling a "data pointer" -- for 
what the API calls `page-token`. In #1555, I called this PageToken. If we need 
to wrap this PageToken in a PageRequest, that's okay.
   
   ```
   public record PageToken() {
     public void getEncodedString() { ... }
     public static PageToken fromEncodedString() { ... }
   }
   
   public record PageRequest(Optional<PageToken> pageToken, Optional<Integer> 
pageSize) {}
   ```



-- 
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

Reply via email to