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

Method AppendBlock

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

Source from the content-addressed store, hash-verified

1324 }
1325
1326 Status AppendBlock(const void* data, int64_t nbytes,
1327 std::shared_ptr<Buffer> owned_buffer = nullptr) {
1328 RETURN_NOT_OK(CheckClosed("append"));
1329
1330 if (nbytes == 0) {
1331 return Status::OK();
1332 }
1333
1334 const auto block_id = CreateBlock();
1335
1336 if (background_writes_) {
1337 if (owned_buffer == nullptr) {
1338 ARROW_ASSIGN_OR_RAISE(owned_buffer, AllocateBuffer(nbytes, io_context_.pool()));
1339 memcpy(owned_buffer->mutable_data(), data, nbytes);
1340 } else {
1341 DCHECK_EQ(data, owned_buffer->data());
1342 DCHECK_EQ(nbytes, owned_buffer->size());
1343 }
1344
1345 // The closure keeps the buffer and the upload state alive
1346 auto deferred = [owned_buffer, block_id, block_blob_client = block_blob_client_,
1347 state = upload_state_]() mutable -> Status {
1348 Core::IO::MemoryBodyStream block_content(owned_buffer->data(),
1349 owned_buffer->size());
1350
1351 auto status = StageBlock(block_blob_client.get(), block_id, block_content);
1352 HandleUploadOutcome(state, status);
1353 return Status::OK();
1354 };
1355 RETURN_NOT_OK(io::internal::SubmitIO(io_context_, std::move(deferred)));
1356 } else {
1357 auto append_data = reinterpret_cast<const uint8_t*>(data);
1358 Core::IO::MemoryBodyStream block_content(append_data, nbytes);
1359
1360 RETURN_NOT_OK(StageBlock(block_blob_client_.get(), block_id, block_content));
1361 }
1362
1363 return Status::OK();
1364 }
1365
1366 Status AppendBlock(std::shared_ptr<Buffer> buffer) {
1367 return AppendBlock(buffer->data(), buffer->size(), buffer);

Callers

nothing calls this directly

Calls 11

StageBlockFunction · 0.85
SubmitIOFunction · 0.85
CheckClosedFunction · 0.50
OKFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
AllocateBufferFunction · 0.50
poolMethod · 0.45
mutable_dataMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected