From 2a37491d1bd739b9e8c515f23773dffd63a94eee Mon Sep 17 00:00:00 2001 From: Oliver Layer Date: Wed, 21 Aug 2024 09:23:50 +0200 Subject: [PATCH] PR feedback pitrou #2 --- cpp/src/arrow/filesystem/azurefs.cc | 7 ++++--- cpp/src/arrow/filesystem/azurefs_test.cc | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cpp/src/arrow/filesystem/azurefs.cc b/cpp/src/arrow/filesystem/azurefs.cc index 6659b147df83c..0bad856339729 100644 --- a/cpp/src/arrow/filesystem/azurefs.cc +++ b/cpp/src/arrow/filesystem/azurefs.cc @@ -1198,9 +1198,10 @@ class ObjectAppendStream final : public io::OutputStream { } // We can upload chunks without copying them into a buffer - while (nbytes >= kMaxBlockSizeBytes) { - RETURN_NOT_OK(AppendBlock(data_ptr, kMaxBlockSizeBytes)); - advance_ptr(kMaxBlockSizeBytes); + while (nbytes >= kBlockUploadSizeBytes) { + const auto upload_size = std::min(nbytes, kMaxBlockSizeBytes); + RETURN_NOT_OK(AppendBlock(data_ptr, upload_size)); + advance_ptr(upload_size); } // Buffer remaining bytes diff --git a/cpp/src/arrow/filesystem/azurefs_test.cc b/cpp/src/arrow/filesystem/azurefs_test.cc index cb00a73990417..7363932edb040 100644 --- a/cpp/src/arrow/filesystem/azurefs_test.cc +++ b/cpp/src/arrow/filesystem/azurefs_test.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -46,7 +47,6 @@ #include #include #include -#include #include "arrow/filesystem/path_util.h" #include "arrow/filesystem/test_util.h"