| 1731 | } // namespace |
| 1732 | |
| 1733 | class AzureFileSystem::Impl { |
| 1734 | private: |
| 1735 | io::IOContext io_context_; |
| 1736 | AzureOptions options_; |
| 1737 | |
| 1738 | std::unique_ptr<DataLake::DataLakeServiceClient> datalake_service_client_; |
| 1739 | std::unique_ptr<Blobs::BlobServiceClient> blob_service_client_; |
| 1740 | HNSSupport cached_hns_support_ = HNSSupport::kUnknown; |
| 1741 | |
| 1742 | Impl(AzureOptions options, io::IOContext io_context) |
| 1743 | : io_context_(std::move(io_context)), options_(std::move(options)) {} |
| 1744 | |
| 1745 | public: |
| 1746 | static Result<std::unique_ptr<AzureFileSystem::Impl>> Make(AzureOptions options, |
| 1747 | io::IOContext io_context) { |
| 1748 | auto self = std::unique_ptr<AzureFileSystem::Impl>( |
| 1749 | new AzureFileSystem::Impl(std::move(options), std::move(io_context))); |
| 1750 | ARROW_ASSIGN_OR_RAISE(self->blob_service_client_, |
| 1751 | self->options_.MakeBlobServiceClient()); |
| 1752 | ARROW_ASSIGN_OR_RAISE(self->datalake_service_client_, |
| 1753 | self->options_.MakeDataLakeServiceClient()); |
| 1754 | return self; |
| 1755 | } |
| 1756 | |
| 1757 | io::IOContext& io_context() { return io_context_; } |
| 1758 | const AzureOptions& options() const { return options_; } |
| 1759 | |
| 1760 | Blobs::BlobContainerClient GetBlobContainerClient(const std::string& container_name) { |
| 1761 | return blob_service_client_->GetBlobContainerClient(container_name); |
| 1762 | } |
| 1763 | |
| 1764 | Blobs::BlobClient GetBlobClient(const std::string& container_name, |
| 1765 | const std::string& blob_name) { |
| 1766 | return GetBlobContainerClient(container_name).GetBlobClient(blob_name); |
| 1767 | } |
| 1768 | |
| 1769 | /// \param container_name Also known as "filesystem" in the ADLS Gen2 API. |
| 1770 | DataLake::DataLakeFileSystemClient GetFileSystemClient( |
| 1771 | const std::string& container_name) { |
| 1772 | return datalake_service_client_->GetFileSystemClient(container_name); |
| 1773 | } |
| 1774 | |
| 1775 | /// \brief Memoized version of CheckIfHierarchicalNamespaceIsEnabled. |
| 1776 | /// |
| 1777 | /// \return kEnabled/kDisabled/kContainerNotFound (kUnknown is never returned). |
| 1778 | Result<HNSSupport> HierarchicalNamespaceSupport( |
| 1779 | const DataLake::DataLakeFileSystemClient& adlfs_client) { |
| 1780 | switch (cached_hns_support_) { |
| 1781 | case HNSSupport::kEnabled: |
| 1782 | case HNSSupport::kDisabled: |
| 1783 | return cached_hns_support_; |
| 1784 | case HNSSupport::kUnknown: |
| 1785 | case HNSSupport::kContainerNotFound: |
| 1786 | // Try the check again because the support is still unknown or the container |
| 1787 | // that didn't exist before may exist now. |
| 1788 | break; |
| 1789 | } |
| 1790 | ARROW_ASSIGN_OR_RAISE( |
nothing calls this directly
no test coverage detected