From 5e37ba433594c5e44f070600c23ca493124bd11e Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Sat, 3 Oct 2020 03:47:45 +0300 Subject: [PATCH] Update DiskS3.cpp --- src/Disks/S3/DiskS3.cpp | 45 +++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/Disks/S3/DiskS3.cpp b/src/Disks/S3/DiskS3.cpp index 13721da629a..2705040841c 100644 --- a/src/Disks/S3/DiskS3.cpp +++ b/src/Disks/S3/DiskS3.cpp @@ -36,33 +36,34 @@ namespace ErrorCodes extern const int NOT_IMPLEMENTED; } -namespace + +/// Helper class to collect keys into chunks of maximum size (to prepare batch requests to AWS API) +class DiskS3::AwsS3KeyKeeper : public std::list> { - /// Helper class to collect keys into chunks of maximum size (to prepare batch requests to AWS API) - class DiskS3::AwsS3KeyKeeper : public std::list> - { - public: - void addKey(const String & key); +public: + void addKey(const String & key); - private: - /// limit for one DeleteObject request - /// see https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html - const static size_t chunk_limit = 1000; - }; +private: + /// limit for one DeleteObject request + /// see https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html + const static size_t chunk_limit = 1000; +}; - void DiskS3::AwsS3KeyKeeper::addKey(const String & key) - { - if (empty() || back().size() >= chunk_limit) - { /// add one more chunk - push_back(value_type()); - back().reserve(chunk_limit); - } - - Aws::S3::Model::ObjectIdentifier obj; - obj.SetKey(key); - back().push_back(obj); +void DiskS3::AwsS3KeyKeeper::addKey(const String & key) +{ + if (empty() || back().size() >= chunk_limit) + { /// add one more chunk + push_back(value_type()); + back().reserve(chunk_limit); } + Aws::S3::Model::ObjectIdentifier obj; + obj.SetKey(key); + back().push_back(obj); +} + +namespace +{ String getRandomName() { std::uniform_int_distribution distribution('a', 'z');