77#else
88#include < windows.h>
99#endif
10+ #include < unordered_map>
11+
1012#include " cloud/aws/aws_file_system.h"
11- #include " cloud/gcp/gcp_file_system.h"
1213#include " cloud/cloud_file_system_impl.h"
1314#include " cloud/cloud_log_controller_impl.h"
1415#include " cloud/cloud_manifest.h"
1516#include " cloud/db_cloud_impl.h"
1617#include " cloud/filename.h"
18+ #include " cloud/gcp/gcp_file_system.h"
1719#include " env/composite_env_wrapper.h"
1820#include " options/configurable_helper.h"
1921#include " options/options_helper.h"
2830#include " rocksdb/utilities/object_registry.h"
2931#include " rocksdb/utilities/options_type.h"
3032#include " util/string_util.h"
31- #include < unordered_map>
3233
3334namespace ROCKSDB_NAMESPACE {
3435
@@ -87,8 +88,8 @@ void CloudFileSystemOptions::Dump(Logger* log) const {
8788 }
8889}
8990
90- bool CloudFileSystemOptions::GetNameFromEnvironment (char const * name,
91- char const * alt,
91+ bool CloudFileSystemOptions::GetNameFromEnvironment (const char * name,
92+ const char * alt,
9293 std::string* result) {
9394 char * value = getenv (name); // See if name is set in the environment
9495 if (value == nullptr &&
@@ -102,9 +103,9 @@ bool CloudFileSystemOptions::GetNameFromEnvironment(char const* name,
102103 return false ; // No, return not found
103104 }
104105}
105- void CloudFileSystemOptions::TEST_Initialize (std::string const & bucket,
106- std::string const & object,
107- std::string const & region) {
106+ void CloudFileSystemOptions::TEST_Initialize (const std::string& bucket,
107+ const std::string& object,
108+ const std::string& region) {
108109 src_bucket.TEST_Initialize (bucket, object, region);
109110 dest_bucket = src_bucket;
110111}
@@ -151,9 +152,9 @@ void BucketOptions::SetBucketPrefix(std::string prefix) {
151152
152153// Initializes the bucket properties
153154
154- void BucketOptions::TEST_Initialize (std::string const & bucket,
155- std::string const & object,
156- std::string const & region) {
155+ void BucketOptions::TEST_Initialize (const std::string& bucket,
156+ const std::string& object,
157+ const std::string& region) {
157158 std::string prefix;
158159 // If the bucket name is not set, then the bucket name is not set,
159160 // Set it to either the value of the environment variable or geteuid
@@ -189,83 +190,83 @@ static std::unordered_map<std::string, OptionTypeInfo>
189190 {" object" ,
190191 {0 , OptionType::kString , OptionVerificationType::kNormal ,
191192 OptionTypeFlags::kCompareNever ,
192- [](ConfigOptions const & /* opts*/ , std::string const & /* name*/ ,
193- std::string const & value, void * addr) {
193+ [](const ConfigOptions & /* opts*/ , const std::string& /* name*/ ,
194+ const std::string& value, void * addr) {
194195 auto bucket = static_cast <BucketOptions*>(addr);
195196 bucket->SetObjectPath (value);
196197 return Status::OK ();
197198 },
198- [](ConfigOptions const & /* opts*/ , std::string const & /* name*/ ,
199- void const * addr, std::string* value) {
199+ [](const ConfigOptions & /* opts*/ , const std::string& /* name*/ ,
200+ const void * addr, std::string* value) {
200201 auto bucket = static_cast <const BucketOptions*>(addr);
201202 *value = bucket->GetObjectPath ();
202203 return Status::OK ();
203204 },
204- [](ConfigOptions const & /* opts*/ , std::string const & /* name*/ ,
205- void const * addr1, void const * addr2, std::string* /* mismatch*/ ) {
205+ [](const ConfigOptions & /* opts*/ , const std::string& /* name*/ ,
206+ const void * addr1, const void * addr2, std::string* /* mismatch*/ ) {
206207 auto bucket1 = static_cast <const BucketOptions*>(addr1);
207208 auto bucket2 = static_cast <const BucketOptions*>(addr2);
208209 return bucket1->GetObjectPath () == bucket2->GetObjectPath ();
209210 }}},
210211 {" region" ,
211212 {0 , OptionType::kString , OptionVerificationType::kNormal ,
212213 OptionTypeFlags::kCompareNever ,
213- [](ConfigOptions const & /* opts*/ , std::string const & /* name*/ ,
214- std::string const & value, void * addr) {
214+ [](const ConfigOptions & /* opts*/ , const std::string& /* name*/ ,
215+ const std::string& value, void * addr) {
215216 auto bucket = static_cast <BucketOptions*>(addr);
216217 bucket->SetRegion (value);
217218 return Status::OK ();
218219 },
219- [](ConfigOptions const & /* opts*/ , std::string const & /* name*/ ,
220- void const * addr, std::string* value) {
220+ [](const ConfigOptions & /* opts*/ , const std::string& /* name*/ ,
221+ const void * addr, std::string* value) {
221222 auto bucket = static_cast <const BucketOptions*>(addr);
222223 *value = bucket->GetRegion ();
223224 return Status::OK ();
224225 },
225- [](ConfigOptions const & /* opts*/ , std::string const & /* name*/ ,
226- void const * addr1, void const * addr2, std::string* /* mismatch*/ ) {
226+ [](const ConfigOptions & /* opts*/ , const std::string& /* name*/ ,
227+ const void * addr1, const void * addr2, std::string* /* mismatch*/ ) {
227228 auto bucket1 = static_cast <const BucketOptions*>(addr1);
228229 auto bucket2 = static_cast <const BucketOptions*>(addr2);
229230 return bucket1->GetRegion () == bucket2->GetRegion ();
230231 }}},
231232 {" prefix" ,
232233 {0 , OptionType::kString , OptionVerificationType::kNormal ,
233234 OptionTypeFlags::kNone ,
234- [](ConfigOptions const & /* opts*/ , std::string const & /* name*/ ,
235- std::string const & value, void * addr) {
235+ [](const ConfigOptions & /* opts*/ , const std::string& /* name*/ ,
236+ const std::string& value, void * addr) {
236237 auto bucket = static_cast <BucketOptions*>(addr);
237238 bucket->SetBucketName (bucket->GetBucketName (false ), value);
238239 return Status::OK ();
239240 },
240- [](ConfigOptions const & /* opts*/ , std::string const & /* name*/ ,
241- void const * addr, std::string* value) {
241+ [](const ConfigOptions & /* opts*/ , const std::string& /* name*/ ,
242+ const void * addr, std::string* value) {
242243 auto bucket = static_cast <const BucketOptions*>(addr);
243244 *value = bucket->GetBucketPrefix ();
244245 return Status::OK ();
245246 },
246- [](ConfigOptions const & /* opts*/ , std::string const & /* name*/ ,
247- void const * addr1, void const * addr2, std::string* /* mismatch*/ ) {
247+ [](const ConfigOptions & /* opts*/ , const std::string& /* name*/ ,
248+ const void * addr1, const void * addr2, std::string* /* mismatch*/ ) {
248249 auto bucket1 = static_cast <const BucketOptions*>(addr1);
249250 auto bucket2 = static_cast <const BucketOptions*>(addr2);
250251 return bucket1->GetBucketPrefix () == bucket2->GetBucketPrefix ();
251252 }}},
252253 {" bucket" ,
253254 {0 , OptionType::kString , OptionVerificationType::kNormal ,
254255 OptionTypeFlags::kNone ,
255- [](ConfigOptions const & /* opts*/ , std::string const & /* name*/ ,
256- std::string const & value, void * addr) {
256+ [](const ConfigOptions & /* opts*/ , const std::string& /* name*/ ,
257+ const std::string& value, void * addr) {
257258 auto bucket = static_cast <BucketOptions*>(addr);
258259 bucket->SetBucketName (value);
259260 return Status::OK ();
260261 },
261- [](ConfigOptions const & /* opts*/ , std::string const & /* name*/ ,
262- void const * addr, std::string* value) {
262+ [](const ConfigOptions & /* opts*/ , const std::string& /* name*/ ,
263+ const void * addr, std::string* value) {
263264 auto bucket = static_cast <const BucketOptions*>(addr);
264265 *value = bucket->GetBucketName (false );
265266 return Status::OK ();
266267 },
267- [](ConfigOptions const & /* opts*/ , std::string const & /* name*/ ,
268- void const * addr1, void const * addr2, std::string* /* mismatch*/ ) {
268+ [](const ConfigOptions & /* opts*/ , const std::string& /* name*/ ,
269+ const void * addr1, const void * addr2, std::string* /* mismatch*/ ) {
269270 auto bucket1 = static_cast <const BucketOptions*>(addr1);
270271 auto bucket2 = static_cast <const BucketOptions*>(addr2);
271272 return bucket1->GetBucketName (false ) ==
@@ -274,8 +275,8 @@ static std::unordered_map<std::string, OptionTypeInfo>
274275 {" TEST" ,
275276 {0 , OptionType::kUnknown , OptionVerificationType::kAlias ,
276277 OptionTypeFlags::kNone ,
277- [](ConfigOptions const & /* opts*/ , std::string const & /* name*/ ,
278- std::string const & value, void * addr) {
278+ [](const ConfigOptions & /* opts*/ , const std::string& /* name*/ ,
279+ const std::string& value, void * addr) {
279280 auto bucket = static_cast <BucketOptions*>(addr);
280281 std::string name = value;
281282 std::string path;
@@ -340,8 +341,8 @@ const std::unordered_map<std::string, OptionTypeInfo>
340341 OptionType::kConfigurable , OptionVerificationType::kByNameAllowNull ,
341342 (OptionTypeFlags::kShared | OptionTypeFlags::kCompareLoose |
342343 OptionTypeFlags::kCompareNever | OptionTypeFlags::kAllowNull ),
343- [](ConfigOptions const & opts, std::string const & /* name*/ ,
344- std::string const & value, void * addr) {
344+ [](const ConfigOptions & opts, const std::string& /* name*/ ,
345+ const std::string& value, void * addr) {
345346 auto provider =
346347 static_cast <std::shared_ptr<CloudStorageProvider>*>(addr);
347348 return CloudStorageProvider::CreateFromString (opts, value,
@@ -353,8 +354,8 @@ const std::unordered_map<std::string, OptionTypeInfo>
353354 (OptionTypeFlags::kShared | OptionTypeFlags::kCompareLoose |
354355 OptionTypeFlags::kCompareNever | OptionTypeFlags::kAllowNull ),
355356 // Creates a new TableFactory based on value
356- [](ConfigOptions const & opts, std::string const & /* name*/ ,
357- std::string const & value, void * addr) {
357+ [](const ConfigOptions & opts, const std::string& /* name*/ ,
358+ const std::string& value, void * addr) {
358359 auto controller =
359360 static_cast <std::shared_ptr<CloudLogController>*>(addr);
360361 Status s =
@@ -372,8 +373,8 @@ const std::unordered_map<std::string, OptionTypeInfo>
372373 {" TEST" ,
373374 {0 , OptionType::kUnknown , OptionVerificationType::kAlias ,
374375 OptionTypeFlags::kNone ,
375- [](ConfigOptions const & /* opts*/ , std::string const & /* name*/ ,
376- std::string const & value, void * addr) {
376+ [](const ConfigOptions & /* opts*/ , const std::string& /* name*/ ,
377+ const std::string& value, void * addr) {
377378 auto copts = static_cast <CloudFileSystemOptions*>(addr);
378379 std::string name;
379380 std::string path;
@@ -394,8 +395,8 @@ const std::unordered_map<std::string, OptionTypeInfo>
394395 }}},
395396};
396397
397- Status CloudFileSystemOptions::Configure (ConfigOptions const & config_options,
398- std::string const & opts_str) {
398+ Status CloudFileSystemOptions::Configure (const ConfigOptions & config_options,
399+ const std::string& opts_str) {
399400 std::string current;
400401 Status s;
401402 if (!config_options.ignore_unknown_options ) {
@@ -419,12 +420,12 @@ Status CloudFileSystemOptions::Configure(ConfigOptions const& config_options,
419420 return s;
420421}
421422
422- Status CloudFileSystemOptions::Serialize (ConfigOptions const & config_options,
423+ Status CloudFileSystemOptions::Serialize (const ConfigOptions & config_options,
423424 std::string* value) const {
424425 return OptionTypeInfo::SerializeStruct (
425426 config_options, CloudFileSystemOptions::kName (),
426427 &cloud_fs_option_type_info, CloudFileSystemOptions::kName (),
427- reinterpret_cast <char const *>(this ), value);
428+ reinterpret_cast <const char *>(this ), value);
428429}
429430
430431Status CloudFileSystemEnv::NewAwsFileSystem (
@@ -450,12 +451,12 @@ Status CloudFileSystemEnv::NewAwsFileSystem(
450451}
451452
452453Status CloudFileSystem::NewGcpFileSystem (
453- std::shared_ptr<FileSystem> const & base_fs,
454- std::string const & src_cloud_bucket, std::string const & src_cloud_object,
455- std::string const & src_cloud_region, std::string const & dest_cloud_bucket,
456- std::string const & dest_cloud_object, std::string const & dest_cloud_region,
457- CloudFileSystemOptions const & cloud_options,
458- std::shared_ptr<Logger> const & logger, CloudFileSystem** cfs) {
454+ const std::shared_ptr<FileSystem>& base_fs,
455+ const std::string& src_cloud_bucket, const std::string& src_cloud_object,
456+ const std::string& src_cloud_region, const std::string& dest_cloud_bucket,
457+ const std::string& dest_cloud_object, const std::string& dest_cloud_region,
458+ const CloudFileSystemOptions & cloud_options,
459+ const std::shared_ptr<Logger>& logger, CloudFileSystem** cfs) {
459460 CloudFileSystemOptions options = cloud_options;
460461 if (!src_cloud_bucket.empty ())
461462 options.src_bucket .SetBucketName (src_cloud_bucket);
@@ -471,12 +472,12 @@ Status CloudFileSystem::NewGcpFileSystem(
471472 return NewGcpFileSystem (base_fs, options, logger, cfs);
472473}
473474
474- int DoRegisterCloudObjects (ObjectLibrary& library, std::string const & arg) {
475+ int DoRegisterCloudObjects (ObjectLibrary& library, const std::string& arg) {
475476 int count = 0 ;
476477 // Register the FileSystem types
477478 library.AddFactory <FileSystem>(
478479 CloudFileSystemImpl::kClassName (),
479- [](std::string const & /* uri*/ , std::unique_ptr<FileSystem>* guard,
480+ [](const std::string& /* uri*/ , std::unique_ptr<FileSystem>* guard,
480481 std::string* /* errmsg*/ ) {
481482 guard->reset (new CloudFileSystemImpl (CloudFileSystemOptions (),
482483 FileSystem::Default (),
@@ -496,7 +497,7 @@ int DoRegisterCloudObjects(ObjectLibrary& library, std::string const& arg) {
496497
497498 library.AddFactory <CloudLogController>(
498499 CloudLogControllerImpl::kKafka (),
499- [](std::string const & /* uri*/ , std::unique_ptr<CloudLogController>* guard,
500+ [](const std::string& /* uri*/ , std::unique_ptr<CloudLogController>* guard,
500501 std::string* errmsg) {
501502 Status s = CloudLogControllerImpl::CreateKafkaController (guard);
502503 if (!s.ok ()) {
@@ -669,28 +670,28 @@ Status CloudFileSystemEnv::NewAwsFileSystem(
669670
670671#ifndef USE_GCP
671672Status CloudFileSystem::NewGcpFileSystem (
672- std::shared_ptr<FileSystem> const & /* base_fs*/ ,
673- CloudFileSystemOptions const & /* options*/ ,
674- std::shared_ptr<Logger> const & /* logger*/ , CloudFileSystem** /* cfs*/ ) {
673+ const std::shared_ptr<FileSystem>& /* base_fs*/ ,
674+ const CloudFileSystemOptions & /* options*/ ,
675+ const std::shared_ptr<Logger>& /* logger*/ , CloudFileSystem** /* cfs*/ ) {
675676 return Status::NotSupported (" RocksDB Cloud not compiled with GCP support" );
676677}
677678#else
678679Status CloudFileSystem::NewGcpFileSystem (
679- std::shared_ptr<FileSystem> const & base_fs,
680- CloudFileSystemOptions const & options,
681- std::shared_ptr<Logger> const & logger, CloudFileSystem** cfs) {
680+ const std::shared_ptr<FileSystem>& base_fs,
681+ const CloudFileSystemOptions & options,
682+ const std::shared_ptr<Logger>& logger, CloudFileSystem** cfs) {
682683 CloudFileSystem::RegisterCloudObjects ();
683- // Dump out cloud fs options
684+ // Dump out cloud fs options
684685 options.Dump (logger.get ());
685686
686687 Status st = GcpFileSystem::NewGcpFileSystem (base_fs, options, logger, cfs);
687- if (st.ok ()) {
688- // store a copy to the logger
688+ if (st.ok ()) {
689+ // store a copy to the logger
689690 auto * cloud = static_cast <CloudFileSystemImpl*>(*cfs);
690691 cloud->info_log_ = logger;
691692
692- // start the purge thread only if there is a destination bucket
693- if (options.dest_bucket .IsValid () && options.run_purger ) {
693+ // start the purge thread only if there is a destination bucket
694+ if (options.dest_bucket .IsValid () && options.run_purger ) {
694695 cloud->purge_thread_ = std::thread ([cloud] { cloud->Purger (); });
695696 }
696697 }
0 commit comments