pitrou commented on code in PR #39009:
URL: https://github.com/apache/arrow/pull/39009#discussion_r1414093199
##########
cpp/src/arrow/filesystem/azurefs.cc:
##########
@@ -815,6 +815,233 @@ class AzureFileSystem::Impl {
}
}
+ private:
+ template <typename OnContainer>
+ Status ListContainers(const Azure::Core::Context& context,
+ OnContainer&& on_container) const {
+ Azure::Storage::Blobs::ListBlobContainersOptions options;
+ // Deleted containers are not returned.
+ options.Include =
Azure::Storage::Blobs::Models::ListBlobContainersIncludeFlags::None;
+ try {
+ auto container_list_response =
+ blob_service_client_->ListBlobContainers(options, context);
+ for (; container_list_response.HasPage();
+ container_list_response.MoveToNextPage(context)) {
+ for (const auto& container : container_list_response.BlobContainers) {
+ RETURN_NOT_OK(on_container(container));
+ }
+ }
+ } catch (const Azure::Storage::StorageException& exception) {
+ return internal::ExceptionToStatus("Failed to list account containers.",
exception);
+ }
+ return Status::OK();
+ }
+
+ static FileInfo FileInfoFromBlob(const std::string& container,
+ const
Azure::Storage::Blobs::Models::BlobItem& blob) {
+ if (blob.Name.back() == internal::kSep) {
+ return DirectoryFileInfoFromPath(container + internal::kSep + blob.Name);
+ }
+ std::string path;
+ path.reserve(container.size() + 1 + blob.Name.size());
+ path += container;
+ path += internal::kSep;
+ path += blob.Name;
Review Comment:
Also, if you're keen on micro-optimization `std::string` allocation, why not
do that as part of `ConcatAbstractPath` and reuse it here? Filesystem code is
sufficiently complex generally that we probably don't want to make it more
obscure by inlining such code :-)
##########
cpp/src/arrow/filesystem/azurefs.cc:
##########
@@ -815,6 +815,233 @@ class AzureFileSystem::Impl {
}
}
+ private:
+ template <typename OnContainer>
+ Status ListContainers(const Azure::Core::Context& context,
+ OnContainer&& on_container) const {
+ Azure::Storage::Blobs::ListBlobContainersOptions options;
+ // Deleted containers are not returned.
+ options.Include =
Azure::Storage::Blobs::Models::ListBlobContainersIncludeFlags::None;
+ try {
+ auto container_list_response =
+ blob_service_client_->ListBlobContainers(options, context);
+ for (; container_list_response.HasPage();
+ container_list_response.MoveToNextPage(context)) {
+ for (const auto& container : container_list_response.BlobContainers) {
+ RETURN_NOT_OK(on_container(container));
+ }
+ }
+ } catch (const Azure::Storage::StorageException& exception) {
+ return internal::ExceptionToStatus("Failed to list account containers.",
exception);
+ }
+ return Status::OK();
+ }
+
+ static FileInfo FileInfoFromBlob(const std::string& container,
+ const
Azure::Storage::Blobs::Models::BlobItem& blob) {
+ if (blob.Name.back() == internal::kSep) {
+ return DirectoryFileInfoFromPath(container + internal::kSep + blob.Name);
+ }
+ std::string path;
+ path.reserve(container.size() + 1 + blob.Name.size());
+ path += container;
+ path += internal::kSep;
+ path += blob.Name;
Review Comment:
Also, if you're keen on micro-optimizating `std::string` allocation, why not
do that as part of `ConcatAbstractPath` and reuse it here? Filesystem code is
sufficiently complex generally that we probably don't want to make it more
obscure by inlining such 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]