laserninja commented on code in PR #10671:
URL: https://github.com/apache/gravitino/pull/10671#discussion_r3296181701


##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java:
##########
@@ -451,6 +471,61 @@ public IcebergTableChange(TableIdentifier tableIdentifier, 
Transaction transacti
     }
   }
 
+  private int parsePageToken(@Nullable String pageToken) {
+    if (pageToken == null || pageToken.isEmpty()) {
+      return 0;
+    }
+    try {
+      int offset = Integer.parseInt(pageToken);
+      Preconditions.checkArgument(offset >= 0, "pageToken must be 
non-negative, got: %s", offset);
+      return offset;
+    } catch (NumberFormatException e) {
+      throw new IllegalArgumentException("Invalid pageToken: " + pageToken, e);
+    }
+  }
+
+  private ListNamespacesResponse paginateNamespaces(
+      ListNamespacesResponse response, @Nullable String pageToken, @Nullable 
Integer pageSize) {
+    if (pageSize == null && (pageToken == null || pageToken.isEmpty())) {
+      return response;
+    }
+    List<Namespace> all = response.namespaces();

Review Comment:
   Sounds good. I've added Javadoc on IcebergPaginationHelper documenting this 
as offset-based, in-memory pagination (the full list is materialized on each 
request). The known limitations (O(N²) for full walk, offset stability 
assumptions with concurrent changes) are called out. Validation ordering is 
also fixed: parsePageToken now validates before the offset >= size 
early-return. True catalog-level pagination would require changes to the 
Iceberg Catalog interface and is out of scope here.



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