Aggarwal-Raghav commented on code in PR #6750:
URL: https://github.com/apache/hive/pull/6750#discussion_r4101115304
##########
standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java:
##########
@@ -275,23 +282,38 @@ public Class<? extends RESTRequest> requestClass() {
private ConfigResponse config() {
final List<Endpoint> endpoints = Arrays.stream(Route.values())
.map(r -> Endpoint.create(r.method.name(), r.pathTemplate)).toList();
- return castResponse(ConfigResponse.class,
ConfigResponse.builder().withEndpoints(endpoints).build());
+ return ConfigResponse.builder().withEndpoints(endpoints).build();
+ }
+
+ /** 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);
}
private ListNamespacesResponse listNamespaces(Map<String, String> vars) {
Namespace namespace;
- if (vars.containsKey("parent")) {
- namespace =
Namespace.of(RESTUtil.NAMESPACE_SPLITTER.splitToStream(vars.get("parent")).toArray(String[]::new));
+ if (vars.containsKey(PARENT)) {
+ namespace = RESTUtil.namespaceFromQueryParam(vars.get(PARENT));
} else {
namespace = Namespace.empty();
}
- return castResponse(ListNamespacesResponse.class,
CatalogHandlers.listNamespaces(asNamespaceCatalog, namespace));
+ return paginateIfRequested(
Review Comment:
Done. Thanks for your repeated guidance on this
--
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]