deniskuzZ commented on code in PR #6749:
URL: https://github.com/apache/hive/pull/6749#discussion_r4024727939
##########
standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java:
##########
@@ -189,26 +192,60 @@ enum Route {
}
this.requestClass = requestClass;
-
this.requiredLength = parts.size();
this.requirements = requirementsBuilder.build();
this.variables = variablesBuilder.build();
}
+ /**
+ * Shift index to skip the prefix.
+ */
+ private int mappedIndex(int baseIndex, int offset) {
+ return (offset > 0 && baseIndex >= 1) ? baseIndex + offset : baseIndex;
+ }
+
private boolean matches(HTTPMethod requestMethod, List<String>
requestPath) {
- return method == requestMethod
- && requiredLength == requestPath.size()
- && requirements.entrySet().stream()
- .allMatch(
- requirement ->
- requirement
- .getValue()
-
.equalsIgnoreCase(requestPath.get(requirement.getKey())));
+ if (method != requestMethod) {
+ return false;
+ }
+
+ int size = requestPath.size();
Review Comment:
````
// A multi-segment prefix like "catalogs/my_catalog" gives prefixLength == 2
int prefixLength = prefixLength(requestPath);
if (prefixLength < 0 || (prefixLength > 0 && !acceptsPrefix)) {
return false;
}
for (Map.Entry<Integer, String> requirement : requirements.entrySet()) {
String actual = requestPath.get(mappedIndex(requirement.getKey(),
prefixLength));
if (!requirement.getValue().equalsIgnoreCase(actual)) {
return false;
}
}
````
helper
````
/** Number of extra segments in the request, i.e. the prefix length. */
private int prefixLength(List<String> requestPath) {
return requestPath.size() - requiredLength;
}
````
--
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]