MCPcopy Create free account
hub / github.com/apache/arrow / CreateDir

Method CreateDir

cpp/src/arrow/filesystem/azurefs.cc:3351–3392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3349}
3350
3351Status AzureFileSystem::CreateDir(const std::string& path, bool recursive) {
3352 ARROW_ASSIGN_OR_RAISE(auto location, AzureLocation::FromString(path));
3353 if (location.container.empty()) {
3354 return Status::Invalid("CreateDir requires a non-empty path.");
3355 }
3356
3357 auto container_client = impl_->GetBlobContainerClient(location.container);
3358 if (location.path.empty()) {
3359 // If the path is just the container, the parent (root) trivially exists,
3360 // and the CreateDir operation comes down to just creating the container.
3361 return CreateContainerIfNotExists(location.container, container_client);
3362 }
3363
3364 auto adlfs_client = impl_->GetFileSystemClient(location.container);
3365 ARROW_ASSIGN_OR_RAISE(auto hns_support,
3366 impl_->HierarchicalNamespaceSupport(adlfs_client));
3367 if (hns_support == HNSSupport::kContainerNotFound) {
3368 if (!recursive) {
3369 auto parent = location.parent();
3370 return PathNotFound(parent);
3371 }
3372 RETURN_NOT_OK(CreateContainerIfNotExists(location.container, container_client));
3373 // Perform a second check for HNS support after creating the container.
3374 ARROW_ASSIGN_OR_RAISE(hns_support, impl_->HierarchicalNamespaceSupport(adlfs_client));
3375 if (hns_support == HNSSupport::kContainerNotFound) {
3376 // We only get kContainerNotFound if we are unable to read the properties of the
3377 // container we just created. This is very unlikely, but theoretically possible in
3378 // a concurrent system, so the error is handled to avoid infinite recursion.
3379 return Status::IOError("Unable to read properties of a newly created container: ",
3380 location.container, ": " + container_client.GetUrl());
3381 }
3382 }
3383 // CreateDirOnFileSystem and CreateDirOnContainer can handle the container
3384 // not existing which is useful and necessary here since the only reason
3385 // a container was created above was to check for HNS support when it wasn't
3386 // cached yet.
3387 if (hns_support == HNSSupport::kEnabled) {
3388 return impl_->CreateDirOnFileSystem(adlfs_client, location, recursive);
3389 }
3390 DCHECK_EQ(hns_support, HNSSupport::kDisabled);
3391 return impl_->CreateDirOnContainer(container_client, location, recursive);
3392}
3393
3394Status AzureFileSystem::DeleteDir(const std::string& path) {
3395 ARROW_ASSIGN_OR_RAISE(auto location, AzureLocation::FromString(path));

Callers

nothing calls this directly

Calls 12

IOErrorFunction · 0.85
GetFileSystemClientMethod · 0.80
CreateDirOnFileSystemMethod · 0.80
CreateDirOnContainerMethod · 0.80
PathNotFoundFunction · 0.70
InvalidFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
emptyMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected