Skip to content

Commit

Permalink
[SYS-7856] Allow empty prefix in RocksDB-Cloud
Browse files Browse the repository at this point in the history
Summary:
See https://github.com/rockset/rs/pull/24132#discussion_r1401179422

Test Plan:
Internal test

Reviewers:
  • Loading branch information
igorcanadi committed Jun 13, 2024
1 parent b939bf8 commit 2d3df10
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 14 additions & 5 deletions cloud/cloud_file_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,27 @@ BucketOptions::BucketOptions() {
"ROCKSDB_CLOUD_TEST_REGION", "ROCKSDB_CLOUD_REGION", &region_);
}

void BucketOptions::SetName() {
if (bucket_.empty()) {
name_.clear();
} else {
name_ = prefix_ + bucket_;
}
}

void BucketOptions::SetBucketName(const std::string& bucket,
const std::string& prefix) {
if (!prefix.empty()) {
prefix_ = prefix;
}

bucket_ = bucket;
if (bucket_.empty()) {
name_.clear();
} else {
name_ = prefix_ + bucket_;
}
SetName();
}

void BucketOptions::SetPrefix(std::string prefix) {
prefix_ = std::move(prefix);
SetName();
}

// Initializes the bucket properties
Expand Down
4 changes: 4 additions & 0 deletions include/rocksdb/cloud/cloud_file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,16 @@ class BucketOptions {
std::string object_; // The object path for the bucket
std::string region_; // The region for the bucket
std::string name_; // The name of the bucket (prefix_ + bucket_)

void SetName();

public:
BucketOptions();
// Sets the name of the bucket to be the new bucket name.
// If prefix is specified, the new bucket name will be [prefix][bucket]
// If no prefix is specified, the bucket name will use the existing prefix
void SetBucketName(const std::string& bucket, const std::string& prefix = "");
void SetBucketPrefix(std::string prefix);
const std::string& GetBucketPrefix() const { return prefix_; }
const std::string& GetBucketName(bool full = true) const {
if (full) {
Expand Down

0 comments on commit 2d3df10

Please sign in to comment.