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

Method OpenAppendStream

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

Source from the content-addressed store, hash-verified

2381 }
2382
2383 Result<std::shared_ptr<ObjectAppendStream>> OpenAppendStream(
2384 const AzureLocation& location,
2385 const std::shared_ptr<const KeyValueMetadata>& metadata, const bool truncate,
2386 AzureFileSystem* fs) {
2387 RETURN_NOT_OK(ValidateFileLocation(location));
2388
2389 const auto blob_container_client = GetBlobContainerClient(location.container);
2390 auto block_blob_client = std::make_shared<Blobs::BlockBlobClient>(
2391 blob_container_client.GetBlockBlobClient(location.path));
2392
2393 auto ensure_not_flat_namespace_directory = [this, location,
2394 blob_container_client]() -> Status {
2395 ARROW_ASSIGN_OR_RAISE(
2396 auto hns_support,
2397 HierarchicalNamespaceSupport(GetFileSystemClient(location.container)));
2398 if (hns_support == HNSSupport::kDisabled) {
2399 // Flat namespace so we need to GetFileInfo in-case its a directory.
2400 ARROW_ASSIGN_OR_RAISE(auto status, GetFileInfo(blob_container_client, location))
2401 if (status.type() == FileType::Directory) {
2402 return NotAFile(location);
2403 }
2404 }
2405 // kContainerNotFound - it doesn't exist, so no need to check if its a directory.
2406 // kEnabled - hierarchical namespace so Azure APIs will fail if its a directory. We
2407 // don't need to explicitly check.
2408 return Status::OK();
2409 };
2410
2411 std::shared_ptr<ObjectAppendStream> stream;
2412 stream = std::make_shared<ObjectAppendStream>(block_blob_client, fs->io_context(),
2413 location, metadata, options_);
2414 RETURN_NOT_OK(stream->Init(truncate, ensure_not_flat_namespace_directory));
2415 return stream;
2416 }
2417
2418 private:
2419 void EnsureEmptyDirExistsImplThatThrows(

Callers

nothing calls this directly

Calls 5

ValidateFileLocationFunction · 0.85
NotAFileFunction · 0.70
OKFunction · 0.50
typeMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected