Skip to content

Commit

Permalink
Update all unique/shared_ptr instances to be qualified with namespace…
Browse files Browse the repository at this point in the history
… std (facebook#4638)

Summary:
Ran the following commands to recursively change all the files under RocksDB:
```
find . -type f -name "*.cc" -exec sed -i 's/ unique_ptr/ std::unique_ptr/g' {} +
find . -type f -name "*.cc" -exec sed -i 's/<unique_ptr/<std::unique_ptr/g' {} +
find . -type f -name "*.cc" -exec sed -i 's/ shared_ptr/ std::shared_ptr/g' {} +
find . -type f -name "*.cc" -exec sed -i 's/<shared_ptr/<std::shared_ptr/g' {} +
```
Running `make format` updated some formatting on the files touched.
Pull Request resolved: facebook#4638

Differential Revision: D12934992

Pulled By: sagar0

fbshipit-source-id: 45a15d23c230cdd64c08f9c0243e5183934338a8
  • Loading branch information
sagar0 authored and facebook-github-bot committed Nov 9, 2018
1 parent 8ba17f3 commit dc35280
Show file tree
Hide file tree
Showing 139 changed files with 656 additions and 619 deletions.
8 changes: 4 additions & 4 deletions cache/cache_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class CacheTest : public testing::TestWithParam<std::string> {

std::vector<int> deleted_keys_;
std::vector<int> deleted_values_;
shared_ptr<Cache> cache_;
shared_ptr<Cache> cache2_;
std::shared_ptr<Cache> cache_;
std::shared_ptr<Cache> cache2_;

CacheTest()
: cache_(NewCache(kCacheSize, kNumShardBits, false)),
Expand Down Expand Up @@ -145,7 +145,7 @@ class CacheTest : public testing::TestWithParam<std::string> {
CacheTest* CacheTest::current_;

TEST_P(CacheTest, UsageTest) {
// cache is shared_ptr and will be automatically cleaned up.
// cache is std::shared_ptr and will be automatically cleaned up.
const uint64_t kCapacity = 100000;
auto cache = NewCache(kCapacity, 8, false);

Expand Down Expand Up @@ -173,7 +173,7 @@ TEST_P(CacheTest, UsageTest) {
}

TEST_P(CacheTest, PinnedUsageTest) {
// cache is shared_ptr and will be automatically cleaned up.
// cache is std::shared_ptr and will be automatically cleaned up.
const uint64_t kCapacity = 100000;
auto cache = NewCache(kCapacity, 8, false);

Expand Down
4 changes: 2 additions & 2 deletions db/builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ Status BuildTable(

if (iter->Valid() || !range_del_agg->IsEmpty()) {
TableBuilder* builder;
unique_ptr<WritableFileWriter> file_writer;
std::unique_ptr<WritableFileWriter> file_writer;
{
unique_ptr<WritableFile> file;
std::unique_ptr<WritableFile> file;
#ifndef NDEBUG
bool use_direct_writes = env_options.use_direct_writes;
TEST_SYNC_POINT_CALLBACK("BuildTable:create_file", &use_direct_writes);
Expand Down
12 changes: 9 additions & 3 deletions db/c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,20 @@ struct rocksdb_writablefile_t { WritableFile* rep; };
struct rocksdb_wal_iterator_t { TransactionLogIterator* rep; };
struct rocksdb_wal_readoptions_t { TransactionLogIterator::ReadOptions rep; };
struct rocksdb_filelock_t { FileLock* rep; };
struct rocksdb_logger_t { shared_ptr<Logger> rep; };
struct rocksdb_cache_t { shared_ptr<Cache> rep; };
struct rocksdb_logger_t {
std::shared_ptr<Logger> rep;
};
struct rocksdb_cache_t {
std::shared_ptr<Cache> rep;
};
struct rocksdb_livefiles_t { std::vector<LiveFileMetaData> rep; };
struct rocksdb_column_family_handle_t { ColumnFamilyHandle* rep; };
struct rocksdb_envoptions_t { EnvOptions rep; };
struct rocksdb_ingestexternalfileoptions_t { IngestExternalFileOptions rep; };
struct rocksdb_sstfilewriter_t { SstFileWriter* rep; };
struct rocksdb_ratelimiter_t { shared_ptr<RateLimiter> rep; };
struct rocksdb_ratelimiter_t {
std::shared_ptr<RateLimiter> rep;
};
struct rocksdb_perfcontext_t { PerfContext* rep; };
struct rocksdb_pinnableslice_t {
PinnableSlice rep;
Expand Down
6 changes: 3 additions & 3 deletions db/column_family_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class EnvCounter : public EnvWrapper {
int GetNumberOfNewWritableFileCalls() {
return num_new_writable_file_;
}
Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r,
Status NewWritableFile(const std::string& f, std::unique_ptr<WritableFile>* r,
const EnvOptions& soptions) override {
++num_new_writable_file_;
return EnvWrapper::NewWritableFile(f, r, soptions);
Expand Down Expand Up @@ -486,9 +486,9 @@ class ColumnFamilyTestBase : public testing::Test {
void CopyFile(const std::string& source, const std::string& destination,
uint64_t size = 0) {
const EnvOptions soptions;
unique_ptr<SequentialFile> srcfile;
std::unique_ptr<SequentialFile> srcfile;
ASSERT_OK(env_->NewSequentialFile(source, &srcfile, soptions));
unique_ptr<WritableFile> destfile;
std::unique_ptr<WritableFile> destfile;
ASSERT_OK(env_->NewWritableFile(destination, &destfile, soptions));

if (size == 0) {
Expand Down
4 changes: 2 additions & 2 deletions db/compaction_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ struct CompactionJob::SubcompactionState {
return *this;
}

// Because member unique_ptrs do not have these.
// Because member std::unique_ptrs do not have these.
SubcompactionState(const SubcompactionState&) = delete;

SubcompactionState& operator=(const SubcompactionState&) = delete;
Expand Down Expand Up @@ -1445,7 +1445,7 @@ Status CompactionJob::OpenCompactionOutputFile(
TableFileCreationReason::kCompaction);
#endif // !ROCKSDB_LITE
// Make the output file
unique_ptr<WritableFile> writable_file;
std::unique_ptr<WritableFile> writable_file;
#ifndef NDEBUG
bool syncpoint_arg = env_options_.use_direct_writes;
TEST_SYNC_POINT_CALLBACK("CompactionJob::OpenCompactionOutputFile",
Expand Down
4 changes: 2 additions & 2 deletions db/compaction_job_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ class CompactionJobTest : public testing::Test {
new_db.SetLastSequence(0);

const std::string manifest = DescriptorFileName(dbname_, 1);
unique_ptr<WritableFile> file;
std::unique_ptr<WritableFile> file;
Status s = env_->NewWritableFile(
manifest, &file, env_->OptimizeForManifestWrite(env_options_));
ASSERT_OK(s);
unique_ptr<WritableFileWriter> file_writer(
std::unique_ptr<WritableFileWriter> file_writer(
new WritableFileWriter(std::move(file), manifest, env_options_));
{
log::Writer log(std::move(file_writer), 0, false);
Expand Down
4 changes: 2 additions & 2 deletions db/convenience.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Status DeleteFilesInRanges(DB* db, ColumnFamilyHandle* column_family,
Status VerifySstFileChecksum(const Options& options,
const EnvOptions& env_options,
const std::string& file_path) {
unique_ptr<RandomAccessFile> file;
std::unique_ptr<RandomAccessFile> file;
uint64_t file_size;
InternalKeyComparator internal_comparator(options.comparator);
ImmutableCFOptions ioptions(options);
Expand All @@ -46,7 +46,7 @@ Status VerifySstFileChecksum(const Options& options,
} else {
return s;
}
unique_ptr<TableReader> table_reader;
std::unique_ptr<TableReader> table_reader;
std::unique_ptr<RandomAccessFileReader> file_reader(
new RandomAccessFileReader(std::move(file), file_path));
const bool kImmortal = true;
Expand Down
4 changes: 2 additions & 2 deletions db/corruption_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CorruptionTest : public testing::Test {
public:
test::ErrorEnv env_;
std::string dbname_;
shared_ptr<Cache> tiny_cache_;
std::shared_ptr<Cache> tiny_cache_;
Options options_;
DB* db_;

Expand Down Expand Up @@ -485,7 +485,7 @@ TEST_F(CorruptionTest, FileSystemStateCorrupted) {
db_ = nullptr;

if (iter == 0) { // corrupt file size
unique_ptr<WritableFile> file;
std::unique_ptr<WritableFile> file;
env_.NewWritableFile(filename, &file, EnvOptions());
file->Append(Slice("corrupted sst"));
file.reset();
Expand Down
2 changes: 1 addition & 1 deletion db/db_basic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ class TestEnv : public EnvWrapper {
int GetCloseCount() { return close_count; }

virtual Status NewLogger(const std::string& /*fname*/,
shared_ptr<Logger>* result) {
std::shared_ptr<Logger>* result) {
result->reset(new TestLogger(this));
return Status::OK();
}
Expand Down
2 changes: 1 addition & 1 deletion db/db_bloom_filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ TEST_P(BloomStatsTestWithParam, BloomStatsTestWithIter) {
ASSERT_OK(Put(key1, value1, WriteOptions()));
ASSERT_OK(Put(key3, value3, WriteOptions()));

unique_ptr<Iterator> iter(dbfull()->NewIterator(ReadOptions()));
std::unique_ptr<Iterator> iter(dbfull()->NewIterator(ReadOptions()));

// check memtable bloom stats
iter->Seek(key1);
Expand Down
2 changes: 1 addition & 1 deletion db/db_dynamic_level_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TEST_F(DBTestDynamicLevel, DynamicLevelMaxBytesBase) {
return;
}
// Use InMemoryEnv, or it would be too slow.
unique_ptr<Env> env(new MockEnv(env_));
std::unique_ptr<Env> env(new MockEnv(env_));

const int kNKeys = 1000;
int keys[kNKeys];
Expand Down
2 changes: 1 addition & 1 deletion db/db_encryption_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ TEST_F(DBEncryptionTest, CheckEncrypted) {
continue;
}
auto filePath = dbname_ + "/" + *it;
unique_ptr<SequentialFile> seqFile;
std::unique_ptr<SequentialFile> seqFile;
auto envOptions = EnvOptions(CurrentOptions());
status = defaultEnv->NewSequentialFile(filePath, &seqFile, envOptions);
ASSERT_OK(status);
Expand Down
7 changes: 3 additions & 4 deletions db/db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2295,9 +2295,8 @@ void DBImpl::ReleaseFileNumberFromPendingOutputs(

#ifndef ROCKSDB_LITE
Status DBImpl::GetUpdatesSince(
SequenceNumber seq, unique_ptr<TransactionLogIterator>* iter,
SequenceNumber seq, std::unique_ptr<TransactionLogIterator>* iter,
const TransactionLogIterator::ReadOptions& read_options) {

RecordTick(stats_, GET_UPDATES_SINCE_CALLS);
if (seq > versions_->LastSequence()) {
return Status::NotFound("Requested sequence not yet written in the db");
Expand Down Expand Up @@ -2545,10 +2544,10 @@ Status DBImpl::CheckConsistency() {
Status DBImpl::GetDbIdentity(std::string& identity) const {
std::string idfilename = IdentityFileName(dbname_);
const EnvOptions soptions;
unique_ptr<SequentialFileReader> id_file_reader;
std::unique_ptr<SequentialFileReader> id_file_reader;
Status s;
{
unique_ptr<SequentialFile> idfile;
std::unique_ptr<SequentialFile> idfile;
s = env_->NewSequentialFile(idfilename, &idfile, soptions);
if (!s.ok()) {
return s;
Expand Down
14 changes: 7 additions & 7 deletions db/db_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ class DBImpl : public DB {
virtual Status GetSortedWalFiles(VectorLogPtr& files) override;

virtual Status GetUpdatesSince(
SequenceNumber seq_number, unique_ptr<TransactionLogIterator>* iter,
const TransactionLogIterator::ReadOptions&
read_options = TransactionLogIterator::ReadOptions()) override;
SequenceNumber seq_number, std::unique_ptr<TransactionLogIterator>* iter,
const TransactionLogIterator::ReadOptions& read_options =
TransactionLogIterator::ReadOptions()) override;
virtual Status DeleteFile(std::string name) override;
Status DeleteFilesInRanges(ColumnFamilyHandle* column_family,
const RangePtr* ranges, size_t n,
Expand Down Expand Up @@ -714,7 +714,7 @@ class DBImpl : public DB {
protected:
Env* const env_;
const std::string dbname_;
unique_ptr<VersionSet> versions_;
std::unique_ptr<VersionSet> versions_;
// Flag to check whether we allocated and own the info log file
bool own_info_log_;
const DBOptions initial_db_options_;
Expand Down Expand Up @@ -1190,7 +1190,7 @@ class DBImpl : public DB {
bool log_empty_;
ColumnFamilyHandleImpl* default_cf_handle_;
InternalStats* default_cf_internal_stats_;
unique_ptr<ColumnFamilyMemTablesImpl> column_family_memtables_;
std::unique_ptr<ColumnFamilyMemTablesImpl> column_family_memtables_;
struct LogFileNumberSize {
explicit LogFileNumberSize(uint64_t _number)
: number(_number) {}
Expand Down Expand Up @@ -1218,7 +1218,7 @@ class DBImpl : public DB {

uint64_t number;
// Visual Studio doesn't support deque's member to be noncopyable because
// of a unique_ptr as a member.
// of a std::unique_ptr as a member.
log::Writer* writer; // own
// true for some prefix of logs_
bool getting_synced = false;
Expand Down Expand Up @@ -1304,7 +1304,7 @@ class DBImpl : public DB {

WriteController write_controller_;

unique_ptr<RateLimiter> low_pri_write_rate_limiter_;
std::unique_ptr<RateLimiter> low_pri_write_rate_limiter_;

// Size of the last batch group. In slowdown mode, next write needs to
// sleep if it uses up the quota.
Expand Down
4 changes: 2 additions & 2 deletions db/db_impl_compaction_flush.cc
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ Status DBImpl::CompactFilesImpl(
// At this point, CompactFiles will be run.
bg_compaction_scheduled_++;

unique_ptr<Compaction> c;
std::unique_ptr<Compaction> c;
assert(cfd->compaction_picker());
c.reset(cfd->compaction_picker()->CompactFiles(
compact_options, input_files, output_level, version->storage_info(),
Expand Down Expand Up @@ -2145,7 +2145,7 @@ Status DBImpl::BackgroundCompaction(bool* made_progress,
TEST_SYNC_POINT("DBImpl::BackgroundCompaction:Start");

bool is_manual = (manual_compaction != nullptr);
unique_ptr<Compaction> c;
std::unique_ptr<Compaction> c;
if (prepicked_compaction != nullptr &&
prepicked_compaction->compaction != nullptr) {
c.reset(prepicked_compaction->compaction);
Expand Down
14 changes: 7 additions & 7 deletions db/db_impl_open.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ Status DBImpl::NewDB() {
ROCKS_LOG_INFO(immutable_db_options_.info_log, "Creating manifest 1 \n");
const std::string manifest = DescriptorFileName(dbname_, 1);
{
unique_ptr<WritableFile> file;
std::unique_ptr<WritableFile> file;
EnvOptions env_options = env_->OptimizeForManifestWrite(env_options_);
s = NewWritableFile(env_, manifest, &file, env_options);
if (!s.ok()) {
return s;
}
file->SetPreallocationBlockSize(
immutable_db_options_.manifest_preallocation_size);
unique_ptr<WritableFileWriter> file_writer(new WritableFileWriter(
std::unique_ptr<WritableFileWriter> file_writer(new WritableFileWriter(
std::move(file), manifest, env_options, nullptr /* stats */,
immutable_db_options_.listeners));
log::Writer log(std::move(file_writer), 0, false);
Expand Down Expand Up @@ -362,7 +362,7 @@ Status DBImpl::Recover(
}
// Verify compatibility of env_options_ and filesystem
{
unique_ptr<RandomAccessFile> idfile;
std::unique_ptr<RandomAccessFile> idfile;
EnvOptions customized_env(env_options_);
customized_env.use_direct_reads |=
immutable_db_options_.use_direct_io_for_flush_and_compaction;
Expand Down Expand Up @@ -573,9 +573,9 @@ Status DBImpl::RecoverLogFiles(const std::vector<uint64_t>& log_numbers,
continue;
}

unique_ptr<SequentialFileReader> file_reader;
std::unique_ptr<SequentialFileReader> file_reader;
{
unique_ptr<SequentialFile> file;
std::unique_ptr<SequentialFile> file;
status = env_->NewSequentialFile(fname, &file,
env_->OptimizeForLogRead(env_options_));
if (!status.ok()) {
Expand Down Expand Up @@ -1129,7 +1129,7 @@ Status DBImpl::Open(const DBOptions& db_options, const std::string& dbname,
s = impl->Recover(column_families);
if (s.ok()) {
uint64_t new_log_number = impl->versions_->NewFileNumber();
unique_ptr<WritableFile> lfile;
std::unique_ptr<WritableFile> lfile;
EnvOptions soptions(db_options);
EnvOptions opt_env_options =
impl->immutable_db_options_.env->OptimizeForLogWrite(
Expand All @@ -1147,7 +1147,7 @@ Status DBImpl::Open(const DBOptions& db_options, const std::string& dbname,
InstrumentedMutexLock wl(&impl->log_write_mutex_);
impl->logfile_number_ = new_log_number;
const auto& listeners = impl->immutable_db_options_.listeners;
unique_ptr<WritableFileWriter> file_writer(
std::unique_ptr<WritableFileWriter> file_writer(
new WritableFileWriter(std::move(lfile), log_fname, opt_env_options,
nullptr /* stats */, listeners));
impl->logs_.emplace_back(
Expand Down
4 changes: 2 additions & 2 deletions db/db_impl_write.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ Status DBImpl::SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context) {
nonmem_write_thread_.EnterUnbatched(&nonmem_w, &mutex_);
}

unique_ptr<WritableFile> lfile;
std::unique_ptr<WritableFile> lfile;
log::Writer* new_log = nullptr;
MemTable* new_mem = nullptr;

Expand Down Expand Up @@ -1455,7 +1455,7 @@ Status DBImpl::SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context) {
// of calling GetWalPreallocateBlockSize()
lfile->SetPreallocationBlockSize(preallocate_block_size);
lfile->SetWriteLifeTimeHint(write_hint);
unique_ptr<WritableFileWriter> file_writer(new WritableFileWriter(
std::unique_ptr<WritableFileWriter> file_writer(new WritableFileWriter(
std::move(lfile), log_fname, opt_env_opt, nullptr /* stats */,
immutable_db_options_.listeners));
new_log = new log::Writer(
Expand Down
Loading

0 comments on commit dc35280

Please sign in to comment.