deniskuzZ commented on code in PR #6750:
URL: https://github.com/apache/hive/pull/6750#discussion_r4081926197
##########
standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java:
##########
@@ -234,14 +238,32 @@ private ConfigResponse config() {
return castResponse(ConfigResponse.class,
ConfigResponse.builder().withEndpoints(endpoints).build());
}
+ private <T extends RESTResponse> T executePaginated(
Review Comment:
could we apply minot improvements to design, how about
````
/** Paging parameters of a list request; present only when the client sent
pageSize. */
private record PageRequest(String token, String size) {
static Optional<PageRequest> from(Map<String, String> vars) {
return Optional.ofNullable(vars.get(PAGE_SIZE))
.map(size -> new PageRequest(vars.get(PAGE_TOKEN), size));
}
}
private static <R> R paginateIfRequested(
Map<String, String> vars, Supplier<R> fullList, Function<PageRequest, R>
page) {
return PageRequest.from(vars).map(page).orElseGet(fullList);
}
````
usage
````
private ListTablesResponse listTables(Map<String, String> vars) {
Namespace namespace = namespaceFromPathVars(vars);
return paginateIfRequested(vars,
() -> CatalogHandlers.listTables(catalog, namespace),
p -> CatalogHandlers.listTables(catalog, namespace, p.token(),
p.size()));
}
````
why did we need `castResponse` at all?
##########
standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java:
##########
@@ -234,14 +238,32 @@ private ConfigResponse config() {
return castResponse(ConfigResponse.class,
ConfigResponse.builder().withEndpoints(endpoints).build());
}
+ private <T extends RESTResponse> T executePaginated(
Review Comment:
could we apply minot changes to design, how about
````
/** Paging parameters of a list request; present only when the client sent
pageSize. */
private record PageRequest(String token, String size) {
static Optional<PageRequest> from(Map<String, String> vars) {
return Optional.ofNullable(vars.get(PAGE_SIZE))
.map(size -> new PageRequest(vars.get(PAGE_TOKEN), size));
}
}
private static <R> R paginateIfRequested(
Map<String, String> vars, Supplier<R> fullList, Function<PageRequest, R>
page) {
return PageRequest.from(vars).map(page).orElseGet(fullList);
}
````
usage
````
private ListTablesResponse listTables(Map<String, String> vars) {
Namespace namespace = namespaceFromPathVars(vars);
return paginateIfRequested(vars,
() -> CatalogHandlers.listTables(catalog, namespace),
p -> CatalogHandlers.listTables(catalog, namespace, p.token(),
p.size()));
}
````
why did we need `castResponse` at all?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]