| 894 | namespace { |
| 895 | |
| 896 | Result<std::shared_ptr<FileSystem>> FileSystemFromUriReal(const Uri& uri, |
| 897 | const std::string& uri_string, |
| 898 | const io::IOContext& io_context, |
| 899 | std::string* out_path) { |
| 900 | const auto scheme = uri.scheme(); |
| 901 | |
| 902 | { |
| 903 | ARROW_ASSIGN_OR_RAISE( |
| 904 | auto* factory, |
| 905 | FileSystemFactoryRegistry::GetInstance()->FactoryForScheme(scheme)); |
| 906 | if (factory != nullptr) { |
| 907 | return factory->function(uri, io_context, out_path); |
| 908 | } |
| 909 | } |
| 910 | |
| 911 | if (scheme == "abfs" || scheme == "abfss") { |
| 912 | #ifdef ARROW_AZURE |
| 913 | ARROW_ASSIGN_OR_RAISE(auto options, AzureOptions::FromUri(uri, out_path)); |
| 914 | return AzureFileSystem::Make(options, io_context); |
| 915 | #else |
| 916 | return Status::NotImplemented( |
| 917 | "Got Azure Blob File System URI but Arrow compiled without Azure Blob File " |
| 918 | "System support"); |
| 919 | #endif |
| 920 | } |
| 921 | if (scheme == "gs" || scheme == "gcs") { |
| 922 | #ifdef ARROW_GCS |
| 923 | ARROW_ASSIGN_OR_RAISE(auto options, GcsOptions::FromUri(uri, out_path)); |
| 924 | return GcsFileSystem::Make(options, io_context); |
| 925 | #else |
| 926 | return Status::NotImplemented( |
| 927 | "Got GCS URI but Arrow compiled " |
| 928 | "without GCS support"); |
| 929 | #endif |
| 930 | } |
| 931 | if (scheme == "hdfs" || scheme == "viewfs") { |
| 932 | #ifdef ARROW_HDFS |
| 933 | ARROW_ASSIGN_OR_RAISE(auto options, HdfsOptions::FromUri(uri)); |
| 934 | if (out_path != nullptr) { |
| 935 | *out_path = uri.path(); |
| 936 | } |
| 937 | ARROW_ASSIGN_OR_RAISE(auto hdfs, HadoopFileSystem::Make(options, io_context)); |
| 938 | return hdfs; |
| 939 | #else |
| 940 | return Status::NotImplemented( |
| 941 | "Got HDFS URI but Arrow compiled " |
| 942 | "without HDFS support"); |
| 943 | #endif |
| 944 | } |
| 945 | |
| 946 | if (scheme == "mock") { |
| 947 | // MockFileSystem does not have an |
| 948 | // absolute / relative path distinction, |
| 949 | // normalize path by removing leading |
| 950 | // slash. |
| 951 | if (out_path != nullptr) { |
| 952 | *out_path = std::string(RemoveLeadingSlash(uri.path())); |
| 953 | } |
no test coverage detected