MCPcopy Create free account
hub / github.com/apache/arrow / FromString

Method FromString

cpp/src/arrow/filesystem/s3fs.cc:533–553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

531 std::vector<std::string> key_parts;
532
533 static Result<S3Path> FromString(const std::string& s) {
534 if (internal::IsLikelyUri(s)) {
535 return Status::Invalid(
536 "Expected an S3 object path of the form 'bucket/key...', got a URI: '", s, "'");
537 }
538 const auto src = internal::RemoveTrailingSlash(s);
539 auto first_sep = src.find_first_of(kSep);
540 if (first_sep == 0) {
541 return Status::Invalid("Path cannot start with a separator ('", s, "')");
542 }
543 if (first_sep == std::string::npos) {
544 return S3Path{std::string(src), std::string(src), "", {}};
545 }
546 S3Path path;
547 path.full_path = std::string(src);
548 path.bucket = std::string(src.substr(0, first_sep));
549 path.key = std::string(src.substr(first_sep + 1));
550 path.key_parts = internal::SplitAbstractPath(path.key);
551 RETURN_NOT_OK(Validate(path));
552 return path;
553 }
554
555 static Status Validate(const S3Path& path) {
556 auto st = internal::ValidateAbstractPath(path.full_path);

Callers

nothing calls this directly

Calls 6

IsLikelyUriFunction · 0.85
SplitAbstractPathFunction · 0.85
ValidateFunction · 0.85
substrMethod · 0.80
RemoveTrailingSlashFunction · 0.70
InvalidFunction · 0.50

Tested by

no test coverage detected