zhjwpku commented on code in PR #1124:
URL: https://github.com/apache/iceberg-cpp/pull/1124#discussion_r4576787195
##########
src/iceberg/util/location_util.cc:
##########
@@ -66,4 +66,63 @@ std::string_view LocationUtil::ParseScheme(std::string_view
location) {
return candidate;
}
+bool LocationUtil::HasScheme(std::string_view location) {
+ // RFC 3986 section 3.1: a URI starts with `scheme ":"`, so the scheme is
+ // everything before the first colon. The spec ("Paths in Metadata") calls a
+ // path absolute iff it starts with such a scheme, as Java's
+ // LocationUtil.hasScheme does.
+ const auto colon = location.find(':');
+ return colon != std::string_view::npos && IsValidScheme(location.substr(0,
colon));
+}
+
+std::string LocationUtil::ResolveLocation(std::string_view table_location,
+ std::string_view location) {
+ if (HasScheme(location)) {
+ return std::string(location);
+ }
+ // The spec ("Path Resolution",
+ // https://iceberg.apache.org/spec/#path-resolution) defines this as a plain
+ // string join with `/`.
+ // It is not RFC 3986 reference resolution (section 5.2), which the spec
+ // rules out: a URI library would remove `.`/`..` segments, merge `//`, and
+ // could decode or re-encode `%XX`, producing a path that differs from the
+ // one the writer stored. Both parts are opaque strings in whatever encoding
+ // the writer used, and they are copied byte for byte.
+ //
+ // The spec recommends a table location that does not end in `/`, because
Review Comment:
Quote comment from java:
```
* The separator is appended unconditionally; {@code tableLocation} is
expected
* not to end with {@code /} and {@code location} is expected not to start
* with {@code /}. Otherwise the result will contain a duplicate {@code //}.
```
--
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]