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

Function CopyFile

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

Source from the content-addressed store, hash-verified

3251 }
3252
3253 Status CopyFile(const AzureLocation& src, const AzureLocation& dest) {
3254 RETURN_NOT_OK(ValidateFileLocation(src));
3255 RETURN_NOT_OK(ValidateFileLocation(dest));
3256 if (src == dest) {
3257 return Status::OK();
3258 }
3259 auto src_url = GetBlobClient(src.container, src.path).GetUrl();
3260 auto dest_blob_client = GetBlobClient(dest.container, dest.path);
3261 if (!dest.path.empty()) {
3262 auto dest_parent = dest.parent();
3263 if (!dest_parent.path.empty()) {
3264 auto dest_container_client = GetBlobContainerClient(dest_parent.container);
3265 ARROW_ASSIGN_OR_RAISE(auto info, GetFileInfo(dest_container_client, dest_parent));
3266 if (info.type() == FileType::File) {
3267 return NotADir(dest_parent);
3268 }
3269 }
3270 }
3271 try {
3272 // We use StartCopyFromUri instead of CopyFromUri because it supports blobs larger
3273 // than 256 MiB and it doesn't require generating a SAS token to authenticate
3274 // reading a source blob in the same storage account.
3275 auto copy_operation = dest_blob_client.StartCopyFromUri(src_url);
3276 // For large blobs, the copy operation may be slow so we need to poll until it
3277 // completes. We use a polling interval of 1 second.
3278 copy_operation.PollUntilDone(std::chrono::milliseconds(1000));
3279 } catch (const Storage::StorageException& exception) {
3280 // StartCopyFromUri failed or a GetProperties call inside PollUntilDone failed.
3281 return ExceptionToStatus(
3282 exception, "Failed to start blob copy or poll status of ongoing copy. (",
3283 src_url, " -> ", dest_blob_client.GetUrl(), ")");
3284 } catch (const Azure::Core::RequestFailedException& exception) {
3285 // A GetProperties call inside PollUntilDone returned a failed CopyStatus.
3286 return ExceptionToStatus(exception, "Failed to copy blob. (", src_url, " -> ",
3287 dest_blob_client.GetUrl(), ")");
3288 }
3289 return Status::OK();
3290 }
3291};
3292
3293std::atomic<LeaseGuard::SteadyClock::time_point> LeaseGuard::latest_known_expiry_time_ =

Callers 1

MoveMethod · 0.85

Calls 7

ValidateFileLocationFunction · 0.85
ExceptionToStatusFunction · 0.85
NotADirFunction · 0.70
OKFunction · 0.50
emptyMethod · 0.45
parentMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected