| 868 | } // namespace internal |
| 869 | |
| 870 | Status LoadFileSystemFactories(const char* libpath) { |
| 871 | using ::arrow::internal::GetSymbolAs; |
| 872 | using ::arrow::internal::LoadDynamicLibrary; |
| 873 | |
| 874 | ARROW_ASSIGN_OR_RAISE(void* lib, LoadDynamicLibrary(libpath)); |
| 875 | auto* get_instance = |
| 876 | GetSymbolAs<void*()>(lib, "arrow_filesystem_get_registry").ValueOr(nullptr); |
| 877 | if (get_instance == nullptr) { |
| 878 | // If a third party library is linked such that registry deduplication is not |
| 879 | // necessary (for example if built with `ARROW_BUILD_SHARED`), we do not require that |
| 880 | // library to export arrow_filesystem_get_registry() since that symbol is not used |
| 881 | // except for deduplication. |
| 882 | return Status::OK(); |
| 883 | } |
| 884 | |
| 885 | auto* lib_registry = static_cast<FileSystemFactoryRegistry*>(get_instance()); |
| 886 | auto* main_registry = FileSystemFactoryRegistry::GetInstance(); |
| 887 | if (lib_registry != main_registry) { |
| 888 | RETURN_NOT_OK(lib_registry->MergeInto(main_registry)); |
| 889 | } |
| 890 | |
| 891 | return Status::OK(); |
| 892 | } |
| 893 | |
| 894 | namespace { |
| 895 | |