Skip to content

Commit

Permalink
Avoid unnecessary API call if kContainerNotFound
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Newton committed Feb 21, 2024
1 parent aec7b34 commit be33953
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cpp/src/arrow/filesystem/azurefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <atomic>
#include <chrono>
#include <iostream>
#include <memory>
#include <optional>

Expand Down Expand Up @@ -1711,15 +1712,19 @@ class AzureFileSystem::Impl {

auto ensure_not_flat_namespace_directory = [this, location,
blob_container_client]() -> Status {
bool hierarchical_namespace_enabled =
HierarchicalNamespaceSupport(GetFileSystemClient(location.container)) ==
HNSSupport::kEnabled;
if (!hierarchical_namespace_enabled) {
ARROW_ASSIGN_OR_RAISE(
auto hns_support,
HierarchicalNamespaceSupport(GetFileSystemClient(location.container)));
if (hns_support == HNSSupport::kDisabled) {
// Flat namespace so we need to GetFileInfo in-case its a directory.
ARROW_ASSIGN_OR_RAISE(auto status, GetFileInfo(blob_container_client, location))
if (status.type() == FileType::Directory) {
return NotAFile(location);
}
}
// kContainerNotFound - it doesn't exist, so no need to check if its a directory.
// kEnabled - hierarchical namespace so Azure APIs will fail if its a directory. We
// don't need to explicitly check.
return Status::OK();
};

Expand Down

0 comments on commit be33953

Please sign in to comment.