rahil-c commented on code in PR #9782:
URL: https://github.com/apache/iceberg/pull/9782#discussion_r1546625002


##########
core/src/main/java/org/apache/iceberg/rest/PaginatedList.java:
##########
@@ -0,0 +1,269 @@
+/*
+ * 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.iceberg.rest;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+import org.apache.iceberg.catalog.Namespace;
+import org.apache.iceberg.exceptions.ValidationException;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.iceberg.rest.responses.ListNamespacesResponse;
+import org.apache.iceberg.rest.responses.ListTablesResponse;
+import org.apache.iceberg.rest.responses.Route;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PaginatedList<T> implements List<T> {

Review Comment:
   @danielcweeks Can you elaborate on what you mean by prefetching? Did you 
want the client to retrieve all the paginated results from the service in one 
go ( by repeatedly sending requests until `next-page-token` is `null`)?
   
   I had this before:
   
   ```
    List<Namespace> namespaces = Lists.newArrayList();
         String pageToken = "";
         queryParams.put("pageSize", restPageSize);
    
         while (pageToken != null) {
           queryParams.put("pageToken", pageToken);
           LOG.error("Sending list namespaces request");
           ListNamespacesResponse response =
                   client.get(
                           paths.namespaces(),
                           queryParams,
                           ListNamespacesResponse.class,
                           headers(context),
                           ErrorHandlers.namespaceErrorHandler());
           pageToken = response.nextPageToken();
           namespaces.addAll(response.namespaces());
         }
   ```
   
    but i think the other reviewers of the pr mentioned that we want to do 
lazily loading of the results, and shared this `PaginatedList` as an idea 
https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/datamodeling/PaginatedList.html
 which is what i tried following. 
   
   
   
   



-- 
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...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to