From dc3528077a4f39723736633c7cac2f62c25894af Mon Sep 17 00:00:00 2001 From: Sagar Vemuri Date: Fri, 9 Nov 2018 11:17:34 -0800 Subject: [PATCH] Update all unique/shared_ptr instances to be qualified with namespace std (#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/ { std::vector deleted_keys_; std::vector deleted_values_; - shared_ptr cache_; - shared_ptr cache2_; + std::shared_ptr cache_; + std::shared_ptr cache2_; CacheTest() : cache_(NewCache(kCacheSize, kNumShardBits, false)), @@ -145,7 +145,7 @@ class CacheTest : public testing::TestWithParam { 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); @@ -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); diff --git a/db/builder.cc b/db/builder.cc index 2192d4c9a..0d896846f 100644 --- a/db/builder.cc +++ b/db/builder.cc @@ -104,9 +104,9 @@ Status BuildTable( if (iter->Valid() || !range_del_agg->IsEmpty()) { TableBuilder* builder; - unique_ptr file_writer; + std::unique_ptr file_writer; { - unique_ptr file; + std::unique_ptr file; #ifndef NDEBUG bool use_direct_writes = env_options.use_direct_writes; TEST_SYNC_POINT_CALLBACK("BuildTable:create_file", &use_direct_writes); diff --git a/db/c.cc b/db/c.cc index 1b44cab2f..aa75a8186 100644 --- a/db/c.cc +++ b/db/c.cc @@ -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 rep; }; -struct rocksdb_cache_t { shared_ptr rep; }; +struct rocksdb_logger_t { + std::shared_ptr rep; +}; +struct rocksdb_cache_t { + std::shared_ptr rep; +}; struct rocksdb_livefiles_t { std::vector 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 rep; }; +struct rocksdb_ratelimiter_t { + std::shared_ptr rep; +}; struct rocksdb_perfcontext_t { PerfContext* rep; }; struct rocksdb_pinnableslice_t { PinnableSlice rep; diff --git a/db/column_family_test.cc b/db/column_family_test.cc index e8a0420f3..07cc5dd13 100644 --- a/db/column_family_test.cc +++ b/db/column_family_test.cc @@ -47,7 +47,7 @@ class EnvCounter : public EnvWrapper { int GetNumberOfNewWritableFileCalls() { return num_new_writable_file_; } - Status NewWritableFile(const std::string& f, unique_ptr* r, + Status NewWritableFile(const std::string& f, std::unique_ptr* r, const EnvOptions& soptions) override { ++num_new_writable_file_; return EnvWrapper::NewWritableFile(f, r, soptions); @@ -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 srcfile; + std::unique_ptr srcfile; ASSERT_OK(env_->NewSequentialFile(source, &srcfile, soptions)); - unique_ptr destfile; + std::unique_ptr destfile; ASSERT_OK(env_->NewWritableFile(destination, &destfile, soptions)); if (size == 0) { diff --git a/db/compaction_job.cc b/db/compaction_job.cc index d4aa28bad..38b665040 100644 --- a/db/compaction_job.cc +++ b/db/compaction_job.cc @@ -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; @@ -1445,7 +1445,7 @@ Status CompactionJob::OpenCompactionOutputFile( TableFileCreationReason::kCompaction); #endif // !ROCKSDB_LITE // Make the output file - unique_ptr writable_file; + std::unique_ptr writable_file; #ifndef NDEBUG bool syncpoint_arg = env_options_.use_direct_writes; TEST_SYNC_POINT_CALLBACK("CompactionJob::OpenCompactionOutputFile", diff --git a/db/compaction_job_test.cc b/db/compaction_job_test.cc index 3eb5dd704..c7da191dd 100644 --- a/db/compaction_job_test.cc +++ b/db/compaction_job_test.cc @@ -200,11 +200,11 @@ class CompactionJobTest : public testing::Test { new_db.SetLastSequence(0); const std::string manifest = DescriptorFileName(dbname_, 1); - unique_ptr file; + std::unique_ptr file; Status s = env_->NewWritableFile( manifest, &file, env_->OptimizeForManifestWrite(env_options_)); ASSERT_OK(s); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(file), manifest, env_options_)); { log::Writer log(std::move(file_writer), 0, false); diff --git a/db/convenience.cc b/db/convenience.cc index 880b84069..71c237f60 100644 --- a/db/convenience.cc +++ b/db/convenience.cc @@ -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 file; + std::unique_ptr file; uint64_t file_size; InternalKeyComparator internal_comparator(options.comparator); ImmutableCFOptions ioptions(options); @@ -46,7 +46,7 @@ Status VerifySstFileChecksum(const Options& options, } else { return s; } - unique_ptr table_reader; + std::unique_ptr table_reader; std::unique_ptr file_reader( new RandomAccessFileReader(std::move(file), file_path)); const bool kImmortal = true; diff --git a/db/corruption_test.cc b/db/corruption_test.cc index 9488c07fe..3bee4c6b2 100644 --- a/db/corruption_test.cc +++ b/db/corruption_test.cc @@ -37,7 +37,7 @@ class CorruptionTest : public testing::Test { public: test::ErrorEnv env_; std::string dbname_; - shared_ptr tiny_cache_; + std::shared_ptr tiny_cache_; Options options_; DB* db_; @@ -485,7 +485,7 @@ TEST_F(CorruptionTest, FileSystemStateCorrupted) { db_ = nullptr; if (iter == 0) { // corrupt file size - unique_ptr file; + std::unique_ptr file; env_.NewWritableFile(filename, &file, EnvOptions()); file->Append(Slice("corrupted sst")); file.reset(); diff --git a/db/db_basic_test.cc b/db/db_basic_test.cc index 6e77f10ec..1c7e4a5c0 100644 --- a/db/db_basic_test.cc +++ b/db/db_basic_test.cc @@ -881,7 +881,7 @@ class TestEnv : public EnvWrapper { int GetCloseCount() { return close_count; } virtual Status NewLogger(const std::string& /*fname*/, - shared_ptr* result) { + std::shared_ptr* result) { result->reset(new TestLogger(this)); return Status::OK(); } diff --git a/db/db_bloom_filter_test.cc b/db/db_bloom_filter_test.cc index 0168b7e2d..2fd5d6dfb 100644 --- a/db/db_bloom_filter_test.cc +++ b/db/db_bloom_filter_test.cc @@ -897,7 +897,7 @@ TEST_P(BloomStatsTestWithParam, BloomStatsTestWithIter) { ASSERT_OK(Put(key1, value1, WriteOptions())); ASSERT_OK(Put(key3, value3, WriteOptions())); - unique_ptr iter(dbfull()->NewIterator(ReadOptions())); + std::unique_ptr iter(dbfull()->NewIterator(ReadOptions())); // check memtable bloom stats iter->Seek(key1); diff --git a/db/db_dynamic_level_test.cc b/db/db_dynamic_level_test.cc index 3f33027d1..eb2db8939 100644 --- a/db/db_dynamic_level_test.cc +++ b/db/db_dynamic_level_test.cc @@ -27,7 +27,7 @@ TEST_F(DBTestDynamicLevel, DynamicLevelMaxBytesBase) { return; } // Use InMemoryEnv, or it would be too slow. - unique_ptr env(new MockEnv(env_)); + std::unique_ptr env(new MockEnv(env_)); const int kNKeys = 1000; int keys[kNKeys]; diff --git a/db/db_encryption_test.cc b/db/db_encryption_test.cc index 38eee5645..46ba411b6 100644 --- a/db/db_encryption_test.cc +++ b/db/db_encryption_test.cc @@ -40,7 +40,7 @@ TEST_F(DBEncryptionTest, CheckEncrypted) { continue; } auto filePath = dbname_ + "/" + *it; - unique_ptr seqFile; + std::unique_ptr seqFile; auto envOptions = EnvOptions(CurrentOptions()); status = defaultEnv->NewSequentialFile(filePath, &seqFile, envOptions); ASSERT_OK(status); diff --git a/db/db_impl.cc b/db/db_impl.cc index cf4e84675..7d5a87c68 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -2295,9 +2295,8 @@ void DBImpl::ReleaseFileNumberFromPendingOutputs( #ifndef ROCKSDB_LITE Status DBImpl::GetUpdatesSince( - SequenceNumber seq, unique_ptr* iter, + SequenceNumber seq, std::unique_ptr* 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"); @@ -2545,10 +2544,10 @@ Status DBImpl::CheckConsistency() { Status DBImpl::GetDbIdentity(std::string& identity) const { std::string idfilename = IdentityFileName(dbname_); const EnvOptions soptions; - unique_ptr id_file_reader; + std::unique_ptr id_file_reader; Status s; { - unique_ptr idfile; + std::unique_ptr idfile; s = env_->NewSequentialFile(idfilename, &idfile, soptions); if (!s.ok()) { return s; diff --git a/db/db_impl.h b/db/db_impl.h index 4fb4e002e..71caff30c 100644 --- a/db/db_impl.h +++ b/db/db_impl.h @@ -259,9 +259,9 @@ class DBImpl : public DB { virtual Status GetSortedWalFiles(VectorLogPtr& files) override; virtual Status GetUpdatesSince( - SequenceNumber seq_number, unique_ptr* iter, - const TransactionLogIterator::ReadOptions& - read_options = TransactionLogIterator::ReadOptions()) override; + SequenceNumber seq_number, std::unique_ptr* 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, @@ -714,7 +714,7 @@ class DBImpl : public DB { protected: Env* const env_; const std::string dbname_; - unique_ptr versions_; + std::unique_ptr versions_; // Flag to check whether we allocated and own the info log file bool own_info_log_; const DBOptions initial_db_options_; @@ -1190,7 +1190,7 @@ class DBImpl : public DB { bool log_empty_; ColumnFamilyHandleImpl* default_cf_handle_; InternalStats* default_cf_internal_stats_; - unique_ptr column_family_memtables_; + std::unique_ptr column_family_memtables_; struct LogFileNumberSize { explicit LogFileNumberSize(uint64_t _number) : number(_number) {} @@ -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; @@ -1304,7 +1304,7 @@ class DBImpl : public DB { WriteController write_controller_; - unique_ptr low_pri_write_rate_limiter_; + std::unique_ptr 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. diff --git a/db/db_impl_compaction_flush.cc b/db/db_impl_compaction_flush.cc index 851683244..63c329aa8 100644 --- a/db/db_impl_compaction_flush.cc +++ b/db/db_impl_compaction_flush.cc @@ -820,7 +820,7 @@ Status DBImpl::CompactFilesImpl( // At this point, CompactFiles will be run. bg_compaction_scheduled_++; - unique_ptr c; + std::unique_ptr c; assert(cfd->compaction_picker()); c.reset(cfd->compaction_picker()->CompactFiles( compact_options, input_files, output_level, version->storage_info(), @@ -2145,7 +2145,7 @@ Status DBImpl::BackgroundCompaction(bool* made_progress, TEST_SYNC_POINT("DBImpl::BackgroundCompaction:Start"); bool is_manual = (manual_compaction != nullptr); - unique_ptr c; + std::unique_ptr c; if (prepicked_compaction != nullptr && prepicked_compaction->compaction != nullptr) { c.reset(prepicked_compaction->compaction); diff --git a/db/db_impl_open.cc b/db/db_impl_open.cc index c595d395c..fab843955 100644 --- a/db/db_impl_open.cc +++ b/db/db_impl_open.cc @@ -230,7 +230,7 @@ Status DBImpl::NewDB() { ROCKS_LOG_INFO(immutable_db_options_.info_log, "Creating manifest 1 \n"); const std::string manifest = DescriptorFileName(dbname_, 1); { - unique_ptr file; + std::unique_ptr file; EnvOptions env_options = env_->OptimizeForManifestWrite(env_options_); s = NewWritableFile(env_, manifest, &file, env_options); if (!s.ok()) { @@ -238,7 +238,7 @@ Status DBImpl::NewDB() { } file->SetPreallocationBlockSize( immutable_db_options_.manifest_preallocation_size); - unique_ptr file_writer(new WritableFileWriter( + std::unique_ptr 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); @@ -362,7 +362,7 @@ Status DBImpl::Recover( } // Verify compatibility of env_options_ and filesystem { - unique_ptr idfile; + std::unique_ptr idfile; EnvOptions customized_env(env_options_); customized_env.use_direct_reads |= immutable_db_options_.use_direct_io_for_flush_and_compaction; @@ -573,9 +573,9 @@ Status DBImpl::RecoverLogFiles(const std::vector& log_numbers, continue; } - unique_ptr file_reader; + std::unique_ptr file_reader; { - unique_ptr file; + std::unique_ptr file; status = env_->NewSequentialFile(fname, &file, env_->OptimizeForLogRead(env_options_)); if (!status.ok()) { @@ -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 lfile; + std::unique_ptr lfile; EnvOptions soptions(db_options); EnvOptions opt_env_options = impl->immutable_db_options_.env->OptimizeForLogWrite( @@ -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 file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(lfile), log_fname, opt_env_options, nullptr /* stats */, listeners)); impl->logs_.emplace_back( diff --git a/db/db_impl_write.cc b/db/db_impl_write.cc index a9ea3a788..3b2e4561d 100644 --- a/db/db_impl_write.cc +++ b/db/db_impl_write.cc @@ -1371,7 +1371,7 @@ Status DBImpl::SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context) { nonmem_write_thread_.EnterUnbatched(&nonmem_w, &mutex_); } - unique_ptr lfile; + std::unique_ptr lfile; log::Writer* new_log = nullptr; MemTable* new_mem = nullptr; @@ -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 file_writer(new WritableFileWriter( + std::unique_ptr file_writer(new WritableFileWriter( std::move(lfile), log_fname, opt_env_opt, nullptr /* stats */, immutable_db_options_.listeners)); new_log = new log::Writer( diff --git a/db/db_iterator_test.cc b/db/db_iterator_test.cc index eb7b52c0c..994a838dd 100644 --- a/db/db_iterator_test.cc +++ b/db/db_iterator_test.cc @@ -85,7 +85,7 @@ TEST_P(DBIteratorTest, IteratorProperty) { ReadOptions ropt; ropt.pin_data = false; { - unique_ptr iter(NewIterator(ropt, handles_[1])); + std::unique_ptr iter(NewIterator(ropt, handles_[1])); iter->SeekToFirst(); std::string prop_value; ASSERT_NOK(iter->GetProperty("non_existing.value", &prop_value)); @@ -2373,7 +2373,7 @@ TEST_P(DBIteratorTest, SeekAfterHittingManyInternalKeys) { Delete("5"); Put("6", "val_6"); - unique_ptr iter(NewIterator(ropts)); + std::unique_ptr iter(NewIterator(ropts)); iter->SeekToFirst(); ASSERT_TRUE(iter->Valid()); @@ -2392,7 +2392,7 @@ TEST_P(DBIteratorTest, SeekAfterHittingManyInternalKeys) { ASSERT_EQ("4", prop_value); // Create a new iterator to seek to the internal key. - unique_ptr iter2(NewIterator(ropts)); + std::unique_ptr iter2(NewIterator(ropts)); iter2->Seek(prop_value); ASSERT_TRUE(iter2->Valid()); ASSERT_OK(iter2->status()); @@ -2420,7 +2420,7 @@ TEST_P(DBIteratorTest, NonBlockingIterationBugRepro) { // Create a nonblocking iterator before writing to memtable. ReadOptions ropt; ropt.read_tier = kBlockCacheTier; - unique_ptr iter(NewIterator(ropt)); + std::unique_ptr iter(NewIterator(ropt)); // Overwrite a key in memtable many times to hit // max_sequential_skip_in_iterations (which is 8 by default). @@ -2430,7 +2430,7 @@ TEST_P(DBIteratorTest, NonBlockingIterationBugRepro) { // Load the second block in sst file into the block cache. { - unique_ptr iter2(NewIterator(ReadOptions())); + std::unique_ptr iter2(NewIterator(ReadOptions())); iter2->Seek("d"); } diff --git a/db/db_log_iter_test.cc b/db/db_log_iter_test.cc index 1370c65ca..a8c92ca26 100644 --- a/db/db_log_iter_test.cc +++ b/db/db_log_iter_test.cc @@ -23,7 +23,7 @@ class DBTestXactLogIterator : public DBTestBase { std::unique_ptr OpenTransactionLogIter( const SequenceNumber seq) { - unique_ptr iter; + std::unique_ptr iter; Status status = dbfull()->GetUpdatesSince(seq, &iter); EXPECT_OK(status); EXPECT_TRUE(iter->Valid()); diff --git a/db/db_properties_test.cc b/db/db_properties_test.cc index 115cf682f..3745135bf 100644 --- a/db/db_properties_test.cc +++ b/db/db_properties_test.cc @@ -446,7 +446,7 @@ TEST_F(DBPropertiesTest, ReadLatencyHistogramByLevel) { ASSERT_EQ(std::string::npos, prop.find("** Level 1 read latency histogram")); ASSERT_EQ(std::string::npos, prop.find("** Level 2 read latency histogram")); { - unique_ptr iter(db_->NewIterator(ReadOptions())); + std::unique_ptr iter(db_->NewIterator(ReadOptions())); for (iter->Seek(Key(0)); iter->Valid(); iter->Next()) { } } diff --git a/db/db_test.cc b/db/db_test.cc index 85cb37050..a0a32f6cd 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -93,7 +93,7 @@ class DBTestWithParam }; TEST_F(DBTest, MockEnvTest) { - unique_ptr env{new MockEnv(Env::Default())}; + std::unique_ptr env{new MockEnv(Env::Default())}; Options options; options.create_if_missing = true; options.env = env.get(); @@ -143,7 +143,7 @@ TEST_F(DBTest, MockEnvTest) { // defined. #ifndef ROCKSDB_LITE TEST_F(DBTest, MemEnvTest) { - unique_ptr env{NewMemEnv(Env::Default())}; + std::unique_ptr env{NewMemEnv(Env::Default())}; Options options; options.create_if_missing = true; options.env = env.get(); @@ -2689,7 +2689,8 @@ class ModelDB : public DB { } virtual Status GetUpdatesSince( - rocksdb::SequenceNumber, unique_ptr*, + rocksdb::SequenceNumber, + std::unique_ptr*, const TransactionLogIterator::ReadOptions& /*read_options*/ = TransactionLogIterator::ReadOptions()) override { return Status::NotSupported("Not supported in Model DB"); diff --git a/db/db_test2.cc b/db/db_test2.cc index f2eae2355..b60ad3afc 100644 --- a/db/db_test2.cc +++ b/db/db_test2.cc @@ -61,7 +61,7 @@ TEST_P(PrefixFullBloomWithReverseComparator, bbto.block_cache->EraseUnRefEntries(); } - unique_ptr iter(db_->NewIterator(ReadOptions())); + std::unique_ptr iter(db_->NewIterator(ReadOptions())); iter->Seek("bar345"); ASSERT_OK(iter->status()); ASSERT_TRUE(iter->Valid()); @@ -2692,7 +2692,7 @@ TEST_F(DBTest2, DISABLED_IteratorPinnedMemory) { // Verify that iterators don't pin more than one data block in block cache // at each time. { - unique_ptr iter(db_->NewIterator(ReadOptions())); + std::unique_ptr iter(db_->NewIterator(ReadOptions())); iter->SeekToFirst(); for (int i = 0; i < 4; i++) { diff --git a/db/db_test_util.cc b/db/db_test_util.cc index c16310859..a0ee69c94 100644 --- a/db/db_test_util.cc +++ b/db/db_test_util.cc @@ -653,12 +653,13 @@ Status DBTestBase::ReadOnlyReopen(const Options& options) { Status DBTestBase::TryReopen(const Options& options) { Close(); last_options_.table_factory.reset(); - // Note: operator= is an unsafe approach here since it destructs shared_ptr in - // the same order of their creation, in contrast to destructors which - // destructs them in the opposite order of creation. One particular problme is - // that the cache destructor might invoke callback functions that use Option - // members such as statistics. To work around this problem, we manually call - // destructor of table_facotry which eventually clears the block cache. + // Note: operator= is an unsafe approach here since it destructs + // std::shared_ptr in the same order of their creation, in contrast to + // destructors which destructs them in the opposite order of creation. One + // particular problme is that the cache destructor might invoke callback + // functions that use Option members such as statistics. To work around this + // problem, we manually call destructor of table_facotry which eventually + // clears the block cache. last_options_ = options; return DB::Open(options, dbname_, &db_); } @@ -670,7 +671,7 @@ bool DBTestBase::IsDirectIOSupported() { std::string tmp = TempFileName(dbname_, 999); Status s; { - unique_ptr file; + std::unique_ptr file; s = env_->NewWritableFile(tmp, &file, env_options); } if (s.ok()) { @@ -1264,9 +1265,9 @@ void DBTestBase::validateNumberOfEntries(int numValues, int cf) { void DBTestBase::CopyFile(const std::string& source, const std::string& destination, uint64_t size) { const EnvOptions soptions; - unique_ptr srcfile; + std::unique_ptr srcfile; ASSERT_OK(env_->NewSequentialFile(source, &srcfile, soptions)); - unique_ptr destfile; + std::unique_ptr destfile; ASSERT_OK(env_->NewWritableFile(destination, &destfile, soptions)); if (size == 0) { diff --git a/db/db_test_util.h b/db/db_test_util.h index 71b9fa366..7c2d79498 100644 --- a/db/db_test_util.h +++ b/db/db_test_util.h @@ -169,7 +169,7 @@ class SpecialMemTableRep : public MemTableRep { virtual ~SpecialMemTableRep() override {} private: - unique_ptr memtable_; + std::unique_ptr memtable_; int num_entries_flush_; int num_entries_; }; @@ -207,15 +207,15 @@ class SpecialEnv : public EnvWrapper { public: explicit SpecialEnv(Env* base); - Status NewWritableFile(const std::string& f, unique_ptr* r, + Status NewWritableFile(const std::string& f, std::unique_ptr* r, const EnvOptions& soptions) override { class SSTableFile : public WritableFile { private: SpecialEnv* env_; - unique_ptr base_; + std::unique_ptr base_; public: - SSTableFile(SpecialEnv* env, unique_ptr&& base) + SSTableFile(SpecialEnv* env, std::unique_ptr&& base) : env_(env), base_(std::move(base)) {} Status Append(const Slice& data) override { if (env_->table_write_callback_) { @@ -295,7 +295,7 @@ class SpecialEnv : public EnvWrapper { }; class ManifestFile : public WritableFile { public: - ManifestFile(SpecialEnv* env, unique_ptr&& b) + ManifestFile(SpecialEnv* env, std::unique_ptr&& b) : env_(env), base_(std::move(b)) {} Status Append(const Slice& data) override { if (env_->manifest_write_error_.load(std::memory_order_acquire)) { @@ -322,11 +322,11 @@ class SpecialEnv : public EnvWrapper { private: SpecialEnv* env_; - unique_ptr base_; + std::unique_ptr base_; }; class WalFile : public WritableFile { public: - WalFile(SpecialEnv* env, unique_ptr&& b) + WalFile(SpecialEnv* env, std::unique_ptr&& b) : env_(env), base_(std::move(b)) { env_->num_open_wal_file_.fetch_add(1); } @@ -378,7 +378,7 @@ class SpecialEnv : public EnvWrapper { private: SpecialEnv* env_; - unique_ptr base_; + std::unique_ptr base_; }; if (non_writeable_rate_.load(std::memory_order_acquire) > 0) { @@ -420,11 +420,11 @@ class SpecialEnv : public EnvWrapper { } Status NewRandomAccessFile(const std::string& f, - unique_ptr* r, + std::unique_ptr* r, const EnvOptions& soptions) override { class CountingFile : public RandomAccessFile { public: - CountingFile(unique_ptr&& target, + CountingFile(std::unique_ptr&& target, anon::AtomicCounter* counter, std::atomic* bytes_read) : target_(std::move(target)), @@ -439,7 +439,7 @@ class SpecialEnv : public EnvWrapper { } private: - unique_ptr target_; + std::unique_ptr target_; anon::AtomicCounter* counter_; std::atomic* bytes_read_; }; @@ -457,11 +457,11 @@ class SpecialEnv : public EnvWrapper { } virtual Status NewSequentialFile(const std::string& f, - unique_ptr* r, + std::unique_ptr* r, const EnvOptions& soptions) override { class CountingFile : public SequentialFile { public: - CountingFile(unique_ptr&& target, + CountingFile(std::unique_ptr&& target, anon::AtomicCounter* counter) : target_(std::move(target)), counter_(counter) {} virtual Status Read(size_t n, Slice* result, char* scratch) override { @@ -471,7 +471,7 @@ class SpecialEnv : public EnvWrapper { virtual Status Skip(uint64_t n) override { return target_->Skip(n); } private: - unique_ptr target_; + std::unique_ptr target_; anon::AtomicCounter* counter_; }; diff --git a/db/db_wal_test.cc b/db/db_wal_test.cc index 9b123d921..0f0c1e96f 100644 --- a/db/db_wal_test.cc +++ b/db/db_wal_test.cc @@ -33,7 +33,8 @@ class DBWALTest : public DBTestBase { class EnrichedSpecialEnv : public SpecialEnv { public: explicit EnrichedSpecialEnv(Env* base) : SpecialEnv(base) {} - Status NewSequentialFile(const std::string& f, unique_ptr* r, + Status NewSequentialFile(const std::string& f, + std::unique_ptr* r, const EnvOptions& soptions) override { InstrumentedMutexLock l(&env_mutex_); if (f == skipped_wal) { @@ -802,12 +803,12 @@ class RecoveryTestHelper { *count = 0; - shared_ptr table_cache = NewLRUCache(50, 0); + std::shared_ptr table_cache = NewLRUCache(50, 0); EnvOptions env_options; WriteBufferManager write_buffer_manager(db_options.db_write_buffer_size); - unique_ptr versions; - unique_ptr wal_manager; + std::unique_ptr versions; + std::unique_ptr wal_manager; WriteController write_controller; versions.reset(new VersionSet(test->dbname_, &db_options, env_options, @@ -821,9 +822,9 @@ class RecoveryTestHelper { for (size_t j = kWALFileOffset; j < wal_count + kWALFileOffset; j++) { uint64_t current_log_number = j; std::string fname = LogFileName(test->dbname_, current_log_number); - unique_ptr file; + std::unique_ptr file; ASSERT_OK(db_options.env->NewWritableFile(fname, &file, env_options)); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(file), fname, env_options)); current_log_writer.reset( new log::Writer(std::move(file_writer), current_log_number, diff --git a/db/fault_injection_test.cc b/db/fault_injection_test.cc index a6328e970..45f5a9402 100644 --- a/db/fault_injection_test.cc +++ b/db/fault_injection_test.cc @@ -70,7 +70,7 @@ class FaultInjectionTest std::unique_ptr base_env_; FaultInjectionTestEnv* env_; std::string dbname_; - shared_ptr tiny_cache_; + std::shared_ptr tiny_cache_; Options options_; DB* db_; diff --git a/db/flush_job_test.cc b/db/flush_job_test.cc index 79f90c6d9..519e01f2a 100644 --- a/db/flush_job_test.cc +++ b/db/flush_job_test.cc @@ -73,11 +73,11 @@ class FlushJobTest : public testing::Test { } const std::string manifest = DescriptorFileName(dbname_, 1); - unique_ptr file; + std::unique_ptr file; Status s = env_->NewWritableFile( manifest, &file, env_->OptimizeForManifestWrite(env_options_)); ASSERT_OK(s); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(file), manifest, EnvOptions())); { log::Writer log(std::move(file_writer), 0, false); diff --git a/db/job_context.h b/db/job_context.h index af640dab2..498ef7d17 100644 --- a/db/job_context.h +++ b/db/job_context.h @@ -30,7 +30,8 @@ struct SuperVersionContext { #ifndef ROCKSDB_DISABLE_STALL_NOTIFICATION autovector write_stall_notifications; #endif - unique_ptr new_superversion; // if nullptr no new superversion + std::unique_ptr + new_superversion; // if nullptr no new superversion explicit SuperVersionContext(bool create_superversion = false) : new_superversion(create_superversion ? new SuperVersion() : nullptr) {} @@ -44,7 +45,7 @@ struct SuperVersionContext { } void NewSuperVersion() { - new_superversion = unique_ptr(new SuperVersion()); + new_superversion = std::unique_ptr(new SuperVersion()); } inline bool HaveSomethingToDelete() const { diff --git a/db/log_reader.cc b/db/log_reader.cc index 6104ce32d..2c57cde5d 100644 --- a/db/log_reader.cc +++ b/db/log_reader.cc @@ -23,8 +23,9 @@ Reader::Reporter::~Reporter() { } Reader::Reader(std::shared_ptr info_log, - unique_ptr&& _file, Reporter* reporter, - bool checksum, uint64_t log_num, bool retry_after_eof) + std::unique_ptr&& _file, + Reporter* reporter, bool checksum, uint64_t log_num, + bool retry_after_eof) : info_log_(info_log), file_(std::move(_file)), reporter_(reporter), diff --git a/db/log_reader.h b/db/log_reader.h index 9a08c62f2..2c4f4f059 100644 --- a/db/log_reader.h +++ b/db/log_reader.h @@ -52,7 +52,7 @@ class Reader { // If "checksum" is true, verify checksums if available. Reader(std::shared_ptr info_log, // @lint-ignore TXT2 T25377293 Grandfathered in - unique_ptr&& file, Reporter* reporter, + std::unique_ptr&& file, Reporter* reporter, bool checksum, uint64_t log_num, bool retry_after_eof); ~Reader(); @@ -87,7 +87,7 @@ class Reader { private: std::shared_ptr info_log_; - const unique_ptr file_; + const std::unique_ptr file_; Reporter* const reporter_; bool const checksum_; char* const backing_store_; diff --git a/db/log_test.cc b/db/log_test.cc index a6f2f4f4a..9e8148f65 100644 --- a/db/log_test.cc +++ b/db/log_test.cc @@ -145,8 +145,8 @@ class LogTest : public ::testing::TestWithParam { } Slice reader_contents_; - unique_ptr dest_holder_; - unique_ptr source_holder_; + std::unique_ptr dest_holder_; + std::unique_ptr source_holder_; ReportCollector report_; Writer writer_; Reader reader_; @@ -639,7 +639,7 @@ TEST_P(LogTest, Recycle) { while (get_reader_contents()->size() < log::kBlockSize * 2) { Write("xxxxxxxxxxxxxxxx"); } - unique_ptr dest_holder(test::GetWritableFileWriter( + std::unique_ptr dest_holder(test::GetWritableFileWriter( new test::OverwritingStringSink(get_reader_contents()), "" /* don't care */)); Writer recycle_writer(std::move(dest_holder), 123, true); @@ -668,16 +668,16 @@ class RetriableLogTest : public ::testing::TestWithParam { }; Slice contents_; - unique_ptr dest_holder_; - unique_ptr log_writer_; + std::unique_ptr dest_holder_; + std::unique_ptr log_writer_; Env* env_; EnvOptions env_options_; const std::string test_dir_; const std::string log_file_; - unique_ptr writer_; - unique_ptr reader_; + std::unique_ptr writer_; + std::unique_ptr reader_; ReportCollector report_; - unique_ptr log_reader_; + std::unique_ptr log_reader_; public: RetriableLogTest() @@ -700,7 +700,7 @@ class RetriableLogTest : public ::testing::TestWithParam { Status s; s = env_->CreateDirIfMissing(test_dir_); - unique_ptr writable_file; + std::unique_ptr writable_file; if (s.ok()) { s = env_->NewWritableFile(log_file_, &writable_file, env_options_); } @@ -709,7 +709,7 @@ class RetriableLogTest : public ::testing::TestWithParam { env_options_)); assert(writer_ != nullptr); } - unique_ptr seq_file; + std::unique_ptr seq_file; if (s.ok()) { s = env_->NewSequentialFile(log_file_, &seq_file, env_options_); } diff --git a/db/log_writer.h b/db/log_writer.h index abd7977b9..dea503387 100644 --- a/db/log_writer.h +++ b/db/log_writer.h @@ -88,7 +88,7 @@ class Writer { bool TEST_BufferIsEmpty(); private: - unique_ptr dest_; + std::unique_ptr dest_; size_t block_offset_; // Current offset in block uint64_t log_number_; bool recycle_log_files_; diff --git a/db/memtable.h b/db/memtable.h index be1960515..b2ee24234 100644 --- a/db/memtable.h +++ b/db/memtable.h @@ -406,8 +406,8 @@ class MemTable { const size_t kArenaBlockSize; AllocTracker mem_tracker_; ConcurrentArena arena_; - unique_ptr table_; - unique_ptr range_del_table_; + std::unique_ptr table_; + std::unique_ptr range_del_table_; bool is_range_del_table_empty_; // Total data size of all data inserted diff --git a/db/memtable_list_test.cc b/db/memtable_list_test.cc index 7482b6611..06554f1ab 100644 --- a/db/memtable_list_test.cc +++ b/db/memtable_list_test.cc @@ -110,7 +110,7 @@ class MemTableListTest : public testing::Test { DBOptions db_options; ImmutableDBOptions immutable_db_options(db_options); EnvOptions env_options; - shared_ptr table_cache(NewLRUCache(50000, 16)); + std::shared_ptr table_cache(NewLRUCache(50000, 16)); WriteBufferManager write_buffer_manager(db_options.db_write_buffer_size); WriteController write_controller(10000000u); diff --git a/db/merge_test.cc b/db/merge_test.cc index 15f6f5125..a24b3e7f9 100644 --- a/db/merge_test.cc +++ b/db/merge_test.cc @@ -246,7 +246,7 @@ class MergeBasedCounters : public Counters { }; void dumpDb(DB* db) { - auto it = unique_ptr(db->NewIterator(ReadOptions())); + auto it = std::unique_ptr(db->NewIterator(ReadOptions())); for (it->SeekToFirst(); it->Valid(); it->Next()) { //uint64_t value = DecodeFixed64(it->value().data()); //std::cout << it->key().ToString() << ": " << value << std::endl; diff --git a/db/plain_table_db_test.cc b/db/plain_table_db_test.cc index dffd77ddc..a98b1629a 100644 --- a/db/plain_table_db_test.cc +++ b/db/plain_table_db_test.cc @@ -50,10 +50,11 @@ TEST_F(PlainTableKeyDecoderTest, ReadNonMmap) { test::StringSource* string_source = new test::StringSource(contents, 0, false); - unique_ptr file_reader( + std::unique_ptr file_reader( test::GetRandomAccessFileReader(string_source)); - unique_ptr file_info(new PlainTableReaderFileInfo( - std::move(file_reader), EnvOptions(), kLength)); + std::unique_ptr file_info( + new PlainTableReaderFileInfo(std::move(file_reader), EnvOptions(), + kLength)); { PlainTableFileReader reader(file_info.get()); @@ -260,7 +261,7 @@ class TestPlainTableReader : public PlainTableReader { int bloom_bits_per_key, double hash_table_ratio, size_t index_sparseness, const TableProperties* table_properties, - unique_ptr&& file, + std::unique_ptr&& file, const ImmutableCFOptions& ioptions, const SliceTransform* prefix_extractor, bool* expect_bloom_not_match, bool store_index_in_file, @@ -327,8 +328,8 @@ class TestPlainTableFactory : public PlainTableFactory { Status NewTableReader( const TableReaderOptions& table_reader_options, - unique_ptr&& file, uint64_t file_size, - unique_ptr* table, + std::unique_ptr&& file, uint64_t file_size, + std::unique_ptr* table, bool /*prefetch_index_and_filter_in_cache*/) const override { TableProperties* props = nullptr; auto s = diff --git a/db/repair.cc b/db/repair.cc index a4029bd51..b8f4e604a 100644 --- a/db/repair.cc +++ b/db/repair.cc @@ -344,13 +344,13 @@ class Repairer { // Open the log file std::string logname = LogFileName(db_options_.wal_dir, log); - unique_ptr lfile; + std::unique_ptr lfile; Status status = env_->NewSequentialFile( logname, &lfile, env_->OptimizeForLogRead(env_options_)); if (!status.ok()) { return status; } - unique_ptr lfile_reader( + std::unique_ptr lfile_reader( new SequentialFileReader(std::move(lfile), logname)); // Create the log reader. diff --git a/db/table_cache.cc b/db/table_cache.cc index fa5e86e7f..c4a7359a5 100644 --- a/db/table_cache.cc +++ b/db/table_cache.cc @@ -92,12 +92,12 @@ Status TableCache::GetTableReader( const EnvOptions& env_options, const InternalKeyComparator& internal_comparator, const FileDescriptor& fd, bool sequential_mode, size_t readahead, bool record_read_stats, - HistogramImpl* file_read_hist, unique_ptr* table_reader, + HistogramImpl* file_read_hist, std::unique_ptr* table_reader, const SliceTransform* prefix_extractor, bool skip_filters, int level, bool prefetch_index_and_filter_in_cache, bool for_compaction) { std::string fname = TableFileName(ioptions_.cf_paths, fd.GetNumber(), fd.GetPathId()); - unique_ptr file; + std::unique_ptr file; Status s = ioptions_.env->NewRandomAccessFile(fname, &file, env_options); RecordTick(ioptions_.statistics, NO_FILE_OPENS); @@ -157,7 +157,7 @@ Status TableCache::FindTable(const EnvOptions& env_options, if (no_io) { // Don't do IO and return a not-found status return Status::Incomplete("Table not found in table_cache, no_io is set"); } - unique_ptr table_reader; + std::unique_ptr table_reader; s = GetTableReader(env_options, internal_comparator, fd, false /* sequential mode */, 0 /* readahead */, record_read_stats, file_read_hist, &table_reader, @@ -217,7 +217,7 @@ InternalIterator* TableCache::NewIterator( auto& fd = file_meta.fd; if (create_new_table_reader) { - unique_ptr table_reader_unique_ptr; + std::unique_ptr table_reader_unique_ptr; s = GetTableReader( env_options, icomparator, fd, true /* sequential_mode */, readahead, !for_compaction /* record stats */, nullptr, &table_reader_unique_ptr, diff --git a/db/table_cache.h b/db/table_cache.h index 61e182401..e3936ab44 100644 --- a/db/table_cache.h +++ b/db/table_cache.h @@ -141,7 +141,7 @@ class TableCache { const FileDescriptor& fd, bool sequential_mode, size_t readahead, bool record_read_stats, HistogramImpl* file_read_hist, - unique_ptr* table_reader, + std::unique_ptr* table_reader, const SliceTransform* prefix_extractor = nullptr, bool skip_filters = false, int level = -1, bool prefetch_index_and_filter_in_cache = true, diff --git a/db/table_properties_collector_test.cc b/db/table_properties_collector_test.cc index 0944bb4c2..ebeb5962b 100644 --- a/db/table_properties_collector_test.cc +++ b/db/table_properties_collector_test.cc @@ -45,7 +45,7 @@ void MakeBuilder(const Options& options, const ImmutableCFOptions& ioptions, int_tbl_prop_collector_factories, std::unique_ptr* writable, std::unique_ptr* builder) { - unique_ptr wf(new test::StringSink); + std::unique_ptr wf(new test::StringSink); writable->reset( new WritableFileWriter(std::move(wf), "" /* don't care */, EnvOptions())); int unknown_level = -1; @@ -415,8 +415,9 @@ void TestInternalKeyPropertiesCollector( test::StringSink* fwf = static_cast(writable->writable_file()); - unique_ptr reader(test::GetRandomAccessFileReader( - new test::StringSource(fwf->contents()))); + std::unique_ptr reader( + test::GetRandomAccessFileReader( + new test::StringSource(fwf->contents()))); TableProperties* props; Status s = ReadTableProperties(reader.get(), fwf->contents().size(), magic_number, diff --git a/db/transaction_log_impl.cc b/db/transaction_log_impl.cc index fba91a979..4d6671ef6 100644 --- a/db/transaction_log_impl.cc +++ b/db/transaction_log_impl.cc @@ -43,9 +43,10 @@ TransactionLogIteratorImpl::TransactionLogIteratorImpl( } Status TransactionLogIteratorImpl::OpenLogFile( - const LogFile* logFile, unique_ptr* file_reader) { + const LogFile* logFile, + std::unique_ptr* file_reader) { Env* env = options_->env; - unique_ptr file; + std::unique_ptr file; std::string fname; Status s; EnvOptions optimized_env_options = env->OptimizeForLogRead(soptions_); @@ -306,7 +307,7 @@ void TransactionLogIteratorImpl::UpdateCurrentWriteBatch(const Slice& record) { } Status TransactionLogIteratorImpl::OpenLogReader(const LogFile* logFile) { - unique_ptr file; + std::unique_ptr file; Status s = OpenLogFile(logFile, &file); if (!s.ok()) { return s; diff --git a/db/transaction_log_impl.h b/db/transaction_log_impl.h index b6762bf5f..3c27a8f37 100644 --- a/db/transaction_log_impl.h +++ b/db/transaction_log_impl.h @@ -85,9 +85,9 @@ class TransactionLogIteratorImpl : public TransactionLogIterator { Status currentStatus_; size_t currentFileIndex_; std::unique_ptr currentBatch_; - unique_ptr currentLogReader_; + std::unique_ptr currentLogReader_; Status OpenLogFile(const LogFile* logFile, - unique_ptr* file); + std::unique_ptr* file); struct LogReporter : public log::Reader::Reporter { Env* env; diff --git a/db/version_set.cc b/db/version_set.cc index c13fadc17..995ab54da 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -2939,14 +2939,14 @@ Status VersionSet::ProcessManifestWrites( pending_manifest_file_number_); std::string descriptor_fname = DescriptorFileName(dbname_, pending_manifest_file_number_); - unique_ptr descriptor_file; + std::unique_ptr descriptor_file; s = NewWritableFile(env_, descriptor_fname, &descriptor_file, opt_env_opts); if (s.ok()) { descriptor_file->SetPreallocationBlockSize( db_options_->manifest_preallocation_size); - unique_ptr file_writer(new WritableFileWriter( + std::unique_ptr file_writer(new WritableFileWriter( std::move(descriptor_file), descriptor_fname, opt_env_opts, nullptr, db_options_->listeners)); descriptor_log_.reset( @@ -3410,9 +3410,9 @@ Status VersionSet::Recover( manifest_filename.c_str()); manifest_filename = dbname_ + "/" + manifest_filename; - unique_ptr manifest_file_reader; + std::unique_ptr manifest_file_reader; { - unique_ptr manifest_file; + std::unique_ptr manifest_file; s = env_->NewSequentialFile(manifest_filename, &manifest_file, env_->OptimizeForManifestRead(env_options_)); if (!s.ok()) { @@ -3660,12 +3660,12 @@ Status VersionSet::ListColumnFamilies(std::vector* column_families, std::string dscname = dbname + "/" + current; - unique_ptr file_reader; + std::unique_ptr file_reader; { - unique_ptr file; - s = env->NewSequentialFile(dscname, &file, soptions); - if (!s.ok()) { - return s; + std::unique_ptr file; + s = env->NewSequentialFile(dscname, &file, soptions); + if (!s.ok()) { + return s; } file_reader.reset(new SequentialFileReader(std::move(file), dscname)); } @@ -3803,10 +3803,10 @@ Status VersionSet::ReduceNumberOfLevels(const std::string& dbname, Status VersionSet::DumpManifest(Options& options, std::string& dscname, bool verbose, bool hex, bool json) { // Open the specified manifest file. - unique_ptr file_reader; + std::unique_ptr file_reader; Status s; { - unique_ptr file; + std::unique_ptr file; s = options.env->NewSequentialFile( dscname, &file, env_->OptimizeForManifestRead(env_options_)); if (!s.ok()) { diff --git a/db/version_set.h b/db/version_set.h index a26254eec..b50f653ba 100644 --- a/db/version_set.h +++ b/db/version_set.h @@ -605,7 +605,7 @@ class Version { // REQUIRES: lock is held // On success, *props will be populated with all SSTables' table properties. // The keys of `props` are the sst file name, the values of `props` are the - // tables' properties, represented as shared_ptr. + // tables' properties, represented as std::shared_ptr. Status GetPropertiesOfAllTables(TablePropertiesCollection* props); Status GetPropertiesOfAllTables(TablePropertiesCollection* props, int level); Status GetPropertiesOfTablesInRange(const Range* range, std::size_t n, @@ -1053,7 +1053,7 @@ class VersionSet { uint64_t prev_log_number_; // 0 or backing store for memtable being compacted // Opened lazily - unique_ptr descriptor_log_; + std::unique_ptr descriptor_log_; // generates a increasing version number for every new version uint64_t current_version_number_; diff --git a/db/version_set_test.cc b/db/version_set_test.cc index 37e1b7b8f..c94ffb154 100644 --- a/db/version_set_test.cc +++ b/db/version_set_test.cc @@ -653,11 +653,11 @@ class VersionSetTest : public testing::Test { *last_seqno = last_seq; const std::string manifest = DescriptorFileName(dbname_, 1); - unique_ptr file; + std::unique_ptr file; Status s = env_->NewWritableFile( manifest, &file, env_->OptimizeForManifestWrite(env_options_)); ASSERT_OK(s); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(file), manifest, env_options_)); { log_writer->reset(new log::Writer(std::move(file_writer), 0, false)); diff --git a/db/wal_manager.cc b/db/wal_manager.cc index cc5ed3105..667ecae41 100644 --- a/db/wal_manager.cc +++ b/db/wal_manager.cc @@ -443,7 +443,7 @@ Status WalManager::ReadFirstLine(const std::string& fname, std::unique_ptr file; Status status = env_->NewSequentialFile( fname, &file, env_->OptimizeForLogRead(env_options_)); - unique_ptr file_reader( + std::unique_ptr file_reader( new SequentialFileReader(std::move(file), fname)); if (!status.ok()) { diff --git a/db/wal_manager_test.cc b/db/wal_manager_test.cc index 838fad2b1..379f12f52 100644 --- a/db/wal_manager_test.cc +++ b/db/wal_manager_test.cc @@ -76,9 +76,9 @@ class WalManagerTest : public testing::Test { void RollTheLog(bool /*archived*/) { current_log_number_++; std::string fname = ArchivedLogFileName(dbname_, current_log_number_); - unique_ptr file; + std::unique_ptr file; ASSERT_OK(env_->NewWritableFile(fname, &file, env_options_)); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(file), fname, env_options_)); current_log_writer_.reset(new log::Writer(std::move(file_writer), 0, false)); } @@ -94,7 +94,7 @@ class WalManagerTest : public testing::Test { std::unique_ptr OpenTransactionLogIter( const SequenceNumber seq) { - unique_ptr iter; + std::unique_ptr iter; Status status = wal_manager_->GetUpdatesSince( seq, &iter, TransactionLogIterator::ReadOptions(), versions_.get()); EXPECT_OK(status); @@ -118,7 +118,7 @@ class WalManagerTest : public testing::Test { TEST_F(WalManagerTest, ReadFirstRecordCache) { Init(); std::string path = dbname_ + "/000001.log"; - unique_ptr file; + std::unique_ptr file; ASSERT_OK(env_->NewWritableFile(path, &file, EnvOptions())); SequenceNumber s; @@ -129,7 +129,7 @@ TEST_F(WalManagerTest, ReadFirstRecordCache) { wal_manager_->TEST_ReadFirstRecord(kAliveLogFile, 1 /* number */, &s)); ASSERT_EQ(s, 0U); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(file), path, EnvOptions())); log::Writer writer(std::move(file_writer), 1, db_options_.recycle_log_file_num > 0); diff --git a/db/write_batch.cc b/db/write_batch.cc index 3fcee08e4..19ec24359 100644 --- a/db/write_batch.cc +++ b/db/write_batch.cc @@ -1053,7 +1053,7 @@ class MemTableInserter : public WriteBatch::Handler { // a map is too expensive in the Write() path as they // cause memory allocations though unused. // Make creation optional but do not incur - // unique_ptr additional allocation + // std::unique_ptr additional allocation using MemPostInfoMap = std::map; using PostMapType = std::aligned_storage::type; PostMapType mem_post_info_map_; diff --git a/env/env.cc b/env/env.cc index 9b7f5e40d..a41feaf00 100644 --- a/env/env.cc +++ b/env/env.cc @@ -43,7 +43,7 @@ uint64_t Env::GetThreadID() const { Status Env::ReuseWritableFile(const std::string& fname, const std::string& old_fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) { Status s = RenameFile(old_fname, fname); if (!s.ok()) { @@ -242,11 +242,11 @@ void Fatal(Logger* info_log, const char* format, ...) { va_end(ap); } -void LogFlush(const shared_ptr& info_log) { +void LogFlush(const std::shared_ptr& info_log) { LogFlush(info_log.get()); } -void Log(const InfoLogLevel log_level, const shared_ptr& info_log, +void Log(const InfoLogLevel log_level, const std::shared_ptr& info_log, const char* format, ...) { va_list ap; va_start(ap, format); @@ -254,49 +254,49 @@ void Log(const InfoLogLevel log_level, const shared_ptr& info_log, va_end(ap); } -void Header(const shared_ptr& info_log, const char* format, ...) { +void Header(const std::shared_ptr& info_log, const char* format, ...) { va_list ap; va_start(ap, format); Headerv(info_log.get(), format, ap); va_end(ap); } -void Debug(const shared_ptr& info_log, const char* format, ...) { +void Debug(const std::shared_ptr& info_log, const char* format, ...) { va_list ap; va_start(ap, format); Debugv(info_log.get(), format, ap); va_end(ap); } -void Info(const shared_ptr& info_log, const char* format, ...) { +void Info(const std::shared_ptr& info_log, const char* format, ...) { va_list ap; va_start(ap, format); Infov(info_log.get(), format, ap); va_end(ap); } -void Warn(const shared_ptr& info_log, const char* format, ...) { +void Warn(const std::shared_ptr& info_log, const char* format, ...) { va_list ap; va_start(ap, format); Warnv(info_log.get(), format, ap); va_end(ap); } -void Error(const shared_ptr& info_log, const char* format, ...) { +void Error(const std::shared_ptr& info_log, const char* format, ...) { va_list ap; va_start(ap, format); Errorv(info_log.get(), format, ap); va_end(ap); } -void Fatal(const shared_ptr& info_log, const char* format, ...) { +void Fatal(const std::shared_ptr& info_log, const char* format, ...) { va_list ap; va_start(ap, format); Fatalv(info_log.get(), format, ap); va_end(ap); } -void Log(const shared_ptr& info_log, const char* format, ...) { +void Log(const std::shared_ptr& info_log, const char* format, ...) { va_list ap; va_start(ap, format); Logv(info_log.get(), format, ap); @@ -305,7 +305,7 @@ void Log(const shared_ptr& info_log, const char* format, ...) { Status WriteStringToFile(Env* env, const Slice& data, const std::string& fname, bool should_sync) { - unique_ptr file; + std::unique_ptr file; EnvOptions soptions; Status s = env->NewWritableFile(fname, &file, soptions); if (!s.ok()) { @@ -324,7 +324,7 @@ Status WriteStringToFile(Env* env, const Slice& data, const std::string& fname, Status ReadFileToString(Env* env, const std::string& fname, std::string* data) { EnvOptions soptions; data->clear(); - unique_ptr file; + std::unique_ptr file; Status s = env->NewSequentialFile(fname, &file, soptions); if (!s.ok()) { return s; diff --git a/env/env_basic_test.cc b/env/env_basic_test.cc index e05f61aa6..22983dbec 100644 --- a/env/env_basic_test.cc +++ b/env/env_basic_test.cc @@ -133,7 +133,7 @@ INSTANTIATE_TEST_CASE_P(CustomEnv, EnvMoreTestWithParam, TEST_P(EnvBasicTestWithParam, Basics) { uint64_t file_size; - unique_ptr writable_file; + std::unique_ptr writable_file; std::vector children; // Check that the directory is empty. @@ -186,8 +186,8 @@ TEST_P(EnvBasicTestWithParam, Basics) { ASSERT_EQ(0U, file_size); // Check that opening non-existent file fails. - unique_ptr seq_file; - unique_ptr rand_file; + std::unique_ptr seq_file; + std::unique_ptr rand_file; ASSERT_TRUE(!env_->NewSequentialFile(test_dir_ + "/non_existent", &seq_file, soptions_) .ok()); @@ -208,9 +208,9 @@ TEST_P(EnvBasicTestWithParam, Basics) { } TEST_P(EnvBasicTestWithParam, ReadWrite) { - unique_ptr writable_file; - unique_ptr seq_file; - unique_ptr rand_file; + std::unique_ptr writable_file; + std::unique_ptr seq_file; + std::unique_ptr rand_file; Slice result; char scratch[100]; @@ -247,7 +247,7 @@ TEST_P(EnvBasicTestWithParam, ReadWrite) { } TEST_P(EnvBasicTestWithParam, Misc) { - unique_ptr writable_file; + std::unique_ptr writable_file; ASSERT_OK(env_->NewWritableFile(test_dir_ + "/b", &writable_file, soptions_)); // These are no-ops, but we test they return success. @@ -266,14 +266,14 @@ TEST_P(EnvBasicTestWithParam, LargeWrite) { write_data.append(1, static_cast(i)); } - unique_ptr writable_file; + std::unique_ptr writable_file; ASSERT_OK(env_->NewWritableFile(test_dir_ + "/f", &writable_file, soptions_)); ASSERT_OK(writable_file->Append("foo")); ASSERT_OK(writable_file->Append(write_data)); ASSERT_OK(writable_file->Close()); writable_file.reset(); - unique_ptr seq_file; + std::unique_ptr seq_file; Slice result; ASSERT_OK(env_->NewSequentialFile(test_dir_ + "/f", &seq_file, soptions_)); ASSERT_OK(seq_file->Read(3, &result, scratch)); // Read "foo". @@ -340,7 +340,7 @@ TEST_P(EnvMoreTestWithParam, GetChildren) { // if dir is a file, returns IOError ASSERT_OK(env_->CreateDir(test_dir_)); - unique_ptr writable_file; + std::unique_ptr writable_file; ASSERT_OK( env_->NewWritableFile(test_dir_ + "/file", &writable_file, soptions_)); ASSERT_OK(writable_file->Close()); diff --git a/env/env_chroot.cc b/env/env_chroot.cc index 6a1fda8a8..f6236c81b 100644 --- a/env/env_chroot.cc +++ b/env/env_chroot.cc @@ -50,7 +50,7 @@ class ChrootEnv : public EnvWrapper { } virtual Status NewRandomAccessFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { auto status_and_enc_path = EncodePathWithNewBasename(fname); if (!status_and_enc_path.first.ok()) { @@ -61,7 +61,7 @@ class ChrootEnv : public EnvWrapper { } virtual Status NewWritableFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { auto status_and_enc_path = EncodePathWithNewBasename(fname); if (!status_and_enc_path.first.ok()) { @@ -73,7 +73,7 @@ class ChrootEnv : public EnvWrapper { virtual Status ReuseWritableFile(const std::string& fname, const std::string& old_fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { auto status_and_enc_path = EncodePathWithNewBasename(fname); if (!status_and_enc_path.first.ok()) { @@ -89,7 +89,7 @@ class ChrootEnv : public EnvWrapper { } virtual Status NewRandomRWFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { auto status_and_enc_path = EncodePathWithNewBasename(fname); if (!status_and_enc_path.first.ok()) { @@ -100,7 +100,7 @@ class ChrootEnv : public EnvWrapper { } virtual Status NewDirectory(const std::string& dir, - unique_ptr* result) override { + std::unique_ptr* result) override { auto status_and_enc_path = EncodePathWithNewBasename(dir); if (!status_and_enc_path.first.ok()) { return status_and_enc_path.first; @@ -238,7 +238,7 @@ class ChrootEnv : public EnvWrapper { } virtual Status NewLogger(const std::string& fname, - shared_ptr* result) override { + std::shared_ptr* result) override { auto status_and_enc_path = EncodePathWithNewBasename(fname); if (!status_and_enc_path.first.ok()) { return status_and_enc_path.first; diff --git a/env/env_encryption.cc b/env/env_encryption.cc index e80796fe0..e38693e3c 100644 --- a/env/env_encryption.cc +++ b/env/env_encryption.cc @@ -422,7 +422,7 @@ class EncryptedEnv : public EnvWrapper { // NewRandomAccessFile opens a file for random read access. virtual Status NewRandomAccessFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { result->reset(); if (options.use_mmap_reads) { @@ -456,10 +456,10 @@ class EncryptedEnv : public EnvWrapper { (*result) = std::unique_ptr(new EncryptedRandomAccessFile(underlying.release(), stream.release(), prefixLength)); return Status::OK(); } - + // NewWritableFile opens a file for sequential writing. virtual Status NewWritableFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { result->reset(); if (options.use_mmap_writes) { @@ -505,8 +505,8 @@ class EncryptedEnv : public EnvWrapper { // // The returned file will only be accessed by one thread at a time. virtual Status ReopenWritableFile(const std::string& fname, - unique_ptr* result, - const EnvOptions& options) override { + std::unique_ptr* result, + const EnvOptions& options) override { result->reset(); if (options.use_mmap_writes) { return Status::InvalidArgument(); @@ -546,7 +546,7 @@ class EncryptedEnv : public EnvWrapper { // Reuse an existing file by renaming it and opening it as writable. virtual Status ReuseWritableFile(const std::string& fname, const std::string& old_fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { result->reset(); if (options.use_mmap_writes) { @@ -590,7 +590,7 @@ class EncryptedEnv : public EnvWrapper { // // The returned file will only be accessed by one thread at a time. virtual Status NewRandomRWFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { result->reset(); if (options.use_mmap_reads || options.use_mmap_writes) { @@ -692,7 +692,7 @@ Status BlockAccessCipherStream::Encrypt(uint64_t fileOffset, char *data, size_t auto blockSize = BlockSize(); uint64_t blockIndex = fileOffset / blockSize; size_t blockOffset = fileOffset % blockSize; - unique_ptr blockBuffer; + std::unique_ptr blockBuffer; std::string scratch; AllocateScratch(scratch); @@ -705,8 +705,8 @@ Status BlockAccessCipherStream::Encrypt(uint64_t fileOffset, char *data, size_t // We're not encrypting a full block. // Copy data to blockBuffer if (!blockBuffer.get()) { - // Allocate buffer - blockBuffer = unique_ptr(new char[blockSize]); + // Allocate buffer + blockBuffer = std::unique_ptr(new char[blockSize]); } block = blockBuffer.get(); // Copy plain data to block buffer @@ -737,7 +737,7 @@ Status BlockAccessCipherStream::Decrypt(uint64_t fileOffset, char *data, size_t auto blockSize = BlockSize(); uint64_t blockIndex = fileOffset / blockSize; size_t blockOffset = fileOffset % blockSize; - unique_ptr blockBuffer; + std::unique_ptr blockBuffer; std::string scratch; AllocateScratch(scratch); @@ -750,8 +750,8 @@ Status BlockAccessCipherStream::Decrypt(uint64_t fileOffset, char *data, size_t // We're not decrypting a full block. // Copy data to blockBuffer if (!blockBuffer.get()) { - // Allocate buffer - blockBuffer = unique_ptr(new char[blockSize]); + // Allocate buffer + blockBuffer = std::unique_ptr(new char[blockSize]); } block = blockBuffer.get(); // Copy encrypted data to block buffer @@ -882,7 +882,9 @@ size_t CTREncryptionProvider::PopulateSecretPrefixPart(char* /*prefix*/, return 0; } -Status CTREncryptionProvider::CreateCipherStream(const std::string& fname, const EnvOptions& options, Slice &prefix, unique_ptr* result) { +Status CTREncryptionProvider::CreateCipherStream( + const std::string& fname, const EnvOptions& options, Slice& prefix, + std::unique_ptr* result) { // Read plain text part of prefix. auto blockSize = cipher_.BlockSize(); uint64_t initialCounter; @@ -905,8 +907,9 @@ Status CTREncryptionProvider::CreateCipherStream(const std::string& fname, const Status CTREncryptionProvider::CreateCipherStreamFromPrefix( const std::string& /*fname*/, const EnvOptions& /*options*/, uint64_t initialCounter, const Slice& iv, const Slice& /*prefix*/, - unique_ptr* result) { - (*result) = unique_ptr(new CTRCipherStream(cipher_, iv.data(), initialCounter)); + std::unique_ptr* result) { + (*result) = std::unique_ptr( + new CTRCipherStream(cipher_, iv.data(), initialCounter)); return Status::OK(); } diff --git a/env/env_hdfs.cc b/env/env_hdfs.cc index 1eaea3a1c..14fb902f0 100644 --- a/env/env_hdfs.cc +++ b/env/env_hdfs.cc @@ -381,7 +381,7 @@ const std::string HdfsEnv::pathsep = "/"; // open a file for sequential reading Status HdfsEnv::NewSequentialFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) { result->reset(); HdfsReadableFile* f = new HdfsReadableFile(fileSys_, fname); @@ -396,7 +396,7 @@ Status HdfsEnv::NewSequentialFile(const std::string& fname, // open a file for random reading Status HdfsEnv::NewRandomAccessFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) { result->reset(); HdfsReadableFile* f = new HdfsReadableFile(fileSys_, fname); @@ -411,7 +411,7 @@ Status HdfsEnv::NewRandomAccessFile(const std::string& fname, // create a new file for writing Status HdfsEnv::NewWritableFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) { result->reset(); Status s; @@ -437,7 +437,7 @@ class HdfsDirectory : public Directory { }; Status HdfsEnv::NewDirectory(const std::string& name, - unique_ptr* result) { + std::unique_ptr* result) { int value = hdfsExists(fileSys_, name.c_str()); switch (value) { case HDFS_EXISTS: @@ -581,7 +581,7 @@ Status HdfsEnv::UnlockFile(FileLock* lock) { } Status HdfsEnv::NewLogger(const std::string& fname, - shared_ptr* result) { + std::shared_ptr* result) { HdfsWritableFile* f = new HdfsWritableFile(fileSys_, fname); if (f == nullptr || !f->isValid()) { delete f; @@ -610,10 +610,10 @@ Status NewHdfsEnv(Env** hdfs_env, const std::string& fsname) { // dummy placeholders used when HDFS is not available namespace rocksdb { Status HdfsEnv::NewSequentialFile(const std::string& /*fname*/, - unique_ptr* /*result*/, + std::unique_ptr* /*result*/, const EnvOptions& /*options*/) { return Status::NotSupported("Not compiled with hdfs support"); - } +} Status NewHdfsEnv(Env** /*hdfs_env*/, const std::string& /*fsname*/) { return Status::NotSupported("Not compiled with hdfs support"); diff --git a/env/env_posix.cc b/env/env_posix.cc index 34d49b9dc..c2e456a66 100644 --- a/env/env_posix.cc +++ b/env/env_posix.cc @@ -142,7 +142,7 @@ class PosixEnv : public Env { } virtual Status NewSequentialFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { result->reset(); int fd = -1; @@ -192,7 +192,7 @@ class PosixEnv : public Env { } virtual Status NewRandomAccessFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { result->reset(); Status s; @@ -249,7 +249,7 @@ class PosixEnv : public Env { } virtual Status OpenWritableFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options, bool reopen = false) { result->reset(); @@ -333,20 +333,20 @@ class PosixEnv : public Env { } virtual Status NewWritableFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { return OpenWritableFile(fname, result, options, false); } virtual Status ReopenWritableFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { return OpenWritableFile(fname, result, options, true); } virtual Status ReuseWritableFile(const std::string& fname, const std::string& old_fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { result->reset(); Status s; @@ -430,7 +430,7 @@ class PosixEnv : public Env { } virtual Status NewRandomRWFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { int fd = -1; int flags = cloexec_flags(O_RDWR, &options); @@ -455,7 +455,7 @@ class PosixEnv : public Env { virtual Status NewMemoryMappedFileBuffer( const std::string& fname, - unique_ptr* result) override { + std::unique_ptr* result) override { int fd = -1; Status status; int flags = cloexec_flags(O_RDWR, nullptr); @@ -497,7 +497,7 @@ class PosixEnv : public Env { } virtual Status NewDirectory(const std::string& name, - unique_ptr* result) override { + std::unique_ptr* result) override { result->reset(); int fd; int flags = cloexec_flags(0, nullptr); @@ -791,7 +791,7 @@ class PosixEnv : public Env { } virtual Status NewLogger(const std::string& fname, - shared_ptr* result) override { + std::shared_ptr* result) override { FILE* f; { IOSTATS_TIMER_GUARD(open_nanos); diff --git a/env/env_test.cc b/env/env_test.cc index 7b9c9741e..36cbd735d 100644 --- a/env/env_test.cc +++ b/env/env_test.cc @@ -181,11 +181,11 @@ TEST_F(EnvPosixTest, DISABLED_FilePermission) { std::vector fileNames{ test::PerThreadDBPath(env_, "testfile"), test::PerThreadDBPath(env_, "testfile1")}; - unique_ptr wfile; + std::unique_ptr wfile; ASSERT_OK(env_->NewWritableFile(fileNames[0], &wfile, soptions)); ASSERT_OK(env_->NewWritableFile(fileNames[1], &wfile, soptions)); wfile.reset(); - unique_ptr rwfile; + std::unique_ptr rwfile; ASSERT_OK(env_->NewRandomRWFile(fileNames[1], &rwfile, soptions)); struct stat sb; @@ -217,7 +217,7 @@ TEST_F(EnvPosixTest, MemoryMappedFileBuffer) { std::string expected_data; std::string fname = test::PerThreadDBPath(env_, "testfile"); { - unique_ptr wfile; + std::unique_ptr wfile; const EnvOptions soptions; ASSERT_OK(env_->NewWritableFile(fname, &wfile, soptions)); @@ -812,7 +812,7 @@ class IoctlFriendlyTmpdir { #ifndef ROCKSDB_LITE TEST_F(EnvPosixTest, PositionedAppend) { - unique_ptr writable_file; + std::unique_ptr writable_file; EnvOptions options; options.use_direct_writes = true; options.use_mmap_writes = false; @@ -832,7 +832,7 @@ TEST_F(EnvPosixTest, PositionedAppend) { // The file now has 1 sector worth of a followed by a page worth of b // Verify the above - unique_ptr seq_file; + std::unique_ptr seq_file; ASSERT_OK(env_->NewSequentialFile(ift.name() + "/f", &seq_file, options)); char scratch[kPageSize * 2]; Slice result; @@ -851,10 +851,10 @@ TEST_P(EnvPosixTestWithParam, RandomAccessUniqueID) { soptions.use_direct_reads = soptions.use_direct_writes = direct_io_; IoctlFriendlyTmpdir ift; std::string fname = ift.name() + "/testfile"; - unique_ptr wfile; + std::unique_ptr wfile; ASSERT_OK(env_->NewWritableFile(fname, &wfile, soptions)); - unique_ptr file; + std::unique_ptr file; // Get Unique ID ASSERT_OK(env_->NewRandomAccessFile(fname, &file, soptions)); @@ -921,7 +921,7 @@ TEST_P(EnvPosixTestWithParam, AllocateTest) { EnvOptions soptions; soptions.use_mmap_writes = false; soptions.use_direct_reads = soptions.use_direct_writes = direct_io_; - unique_ptr wfile; + std::unique_ptr wfile; ASSERT_OK(env_->NewWritableFile(fname, &wfile, soptions)); // allocate 100 MB @@ -990,14 +990,14 @@ TEST_P(EnvPosixTestWithParam, RandomAccessUniqueIDConcurrent) { fnames.push_back(ift.name() + "/" + "testfile" + ToString(i)); // Create file. - unique_ptr wfile; + std::unique_ptr wfile; ASSERT_OK(env_->NewWritableFile(fnames[i], &wfile, soptions)); } // Collect and check whether the IDs are unique. std::unordered_set ids; for (const std::string fname : fnames) { - unique_ptr file; + std::unique_ptr file; std::string unique_id; ASSERT_OK(env_->NewRandomAccessFile(fname, &file, soptions)); size_t id_size = file->GetUniqueId(temp_id, MAX_ID_SIZE); @@ -1033,14 +1033,14 @@ TEST_P(EnvPosixTestWithParam, RandomAccessUniqueIDDeletes) { for (int i = 0; i < 1000; ++i) { // Create file. { - unique_ptr wfile; + std::unique_ptr wfile; ASSERT_OK(env_->NewWritableFile(fname, &wfile, soptions)); } // Get Unique ID std::string unique_id; { - unique_ptr file; + std::unique_ptr file; ASSERT_OK(env_->NewRandomAccessFile(fname, &file, soptions)); size_t id_size = file->GetUniqueId(temp_id, MAX_ID_SIZE); ASSERT_TRUE(id_size > 0); @@ -1076,7 +1076,7 @@ TEST_P(EnvPosixTestWithParam, InvalidateCache) { // Create file. { - unique_ptr wfile; + std::unique_ptr wfile; #if !defined(OS_MACOSX) && !defined(OS_WIN) && !defined(OS_SOLARIS) && !defined(OS_AIX) if (soptions.use_direct_writes) { soptions.use_direct_writes = false; @@ -1090,7 +1090,7 @@ TEST_P(EnvPosixTestWithParam, InvalidateCache) { // Random Read { - unique_ptr file; + std::unique_ptr file; auto scratch = NewAligned(kSectorSize, 0); Slice result; #if !defined(OS_MACOSX) && !defined(OS_WIN) && !defined(OS_SOLARIS) && !defined(OS_AIX) @@ -1107,7 +1107,7 @@ TEST_P(EnvPosixTestWithParam, InvalidateCache) { // Sequential Read { - unique_ptr file; + std::unique_ptr file; auto scratch = NewAligned(kSectorSize, 0); Slice result; #if !defined(OS_MACOSX) && !defined(OS_WIN) && !defined(OS_SOLARIS) && !defined(OS_AIX) @@ -1252,7 +1252,7 @@ TEST_P(EnvPosixTestWithParam, LogBufferMaxSizeTest) { TEST_P(EnvPosixTestWithParam, Preallocation) { rocksdb::SyncPoint::GetInstance()->EnableProcessing(); const std::string src = test::PerThreadDBPath(env_, "testfile"); - unique_ptr srcfile; + std::unique_ptr srcfile; EnvOptions soptions; soptions.use_direct_reads = soptions.use_direct_writes = direct_io_; #if !defined(OS_MACOSX) && !defined(OS_WIN) && !defined(OS_SOLARIS) && !defined(OS_AIX) && !defined(OS_OPENBSD) && !defined(OS_FREEBSD) @@ -1315,7 +1315,7 @@ TEST_P(EnvPosixTestWithParam, ConsistentChildrenAttributes) { for (int i = 0; i < kNumChildren; ++i) { const std::string path = test::TmpDir(env_) + "/" + "testfile_" + std::to_string(i); - unique_ptr file; + std::unique_ptr file; #if !defined(OS_MACOSX) && !defined(OS_WIN) && !defined(OS_SOLARIS) && !defined(OS_AIX) && !defined(OS_OPENBSD) && !defined(OS_FREEBSD) if (soptions.use_direct_writes) { rocksdb::SyncPoint::GetInstance()->SetCallBack( @@ -1638,7 +1638,7 @@ TEST_P(EnvPosixTestWithParam, PosixRandomRWFileRandomized) { const std::string path = test::PerThreadDBPath(env_, "random_rw_file_rand"); env_->DeleteFile(path); - unique_ptr file; + std::unique_ptr file; #ifdef OS_LINUX // Cannot open non-existing file. @@ -1712,7 +1712,7 @@ class TestEnv : public EnvWrapper { int GetCloseCount() { return close_count; } virtual Status NewLogger(const std::string& /*fname*/, - shared_ptr* result) { + std::shared_ptr* result) { result->reset(new TestLogger(this)); return Status::OK(); } @@ -1756,8 +1756,8 @@ INSTANTIATE_TEST_CASE_P(DefaultEnvWithDirectIO, EnvPosixTestWithParam, #endif // !defined(ROCKSDB_LITE) #if !defined(ROCKSDB_LITE) && !defined(OS_WIN) -static unique_ptr chroot_env(NewChrootEnv(Env::Default(), - test::TmpDir(Env::Default()))); +static std::unique_ptr chroot_env( + NewChrootEnv(Env::Default(), test::TmpDir(Env::Default()))); INSTANTIATE_TEST_CASE_P( ChrootEnvWithoutDirectIO, EnvPosixTestWithParam, ::testing::Values(std::pair(chroot_env.get(), false))); diff --git a/env/mock_env.cc b/env/mock_env.cc index f4237edda..84b306071 100644 --- a/env/mock_env.cc +++ b/env/mock_env.cc @@ -424,7 +424,7 @@ MockEnv::~MockEnv() { // Partial implementation of the Env interface. Status MockEnv::NewSequentialFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& /*soptions*/) { auto fn = NormalizePath(fname); MutexLock lock(&mutex_); @@ -441,7 +441,7 @@ Status MockEnv::NewSequentialFile(const std::string& fname, } Status MockEnv::NewRandomAccessFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& /*soptions*/) { auto fn = NormalizePath(fname); MutexLock lock(&mutex_); @@ -458,7 +458,7 @@ Status MockEnv::NewRandomAccessFile(const std::string& fname, } Status MockEnv::NewRandomRWFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& /*soptions*/) { auto fn = NormalizePath(fname); MutexLock lock(&mutex_); @@ -476,7 +476,7 @@ Status MockEnv::NewRandomRWFile(const std::string& fname, Status MockEnv::ReuseWritableFile(const std::string& fname, const std::string& old_fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) { auto s = RenameFile(old_fname, fname); if (!s.ok()) { @@ -487,7 +487,7 @@ Status MockEnv::ReuseWritableFile(const std::string& fname, } Status MockEnv::NewWritableFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& env_options) { auto fn = NormalizePath(fname); MutexLock lock(&mutex_); @@ -503,7 +503,7 @@ Status MockEnv::NewWritableFile(const std::string& fname, } Status MockEnv::NewDirectory(const std::string& /*name*/, - unique_ptr* result) { + std::unique_ptr* result) { result->reset(new MockEnvDirectory()); return Status::OK(); } @@ -660,7 +660,7 @@ Status MockEnv::LinkFile(const std::string& src, const std::string& dest) { } Status MockEnv::NewLogger(const std::string& fname, - shared_ptr* result) { + std::shared_ptr* result) { auto fn = NormalizePath(fname); MutexLock lock(&mutex_); auto iter = file_map_.find(fn); diff --git a/env/mock_env.h b/env/mock_env.h index 816256ab0..87b8deaf8 100644 --- a/env/mock_env.h +++ b/env/mock_env.h @@ -28,28 +28,28 @@ class MockEnv : public EnvWrapper { // Partial implementation of the Env interface. virtual Status NewSequentialFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& soptions) override; virtual Status NewRandomAccessFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& soptions) override; virtual Status NewRandomRWFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override; virtual Status ReuseWritableFile(const std::string& fname, const std::string& old_fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override; virtual Status NewWritableFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& env_options) override; virtual Status NewDirectory(const std::string& name, - unique_ptr* result) override; + std::unique_ptr* result) override; virtual Status FileExists(const std::string& fname) override; @@ -81,7 +81,7 @@ class MockEnv : public EnvWrapper { const std::string& target) override; virtual Status NewLogger(const std::string& fname, - shared_ptr* result) override; + std::shared_ptr* result) override; virtual Status LockFile(const std::string& fname, FileLock** flock) override; diff --git a/env/mock_env_test.cc b/env/mock_env_test.cc index 19e259ccd..abd5b89f0 100644 --- a/env/mock_env_test.cc +++ b/env/mock_env_test.cc @@ -29,7 +29,7 @@ TEST_F(MockEnvTest, Corrupt) { const std::string kGood = "this is a good string, synced to disk"; const std::string kCorrupted = "this part may be corrupted"; const std::string kFileName = "/dir/f"; - unique_ptr writable_file; + std::unique_ptr writable_file; ASSERT_OK(env_->NewWritableFile(kFileName, &writable_file, soptions_)); ASSERT_OK(writable_file->Append(kGood)); ASSERT_TRUE(writable_file->GetFileSize() == kGood.size()); @@ -37,7 +37,7 @@ TEST_F(MockEnvTest, Corrupt) { std::string scratch; scratch.resize(kGood.size() + kCorrupted.size() + 16); Slice result; - unique_ptr rand_file; + std::unique_ptr rand_file; ASSERT_OK(env_->NewRandomAccessFile(kFileName, &rand_file, soptions_)); ASSERT_OK(rand_file->Read(0, kGood.size(), &result, &(scratch[0]))); ASSERT_EQ(result.compare(kGood), 0); diff --git a/hdfs/env_hdfs.h b/hdfs/env_hdfs.h index b0c9e33fd..a77c42e0a 100644 --- a/hdfs/env_hdfs.h +++ b/hdfs/env_hdfs.h @@ -255,23 +255,24 @@ class HdfsEnv : public Env { } virtual Status NewSequentialFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override; - virtual Status NewRandomAccessFile(const std::string& /*fname*/, - unique_ptr* /*result*/, - const EnvOptions& /*options*/) override { + virtual Status NewRandomAccessFile( + const std::string& /*fname*/, + std::unique_ptr* /*result*/, + const EnvOptions& /*options*/) override { return notsup; } virtual Status NewWritableFile(const std::string& /*fname*/, - unique_ptr* /*result*/, + std::unique_ptr* /*result*/, const EnvOptions& /*options*/) override { return notsup; } virtual Status NewDirectory(const std::string& /*name*/, - unique_ptr* /*result*/) override { + std::unique_ptr* /*result*/) override { return notsup; } @@ -328,7 +329,7 @@ class HdfsEnv : public Env { virtual Status UnlockFile(FileLock* /*lock*/) override { return notsup; } virtual Status NewLogger(const std::string& /*fname*/, - shared_ptr* /*result*/) override { + std::shared_ptr* /*result*/) override { return notsup; } diff --git a/include/rocksdb/db.h b/include/rocksdb/db.h index 07e6d0f6d..51d4df598 100644 --- a/include/rocksdb/db.h +++ b/include/rocksdb/db.h @@ -996,9 +996,9 @@ class DB { // cleared aggressively and the iterator might keep getting invalid before // an update is read. virtual Status GetUpdatesSince( - SequenceNumber seq_number, unique_ptr* iter, - const TransactionLogIterator::ReadOptions& - read_options = TransactionLogIterator::ReadOptions()) = 0; + SequenceNumber seq_number, std::unique_ptr* iter, + const TransactionLogIterator::ReadOptions& read_options = + TransactionLogIterator::ReadOptions()) = 0; // Windows API macro interference #undef DeleteFile diff --git a/include/rocksdb/env.h b/include/rocksdb/env.h index 69d361ee9..bc439ac1c 100644 --- a/include/rocksdb/env.h +++ b/include/rocksdb/env.h @@ -137,9 +137,8 @@ class Env { // // The returned file will only be accessed by one thread at a time. virtual Status NewSequentialFile(const std::string& fname, - unique_ptr* result, - const EnvOptions& options) - = 0; + std::unique_ptr* result, + const EnvOptions& options) = 0; // Create a brand new random access read-only file with the // specified name. On success, stores a pointer to the new file in @@ -149,9 +148,8 @@ class Env { // // The returned file may be concurrently accessed by multiple threads. virtual Status NewRandomAccessFile(const std::string& fname, - unique_ptr* result, - const EnvOptions& options) - = 0; + std::unique_ptr* result, + const EnvOptions& options) = 0; // These values match Linux definition // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/fcntl.h#n56 enum WriteLifeTimeHint { @@ -171,7 +169,7 @@ class Env { // // The returned file will only be accessed by one thread at a time. virtual Status NewWritableFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) = 0; // Create an object that writes to a new file with the specified @@ -182,7 +180,7 @@ class Env { // // The returned file will only be accessed by one thread at a time. virtual Status ReopenWritableFile(const std::string& /*fname*/, - unique_ptr* /*result*/, + std::unique_ptr* /*result*/, const EnvOptions& /*options*/) { return Status::NotSupported(); } @@ -190,7 +188,7 @@ class Env { // Reuse an existing file by renaming it and opening it as writable. virtual Status ReuseWritableFile(const std::string& fname, const std::string& old_fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options); // Open `fname` for random read and write, if file doesn't exist the file @@ -199,7 +197,7 @@ class Env { // // The returned file will only be accessed by one thread at a time. virtual Status NewRandomRWFile(const std::string& /*fname*/, - unique_ptr* /*result*/, + std::unique_ptr* /*result*/, const EnvOptions& /*options*/) { return Status::NotSupported("RandomRWFile is not implemented in this Env"); } @@ -209,7 +207,7 @@ class Env { // file in `*result`. The file must exist prior to this call. virtual Status NewMemoryMappedFileBuffer( const std::string& /*fname*/, - unique_ptr* /*result*/) { + std::unique_ptr* /*result*/) { return Status::NotSupported( "MemoryMappedFileBuffer is not implemented in this Env"); } @@ -222,7 +220,7 @@ class Env { // *result and returns OK. On failure stores nullptr in *result and // returns non-OK. virtual Status NewDirectory(const std::string& name, - unique_ptr* result) = 0; + std::unique_ptr* result) = 0; // Returns OK if the named file exists. // NotFound if the named file does not exist, @@ -370,7 +368,7 @@ class Env { // Create and return a log file for storing informational messages. virtual Status NewLogger(const std::string& fname, - shared_ptr* result) = 0; + std::shared_ptr* result) = 0; // Returns the number of micro-seconds since some fixed point in time. // It is often used as system time such as in GenericRateLimiter @@ -942,24 +940,32 @@ class FileLock { void operator=(const FileLock&); }; -extern void LogFlush(const shared_ptr& info_log); +extern void LogFlush(const std::shared_ptr& info_log); extern void Log(const InfoLogLevel log_level, - const shared_ptr& info_log, const char* format, ...); + const std::shared_ptr& info_log, const char* format, + ...); // a set of log functions with different log levels. -extern void Header(const shared_ptr& info_log, const char* format, ...); -extern void Debug(const shared_ptr& info_log, const char* format, ...); -extern void Info(const shared_ptr& info_log, const char* format, ...); -extern void Warn(const shared_ptr& info_log, const char* format, ...); -extern void Error(const shared_ptr& info_log, const char* format, ...); -extern void Fatal(const shared_ptr& info_log, const char* format, ...); +extern void Header(const std::shared_ptr& info_log, const char* format, + ...); +extern void Debug(const std::shared_ptr& info_log, const char* format, + ...); +extern void Info(const std::shared_ptr& info_log, const char* format, + ...); +extern void Warn(const std::shared_ptr& info_log, const char* format, + ...); +extern void Error(const std::shared_ptr& info_log, const char* format, + ...); +extern void Fatal(const std::shared_ptr& info_log, const char* format, + ...); // Log the specified data to *info_log if info_log is non-nullptr. // The default info log level is InfoLogLevel::INFO_LEVEL. -extern void Log(const shared_ptr& info_log, const char* format, ...) +extern void Log(const std::shared_ptr& info_log, const char* format, + ...) # if defined(__GNUC__) || defined(__clang__) - __attribute__((__format__ (__printf__, 2, 3))) + __attribute__((__format__(__printf__, 2, 3))) # endif ; @@ -1005,37 +1011,38 @@ class EnvWrapper : public Env { Env* target() const { return target_; } // The following text is boilerplate that forwards all methods to target() - Status NewSequentialFile(const std::string& f, unique_ptr* r, + Status NewSequentialFile(const std::string& f, + std::unique_ptr* r, const EnvOptions& options) override { return target_->NewSequentialFile(f, r, options); } Status NewRandomAccessFile(const std::string& f, - unique_ptr* r, + std::unique_ptr* r, const EnvOptions& options) override { return target_->NewRandomAccessFile(f, r, options); } - Status NewWritableFile(const std::string& f, unique_ptr* r, + Status NewWritableFile(const std::string& f, std::unique_ptr* r, const EnvOptions& options) override { return target_->NewWritableFile(f, r, options); } Status ReopenWritableFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { return target_->ReopenWritableFile(fname, result, options); } Status ReuseWritableFile(const std::string& fname, const std::string& old_fname, - unique_ptr* r, + std::unique_ptr* r, const EnvOptions& options) override { return target_->ReuseWritableFile(fname, old_fname, r, options); } Status NewRandomRWFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { return target_->NewRandomRWFile(fname, result, options); } Status NewDirectory(const std::string& name, - unique_ptr* result) override { + std::unique_ptr* result) override { return target_->NewDirectory(name, result); } Status FileExists(const std::string& f) override { @@ -1113,7 +1120,7 @@ class EnvWrapper : public Env { return target_->GetTestDirectory(path); } Status NewLogger(const std::string& fname, - shared_ptr* result) override { + std::shared_ptr* result) override { return target_->NewLogger(fname, result); } uint64_t NowMicros() override { return target_->NowMicros(); } diff --git a/include/rocksdb/env_encryption.h b/include/rocksdb/env_encryption.h index 70dce616a..a6e919546 100644 --- a/include/rocksdb/env_encryption.h +++ b/include/rocksdb/env_encryption.h @@ -142,8 +142,9 @@ class EncryptionProvider { // CreateCipherStream creates a block access cipher stream for a file given // given name and options. - virtual Status CreateCipherStream(const std::string& fname, const EnvOptions& options, - Slice& prefix, unique_ptr* result) = 0; + virtual Status CreateCipherStream( + const std::string& fname, const EnvOptions& options, Slice& prefix, + std::unique_ptr* result) = 0; }; // This encryption provider uses a CTR cipher stream, with a given block cipher @@ -174,10 +175,11 @@ class CTREncryptionProvider : public EncryptionProvider { // CreateCipherStream creates a block access cipher stream for a file given // given name and options. - virtual Status CreateCipherStream(const std::string& fname, const EnvOptions& options, - Slice& prefix, unique_ptr* result) override; + virtual Status CreateCipherStream( + const std::string& fname, const EnvOptions& options, Slice& prefix, + std::unique_ptr* result) override; - protected: + protected: // PopulateSecretPrefixPart initializes the data into a new prefix block // that will be encrypted. This function will store the data in plain text. // It will be encrypted later (before written to disk). @@ -187,8 +189,10 @@ class CTREncryptionProvider : public EncryptionProvider { // CreateCipherStreamFromPrefix creates a block access cipher stream for a file given // given name and options. The given prefix is already decrypted. - virtual Status CreateCipherStreamFromPrefix(const std::string& fname, const EnvOptions& options, - uint64_t initialCounter, const Slice& iv, const Slice& prefix, unique_ptr* result); + virtual Status CreateCipherStreamFromPrefix( + const std::string& fname, const EnvOptions& options, + uint64_t initialCounter, const Slice& iv, const Slice& prefix, + std::unique_ptr* result); }; } // namespace rocksdb diff --git a/include/rocksdb/table.h b/include/rocksdb/table.h index 795e0010c..7e5bc6a11 100644 --- a/include/rocksdb/table.h +++ b/include/rocksdb/table.h @@ -462,8 +462,8 @@ class TableFactory { // table_reader is the output table reader. virtual Status NewTableReader( const TableReaderOptions& table_reader_options, - unique_ptr&& file, uint64_t file_size, - unique_ptr* table_reader, + std::unique_ptr&& file, uint64_t file_size, + std::unique_ptr* table_reader, bool prefetch_index_and_filter_in_cache = true) const = 0; // Return a table builder to write to a file for this table type. diff --git a/include/rocksdb/transaction_log.h b/include/rocksdb/transaction_log.h index 1d8ef9186..cf80a633f 100644 --- a/include/rocksdb/transaction_log.h +++ b/include/rocksdb/transaction_log.h @@ -60,7 +60,7 @@ struct BatchResult { // Add empty __ctor and __dtor for the rule of five // However, preserve the original semantics and prohibit copying - // as the unique_ptr member does not copy. + // as the std::unique_ptr member does not copy. BatchResult() {} ~BatchResult() {} diff --git a/include/rocksdb/utilities/env_mirror.h b/include/rocksdb/utilities/env_mirror.h index bc27cdc48..40e9411ff 100644 --- a/include/rocksdb/utilities/env_mirror.h +++ b/include/rocksdb/utilities/env_mirror.h @@ -48,20 +48,21 @@ class EnvMirror : public EnvWrapper { delete b_; } - Status NewSequentialFile(const std::string& f, unique_ptr* r, + Status NewSequentialFile(const std::string& f, + std::unique_ptr* r, const EnvOptions& options) override; Status NewRandomAccessFile(const std::string& f, - unique_ptr* r, + std::unique_ptr* r, const EnvOptions& options) override; - Status NewWritableFile(const std::string& f, unique_ptr* r, + Status NewWritableFile(const std::string& f, std::unique_ptr* r, const EnvOptions& options) override; Status ReuseWritableFile(const std::string& fname, const std::string& old_fname, - unique_ptr* r, + std::unique_ptr* r, const EnvOptions& options) override; virtual Status NewDirectory(const std::string& name, - unique_ptr* result) override { - unique_ptr br; + std::unique_ptr* result) override { + std::unique_ptr br; Status as = a_->NewDirectory(name, result); Status bs = b_->NewDirectory(name, &br); assert(as == bs); diff --git a/include/rocksdb/utilities/object_registry.h b/include/rocksdb/utilities/object_registry.h index b046ba7c1..86a51b92e 100644 --- a/include/rocksdb/utilities/object_registry.h +++ b/include/rocksdb/utilities/object_registry.h @@ -27,8 +27,8 @@ namespace rocksdb { template T* NewCustomObject(const std::string& target, std::unique_ptr* res_guard); -// Returns a new T when called with a string. Populates the unique_ptr argument -// if granting ownership to caller. +// Returns a new T when called with a string. Populates the std::unique_ptr +// argument if granting ownership to caller. template using FactoryFunc = std::function*)>; diff --git a/include/rocksdb/utilities/stackable_db.h b/include/rocksdb/utilities/stackable_db.h index 88426b3f5..eae3a85ea 100644 --- a/include/rocksdb/utilities/stackable_db.h +++ b/include/rocksdb/utilities/stackable_db.h @@ -369,7 +369,7 @@ class StackableDB : public DB { } virtual Status GetUpdatesSince( - SequenceNumber seq_number, unique_ptr* iter, + SequenceNumber seq_number, std::unique_ptr* iter, const TransactionLogIterator::ReadOptions& read_options) override { return db_->GetUpdatesSince(seq_number, iter, read_options); } diff --git a/java/rocksjni/options.cc b/java/rocksjni/options.cc index 7fff7cdbe..342ee3e9e 100644 --- a/java/rocksjni/options.cc +++ b/java/rocksjni/options.cc @@ -1970,8 +1970,8 @@ jbyte Java_org_rocksdb_Options_compressionType(JNIEnv* /*env*/, * @param jcompression_levels A reference to a java byte array * where each byte indicates a compression level * - * @return A unique_ptr to the vector, or unique_ptr(nullptr) if a JNI exception - * occurs + * @return A std::unique_ptr to the vector, or std::unique_ptr(nullptr) if a JNI + * exception occurs */ std::unique_ptr> rocksdb_compression_vector_helper(JNIEnv* env, jbyteArray jcompression_levels) { diff --git a/memtable/hash_skiplist_rep.cc b/memtable/hash_skiplist_rep.cc index 93082b1ec..a5c46011e 100644 --- a/memtable/hash_skiplist_rep.cc +++ b/memtable/hash_skiplist_rep.cc @@ -168,7 +168,7 @@ class HashSkipListRep : public MemTableRep { Bucket* list_; Bucket::Iterator iter_; // here we track if we own list_. If we own it, we are also - // responsible for it's cleaning. This is a poor man's shared_ptr + // responsible for it's cleaning. This is a poor man's std::shared_ptr bool own_list_; std::unique_ptr arena_; std::string tmp_; // For passing to EncodeKey diff --git a/options/cf_options.h b/options/cf_options.h index 1658bf427..69b0b0105 100644 --- a/options/cf_options.h +++ b/options/cf_options.h @@ -18,7 +18,7 @@ namespace rocksdb { // ImmutableCFOptions is a data struct used by RocksDB internal. It contains a // subset of Options that should not be changed during the entire lifetime // of DB. Raw pointers defined in this struct do not have ownership to the data -// they point to. Options contains shared_ptr to these data. +// they point to. Options contains std::shared_ptr to these data. struct ImmutableCFOptions { ImmutableCFOptions(); explicit ImmutableCFOptions(const Options& options); diff --git a/options/options_parser.cc b/options/options_parser.cc index f9144b67d..32cfb8d53 100644 --- a/options/options_parser.cc +++ b/options/options_parser.cc @@ -48,7 +48,7 @@ Status PersistRocksDBOptions(const DBOptions& db_opt, if (!s.ok()) { return s; } - unique_ptr writable; + std::unique_ptr writable; writable.reset(new WritableFileWriter(std::move(wf), file_name, EnvOptions(), nullptr /* statistics */)); diff --git a/port/win/env_win.h b/port/win/env_win.h index 81b323a71..d61ac3acd 100644 --- a/port/win/env_win.h +++ b/port/win/env_win.h @@ -109,8 +109,8 @@ public: // The returned file will only be accessed by one thread at a time. virtual Status NewRandomRWFile(const std::string& fname, - unique_ptr* result, - const EnvOptions& options); + std::unique_ptr* result, + const EnvOptions& options); virtual Status NewMemoryMappedFileBuffer( const std::string& fname, diff --git a/port/win/win_thread.cc b/port/win/win_thread.cc index b48af2370..9a976e2c6 100644 --- a/port/win/win_thread.cc +++ b/port/win/win_thread.cc @@ -40,7 +40,7 @@ struct WindowsThread::Data { void WindowsThread::Init(std::function&& func) { data_ = std::make_shared(std::move(func)); - // We create another instance of shared_ptr to get an additional ref + // We create another instance of std::shared_ptr to get an additional ref // since we may detach and destroy this instance before the threadproc // may start to run. We choose to allocate this additional ref on the heap // so we do not need to synchronize and allow this thread to proceed diff --git a/table/adaptive_table_factory.cc b/table/adaptive_table_factory.cc index 0a3e9415a..bbba3b919 100644 --- a/table/adaptive_table_factory.cc +++ b/table/adaptive_table_factory.cc @@ -42,8 +42,8 @@ extern const uint64_t kCuckooTableMagicNumber; Status AdaptiveTableFactory::NewTableReader( const TableReaderOptions& table_reader_options, - unique_ptr&& file, uint64_t file_size, - unique_ptr* table, + std::unique_ptr&& file, uint64_t file_size, + std::unique_ptr* table, bool /*prefetch_index_and_filter_in_cache*/) const { Footer footer; auto s = ReadFooterFromFile(file.get(), nullptr /* prefetch_buffer */, diff --git a/table/adaptive_table_factory.h b/table/adaptive_table_factory.h index 00af6a76e..2a82dbfa9 100644 --- a/table/adaptive_table_factory.h +++ b/table/adaptive_table_factory.h @@ -35,8 +35,8 @@ class AdaptiveTableFactory : public TableFactory { Status NewTableReader( const TableReaderOptions& table_reader_options, - unique_ptr&& file, uint64_t file_size, - unique_ptr* table, + std::unique_ptr&& file, uint64_t file_size, + std::unique_ptr* table, bool prefetch_index_and_filter_in_cache = true) const override; TableBuilder* NewTableBuilder( diff --git a/table/block_based_table_factory.cc b/table/block_based_table_factory.cc index 485aed870..fbb7406a3 100644 --- a/table/block_based_table_factory.cc +++ b/table/block_based_table_factory.cc @@ -194,8 +194,8 @@ BlockBasedTableFactory::BlockBasedTableFactory( Status BlockBasedTableFactory::NewTableReader( const TableReaderOptions& table_reader_options, - unique_ptr&& file, uint64_t file_size, - unique_ptr* table_reader, + std::unique_ptr&& file, uint64_t file_size, + std::unique_ptr* table_reader, bool prefetch_index_and_filter_in_cache) const { return BlockBasedTable::Open( table_reader_options.ioptions, table_reader_options.env_options, diff --git a/table/block_based_table_factory.h b/table/block_based_table_factory.h index b30bd6232..cde6f6535 100644 --- a/table/block_based_table_factory.h +++ b/table/block_based_table_factory.h @@ -53,8 +53,8 @@ class BlockBasedTableFactory : public TableFactory { Status NewTableReader( const TableReaderOptions& table_reader_options, - unique_ptr&& file, uint64_t file_size, - unique_ptr* table_reader, + std::unique_ptr&& file, uint64_t file_size, + std::unique_ptr* table_reader, bool prefetch_index_and_filter_in_cache = true) const override; TableBuilder* NewTableBuilder( diff --git a/table/block_based_table_reader.cc b/table/block_based_table_reader.cc index e6272cee8..e0b967d6c 100644 --- a/table/block_based_table_reader.cc +++ b/table/block_based_table_reader.cc @@ -745,9 +745,9 @@ Status BlockBasedTable::Open(const ImmutableCFOptions& ioptions, const EnvOptions& env_options, const BlockBasedTableOptions& table_options, const InternalKeyComparator& internal_comparator, - unique_ptr&& file, + std::unique_ptr&& file, uint64_t file_size, - unique_ptr* table_reader, + std::unique_ptr* table_reader, const SliceTransform* prefix_extractor, const bool prefetch_index_and_filter_in_cache, const bool skip_filters, const int level, @@ -826,7 +826,7 @@ Status BlockBasedTable::Open(const ImmutableCFOptions& ioptions, rep->internal_prefix_transform.reset( new InternalKeySliceTransform(prefix_extractor)); SetupCacheKeyPrefix(rep, file_size); - unique_ptr new_table(new BlockBasedTable(rep)); + std::unique_ptr new_table(new BlockBasedTable(rep)); // page cache options rep->persistent_cache_options = @@ -1029,7 +1029,7 @@ Status BlockBasedTable::Open(const ImmutableCFOptions& ioptions, bool disable_prefix_seek = rep->index_type == BlockBasedTableOptions::kHashSearch && need_upper_bound_check; - unique_ptr> iter( + std::unique_ptr> iter( new_table->NewIndexIterator(ReadOptions(), disable_prefix_seek, nullptr, &index_entry)); s = iter->status(); @@ -1948,7 +1948,7 @@ bool BlockBasedTable::PrefixMayMatch( // Then, try find it within each block // we already know prefix_extractor and prefix_extractor_name must match // because `CheckPrefixMayMatch` first checks `check_filter_ == true` - unique_ptr> iiter( + std::unique_ptr> iiter( NewIndexIterator(no_io_read_options, /* need_upper_bound_check */ false)); iiter->Seek(internal_prefix); @@ -2730,7 +2730,7 @@ Status BlockBasedTable::CreateIndexReader( } uint64_t BlockBasedTable::ApproximateOffsetOf(const Slice& key) { - unique_ptr> index_iter( + std::unique_ptr> index_iter( NewIndexIterator(ReadOptions())); index_iter->Seek(key); diff --git a/table/block_based_table_reader.h b/table/block_based_table_reader.h index 3502c26c4..d6d5246cf 100644 --- a/table/block_based_table_reader.h +++ b/table/block_based_table_reader.h @@ -89,8 +89,9 @@ class BlockBasedTable : public TableReader { const EnvOptions& env_options, const BlockBasedTableOptions& table_options, const InternalKeyComparator& internal_key_comparator, - unique_ptr&& file, - uint64_t file_size, unique_ptr* table_reader, + std::unique_ptr&& file, + uint64_t file_size, + std::unique_ptr* table_reader, const SliceTransform* prefix_extractor = nullptr, bool prefetch_index_and_filter_in_cache = true, bool skip_filters = false, int level = -1, @@ -458,7 +459,7 @@ struct BlockBasedTable::Rep { const FilterPolicy* const filter_policy; const InternalKeyComparator& internal_comparator; Status status; - unique_ptr file; + std::unique_ptr file; char cache_key_prefix[kMaxCacheKeyPrefixSize]; size_t cache_key_prefix_size = 0; char persistent_cache_key_prefix[kMaxCacheKeyPrefixSize]; @@ -474,8 +475,8 @@ struct BlockBasedTable::Rep { // index_reader and filter will be populated and used only when // options.block_cache is nullptr; otherwise we will get the index block via // the block cache. - unique_ptr index_reader; - unique_ptr filter; + std::unique_ptr index_reader; + std::unique_ptr filter; enum class FilterType { kNoFilter, @@ -500,7 +501,7 @@ struct BlockBasedTable::Rep { // module should not be relying on db module. However to make things easier // and compatible with existing code, we introduce a wrapper that allows // block to extract prefix without knowing if a key is internal or not. - unique_ptr internal_prefix_transform; + std::unique_ptr internal_prefix_transform; std::shared_ptr table_prefix_extractor; // only used in level 0 files when pin_l0_filter_and_index_blocks_in_cache is diff --git a/table/cuckoo_table_builder_test.cc b/table/cuckoo_table_builder_test.cc index e4a1804e7..c1e350327 100644 --- a/table/cuckoo_table_builder_test.cc +++ b/table/cuckoo_table_builder_test.cc @@ -51,7 +51,7 @@ class CuckooBuilderTest : public testing::Test { } } // Read file - unique_ptr read_file; + std::unique_ptr read_file; ASSERT_OK(env_->NewRandomAccessFile(fname, &read_file, env_options_)); uint64_t read_file_size; ASSERT_OK(env_->GetFileSize(fname, &read_file_size)); @@ -63,7 +63,7 @@ class CuckooBuilderTest : public testing::Test { // Assert Table Properties. TableProperties* props = nullptr; - unique_ptr file_reader( + std::unique_ptr file_reader( new RandomAccessFileReader(std::move(read_file), fname)); ASSERT_OK(ReadTableProperties(file_reader.get(), read_file_size, kCuckooTableMagicNumber, ioptions, @@ -161,10 +161,10 @@ class CuckooBuilderTest : public testing::Test { }; TEST_F(CuckooBuilderTest, SuccessWithEmptyFile) { - unique_ptr writable_file; + std::unique_ptr writable_file; fname = test::PerThreadDBPath("EmptyFile"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, 4, 100, BytewiseComparator(), 1, false, false, @@ -203,10 +203,10 @@ TEST_F(CuckooBuilderTest, WriteSuccessNoCollisionFullKey) { } uint64_t expected_table_size = GetExpectedTableSize(keys.size()); - unique_ptr writable_file; + std::unique_ptr writable_file; fname = test::PerThreadDBPath("NoCollisionFullKey"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 100, BytewiseComparator(), 1, false, false, @@ -252,10 +252,10 @@ TEST_F(CuckooBuilderTest, WriteSuccessWithCollisionFullKey) { } uint64_t expected_table_size = GetExpectedTableSize(keys.size()); - unique_ptr writable_file; + std::unique_ptr writable_file; fname = test::PerThreadDBPath("WithCollisionFullKey"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 100, BytewiseComparator(), 1, false, false, @@ -300,11 +300,11 @@ TEST_F(CuckooBuilderTest, WriteSuccessWithCollisionAndCuckooBlock) { } uint64_t expected_table_size = GetExpectedTableSize(keys.size()); - unique_ptr writable_file; + std::unique_ptr writable_file; uint32_t cuckoo_block_size = 2; fname = test::PerThreadDBPath("WithCollisionFullKey2"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder( file_writer.get(), kHashTableRatio, num_hash_fun, 100, @@ -354,10 +354,10 @@ TEST_F(CuckooBuilderTest, WithCollisionPathFullKey) { } uint64_t expected_table_size = GetExpectedTableSize(keys.size()); - unique_ptr writable_file; + std::unique_ptr writable_file; fname = test::PerThreadDBPath("WithCollisionPathFullKey"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 100, BytewiseComparator(), 1, false, false, @@ -404,10 +404,10 @@ TEST_F(CuckooBuilderTest, WithCollisionPathFullKeyAndCuckooBlock) { } uint64_t expected_table_size = GetExpectedTableSize(keys.size()); - unique_ptr writable_file; + std::unique_ptr writable_file; fname = test::PerThreadDBPath("WithCollisionPathFullKeyAndCuckooBlock"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 100, BytewiseComparator(), 2, false, false, @@ -447,10 +447,10 @@ TEST_F(CuckooBuilderTest, WriteSuccessNoCollisionUserKey) { std::vector expected_locations = {0, 1, 2, 3}; uint64_t expected_table_size = GetExpectedTableSize(user_keys.size()); - unique_ptr writable_file; + std::unique_ptr writable_file; fname = test::PerThreadDBPath("NoCollisionUserKey"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 100, BytewiseComparator(), 1, false, false, @@ -491,10 +491,10 @@ TEST_F(CuckooBuilderTest, WriteSuccessWithCollisionUserKey) { std::vector expected_locations = {0, 1, 2, 3}; uint64_t expected_table_size = GetExpectedTableSize(user_keys.size()); - unique_ptr writable_file; + std::unique_ptr writable_file; fname = test::PerThreadDBPath("WithCollisionUserKey"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 100, BytewiseComparator(), 1, false, false, @@ -537,10 +537,10 @@ TEST_F(CuckooBuilderTest, WithCollisionPathUserKey) { std::vector expected_locations = {0, 1, 3, 4, 2}; uint64_t expected_table_size = GetExpectedTableSize(user_keys.size()); - unique_ptr writable_file; + std::unique_ptr writable_file; fname = test::PerThreadDBPath("WithCollisionPathUserKey"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 2, BytewiseComparator(), 1, false, false, @@ -582,10 +582,10 @@ TEST_F(CuckooBuilderTest, FailWhenCollisionPathTooLong) { }; hash_map = std::move(hm); - unique_ptr writable_file; + std::unique_ptr writable_file; fname = test::PerThreadDBPath("WithCollisionPathUserKey"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 2, BytewiseComparator(), 1, false, false, @@ -610,10 +610,10 @@ TEST_F(CuckooBuilderTest, FailWhenSameKeyInserted) { uint32_t num_hash_fun = 4; std::string user_key = "repeatedkey"; - unique_ptr writable_file; + std::unique_ptr writable_file; fname = test::PerThreadDBPath("FailWhenSameKeyInserted"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 100, BytewiseComparator(), 1, false, false, diff --git a/table/cuckoo_table_factory.cc b/table/cuckoo_table_factory.cc index 84d22468e..74d18d512 100644 --- a/table/cuckoo_table_factory.cc +++ b/table/cuckoo_table_factory.cc @@ -14,7 +14,7 @@ namespace rocksdb { Status CuckooTableFactory::NewTableReader( const TableReaderOptions& table_reader_options, - unique_ptr&& file, uint64_t file_size, + std::unique_ptr&& file, uint64_t file_size, std::unique_ptr* table, bool /*prefetch_index_and_filter_in_cache*/) const { std::unique_ptr new_reader(new CuckooTableReader( diff --git a/table/cuckoo_table_factory.h b/table/cuckoo_table_factory.h index a96635de5..eb3c5e517 100644 --- a/table/cuckoo_table_factory.h +++ b/table/cuckoo_table_factory.h @@ -60,8 +60,8 @@ class CuckooTableFactory : public TableFactory { Status NewTableReader( const TableReaderOptions& table_reader_options, - unique_ptr&& file, uint64_t file_size, - unique_ptr* table, + std::unique_ptr&& file, uint64_t file_size, + std::unique_ptr* table, bool prefetch_index_and_filter_in_cache = true) const override; TableBuilder* NewTableBuilder( diff --git a/table/cuckoo_table_reader_test.cc b/table/cuckoo_table_reader_test.cc index 36083c547..74fb52e6c 100644 --- a/table/cuckoo_table_reader_test.cc +++ b/table/cuckoo_table_reader_test.cc @@ -95,7 +95,7 @@ class CuckooReaderTest : public testing::Test { const Comparator* ucomp = BytewiseComparator()) { std::unique_ptr writable_file; ASSERT_OK(env->NewWritableFile(fname, &writable_file, env_options)); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(writable_file), fname, env_options)); CuckooTableBuilder builder( @@ -115,7 +115,7 @@ class CuckooReaderTest : public testing::Test { // Check reader now. std::unique_ptr read_file; ASSERT_OK(env->NewRandomAccessFile(fname, &read_file, env_options)); - unique_ptr file_reader( + std::unique_ptr file_reader( new RandomAccessFileReader(std::move(read_file), fname)); const ImmutableCFOptions ioptions(options); CuckooTableReader reader(ioptions, std::move(file_reader), file_size, ucomp, @@ -144,7 +144,7 @@ class CuckooReaderTest : public testing::Test { void CheckIterator(const Comparator* ucomp = BytewiseComparator()) { std::unique_ptr read_file; ASSERT_OK(env->NewRandomAccessFile(fname, &read_file, env_options)); - unique_ptr file_reader( + std::unique_ptr file_reader( new RandomAccessFileReader(std::move(read_file), fname)); const ImmutableCFOptions ioptions(options); CuckooTableReader reader(ioptions, std::move(file_reader), file_size, ucomp, @@ -323,7 +323,7 @@ TEST_F(CuckooReaderTest, WhenKeyNotFound) { CreateCuckooFileAndCheckReader(); std::unique_ptr read_file; ASSERT_OK(env->NewRandomAccessFile(fname, &read_file, env_options)); - unique_ptr file_reader( + std::unique_ptr file_reader( new RandomAccessFileReader(std::move(read_file), fname)); const ImmutableCFOptions ioptions(options); CuckooTableReader reader(ioptions, std::move(file_reader), file_size, ucmp, @@ -411,7 +411,7 @@ void WriteFile(const std::vector& keys, std::unique_ptr writable_file; ASSERT_OK(env->NewWritableFile(fname, &writable_file, env_options)); - unique_ptr file_writer( + std::unique_ptr file_writer( new WritableFileWriter(std::move(writable_file), fname, env_options)); CuckooTableBuilder builder( file_writer.get(), hash_ratio, 64, 1000, test::Uint64Comparator(), 5, @@ -432,7 +432,7 @@ void WriteFile(const std::vector& keys, env->GetFileSize(fname, &file_size); std::unique_ptr read_file; ASSERT_OK(env->NewRandomAccessFile(fname, &read_file, env_options)); - unique_ptr file_reader( + std::unique_ptr file_reader( new RandomAccessFileReader(std::move(read_file), fname)); const ImmutableCFOptions ioptions(options); @@ -464,7 +464,7 @@ void ReadKeys(uint64_t num, uint32_t batch_size) { env->GetFileSize(fname, &file_size); std::unique_ptr read_file; ASSERT_OK(env->NewRandomAccessFile(fname, &read_file, env_options)); - unique_ptr file_reader( + std::unique_ptr file_reader( new RandomAccessFileReader(std::move(read_file), fname)); const ImmutableCFOptions ioptions(options); diff --git a/table/data_block_hash_index_test.cc b/table/data_block_hash_index_test.cc index f25147079..579a7608b 100644 --- a/table/data_block_hash_index_test.cc +++ b/table/data_block_hash_index_test.cc @@ -542,9 +542,9 @@ TEST(DataBlockHashIndex, BlockTestLarge) { void TestBoundary(InternalKey& ik1, std::string& v1, InternalKey& ik2, std::string& v2, InternalKey& seek_ikey, GetContext& get_context, Options& options) { - unique_ptr file_writer; - unique_ptr file_reader; - unique_ptr table_reader; + std::unique_ptr file_writer; + std::unique_ptr file_reader; + std::unique_ptr table_reader; int level_ = -1; std::vector keys; @@ -557,7 +557,7 @@ void TestBoundary(InternalKey& ik1, std::string& v1, InternalKey& ik2, soptions.use_mmap_reads = ioptions.allow_mmap_reads; file_writer.reset( test::GetWritableFileWriter(new test::StringSink(), "" /* don't care */)); - unique_ptr builder; + std::unique_ptr builder; std::vector> int_tbl_prop_collector_factories; std::string column_family_name; diff --git a/table/mock_table.cc b/table/mock_table.cc index a5473b30b..65a436169 100644 --- a/table/mock_table.cc +++ b/table/mock_table.cc @@ -60,8 +60,8 @@ MockTableFactory::MockTableFactory() : next_id_(1) {} Status MockTableFactory::NewTableReader( const TableReaderOptions& /*table_reader_options*/, - unique_ptr&& file, uint64_t /*file_size*/, - unique_ptr* table_reader, + std::unique_ptr&& file, uint64_t /*file_size*/, + std::unique_ptr* table_reader, bool /*prefetch_index_and_filter_in_cache*/) const { uint32_t id = GetIDFromFile(file.get()); diff --git a/table/mock_table.h b/table/mock_table.h index 92cf87370..2f123a963 100644 --- a/table/mock_table.h +++ b/table/mock_table.h @@ -157,8 +157,8 @@ class MockTableFactory : public TableFactory { const char* Name() const override { return "MockTable"; } Status NewTableReader( const TableReaderOptions& table_reader_options, - unique_ptr&& file, uint64_t file_size, - unique_ptr* table_reader, + std::unique_ptr&& file, uint64_t file_size, + std::unique_ptr* table_reader, bool prefetch_index_and_filter_in_cache = true) const override; TableBuilder* NewTableBuilder( const TableBuilderOptions& table_builder_options, diff --git a/table/plain_table_factory.cc b/table/plain_table_factory.cc index b88a689d4..273a1bd4f 100644 --- a/table/plain_table_factory.cc +++ b/table/plain_table_factory.cc @@ -19,8 +19,8 @@ namespace rocksdb { Status PlainTableFactory::NewTableReader( const TableReaderOptions& table_reader_options, - unique_ptr&& file, uint64_t file_size, - unique_ptr* table, + std::unique_ptr&& file, uint64_t file_size, + std::unique_ptr* table, bool /*prefetch_index_and_filter_in_cache*/) const { return PlainTableReader::Open( table_reader_options.ioptions, table_reader_options.env_options, diff --git a/table/plain_table_factory.h b/table/plain_table_factory.h index f540a92b8..157e3acda 100644 --- a/table/plain_table_factory.h +++ b/table/plain_table_factory.h @@ -149,8 +149,8 @@ class PlainTableFactory : public TableFactory { const char* Name() const override { return "PlainTable"; } Status NewTableReader(const TableReaderOptions& table_reader_options, - unique_ptr&& file, - uint64_t file_size, unique_ptr* table, + std::unique_ptr&& file, + uint64_t file_size, std::unique_ptr* table, bool prefetch_index_and_filter_in_cache) const override; TableBuilder* NewTableBuilder( diff --git a/table/plain_table_key_coding.h b/table/plain_table_key_coding.h index 321e0aed5..9a27ad06b 100644 --- a/table/plain_table_key_coding.h +++ b/table/plain_table_key_coding.h @@ -114,7 +114,7 @@ class PlainTableFileReader { }; // Keep buffers for two recent reads. - std::array, 2> buffers_; + std::array, 2> buffers_; uint32_t num_buf_; Status status_; diff --git a/table/plain_table_reader.cc b/table/plain_table_reader.cc index 4f6c99f94..ae656763c 100644 --- a/table/plain_table_reader.cc +++ b/table/plain_table_reader.cc @@ -91,14 +91,13 @@ class PlainTableIterator : public InternalIterator { }; extern const uint64_t kPlainTableMagicNumber; -PlainTableReader::PlainTableReader(const ImmutableCFOptions& ioptions, - unique_ptr&& file, - const EnvOptions& storage_options, - const InternalKeyComparator& icomparator, - EncodingType encoding_type, - uint64_t file_size, - const TableProperties* table_properties, - const SliceTransform* prefix_extractor) +PlainTableReader::PlainTableReader( + const ImmutableCFOptions& ioptions, + std::unique_ptr&& file, + const EnvOptions& storage_options, const InternalKeyComparator& icomparator, + EncodingType encoding_type, uint64_t file_size, + const TableProperties* table_properties, + const SliceTransform* prefix_extractor) : internal_comparator_(icomparator), encoding_type_(encoding_type), full_scan_mode_(false), @@ -118,8 +117,8 @@ PlainTableReader::~PlainTableReader() { Status PlainTableReader::Open( const ImmutableCFOptions& ioptions, const EnvOptions& env_options, const InternalKeyComparator& internal_comparator, - unique_ptr&& file, uint64_t file_size, - unique_ptr* table_reader, const int bloom_bits_per_key, + std::unique_ptr&& file, uint64_t file_size, + std::unique_ptr* table_reader, const int bloom_bits_per_key, double hash_table_ratio, size_t index_sparseness, size_t huge_page_tlb_size, bool full_scan_mode, const SliceTransform* prefix_extractor) { if (file_size > PlainTableIndex::kMaxFileSize) { diff --git a/table/plain_table_reader.h b/table/plain_table_reader.h index d7a8ed4aa..5f8248dd7 100644 --- a/table/plain_table_reader.h +++ b/table/plain_table_reader.h @@ -48,7 +48,7 @@ struct PlainTableReaderFileInfo { bool is_mmap_mode; Slice file_data; uint32_t data_end_offset; - unique_ptr file; + std::unique_ptr file; PlainTableReaderFileInfo(unique_ptr&& _file, const EnvOptions& storage_options, @@ -71,8 +71,8 @@ class PlainTableReader: public TableReader { static Status Open(const ImmutableCFOptions& ioptions, const EnvOptions& env_options, const InternalKeyComparator& internal_comparator, - unique_ptr&& file, - uint64_t file_size, unique_ptr* table, + std::unique_ptr&& file, + uint64_t file_size, std::unique_ptr* table, const int bloom_bits_per_key, double hash_table_ratio, size_t index_sparseness, size_t huge_page_tlb_size, bool full_scan_mode, @@ -104,7 +104,7 @@ class PlainTableReader: public TableReader { } PlainTableReader(const ImmutableCFOptions& ioptions, - unique_ptr&& file, + std::unique_ptr&& file, const EnvOptions& env_options, const InternalKeyComparator& internal_comparator, EncodingType encoding_type, uint64_t file_size, diff --git a/table/table_reader_bench.cc b/table/table_reader_bench.cc index 43e5b2f0b..fbcfac826 100644 --- a/table/table_reader_bench.cc +++ b/table/table_reader_bench.cc @@ -86,9 +86,9 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options, const ImmutableCFOptions ioptions(opts); const ColumnFamilyOptions cfo(opts); const MutableCFOptions moptions(cfo); - unique_ptr file_writer; + std::unique_ptr file_writer; if (!through_db) { - unique_ptr file; + std::unique_ptr file; env->NewWritableFile(file_name, &file, env_options); std::vector > @@ -127,9 +127,9 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options, db->Flush(FlushOptions()); } - unique_ptr table_reader; + std::unique_ptr table_reader; if (!through_db) { - unique_ptr raf; + std::unique_ptr raf; s = env->NewRandomAccessFile(file_name, &raf, env_options); if (!s.ok()) { fprintf(stderr, "Create File Error: %s\n", s.ToString().c_str()); @@ -137,7 +137,7 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options, } uint64_t file_size; env->GetFileSize(file_name, &file_size); - unique_ptr file_reader( + std::unique_ptr file_reader( new RandomAccessFileReader(std::move(raf), file_name)); s = opts.table_factory->NewTableReader( TableReaderOptions(ioptions, moptions.prefix_extractor.get(), diff --git a/table/table_test.cc b/table/table_test.cc index 2e209a3ec..d5d70ef33 100644 --- a/table/table_test.cc +++ b/table/table_test.cc @@ -325,7 +325,7 @@ class TableConstructor: public Constructor { soptions.use_mmap_reads = ioptions.allow_mmap_reads; file_writer_.reset(test::GetWritableFileWriter(new test::StringSink(), "" /* don't care */)); - unique_ptr builder; + std::unique_ptr builder; std::vector> int_tbl_prop_collector_factories; std::string column_family_name; @@ -423,9 +423,9 @@ class TableConstructor: public Constructor { } uint64_t uniq_id_; - unique_ptr file_writer_; - unique_ptr file_reader_; - unique_ptr table_reader_; + std::unique_ptr file_writer_; + std::unique_ptr file_reader_; + std::unique_ptr table_reader_; bool convert_to_internal_key_; int level_; @@ -508,7 +508,7 @@ class InternalIteratorFromIterator : public InternalIterator { virtual Status status() const override { return it_->status(); } private: - unique_ptr it_; + std::unique_ptr it_; }; class DBConstructor: public Constructor { @@ -1024,7 +1024,7 @@ class HarnessTest : public testing::Test { WriteBufferManager write_buffer_; bool support_prev_; bool only_support_prefix_seek_; - shared_ptr internal_comparator_; + std::shared_ptr internal_comparator_; }; static bool Between(uint64_t val, uint64_t low, uint64_t high) { @@ -1393,8 +1393,8 @@ void PrefetchRange(TableConstructor* c, Options* opt, // prefetch auto* table_reader = dynamic_cast(c->GetTableReader()); Status s; - unique_ptr begin, end; - unique_ptr i_begin, i_end; + std::unique_ptr begin, end; + std::unique_ptr i_begin, i_end; if (key_begin != nullptr) { if (c->ConvertToInternalKey()) { i_begin.reset(new InternalKey(key_begin, kMaxSequenceNumber, kTypeValue)); @@ -1425,7 +1425,7 @@ TEST_P(BlockBasedTableTest, PrefetchTest) { // The purpose of this test is to test the prefetching operation built into // BlockBasedTable. Options opt; - unique_ptr ikc; + std::unique_ptr ikc; ikc.reset(new test::PlainInternalKeyComparator(opt.comparator)); opt.compression = kNoCompression; BlockBasedTableOptions table_options = GetBlockBasedTableOptions(); @@ -2017,7 +2017,7 @@ TEST_P(BlockBasedTableTest, FilterBlockInBlockCache) { // -- PART 1: Open with regular block cache. // Since block_cache is disabled, no cache activities will be involved. - unique_ptr iter; + std::unique_ptr iter; int64_t last_cache_bytes_read = 0; // At first, no block will be accessed. @@ -2351,7 +2351,7 @@ TEST_P(BlockBasedTableTest, NoObjectInCacheAfterTableClose) { } // Create a table Options opt; - unique_ptr ikc; + std::unique_ptr ikc; ikc.reset(new test::PlainInternalKeyComparator(opt.comparator)); opt.compression = kNoCompression; BlockBasedTableOptions table_options = @@ -2427,7 +2427,7 @@ TEST_P(BlockBasedTableTest, BlockCacheLeak) { // unique ID from the file. Options opt; - unique_ptr ikc; + std::unique_ptr ikc; ikc.reset(new test::PlainInternalKeyComparator(opt.comparator)); opt.compression = kNoCompression; BlockBasedTableOptions table_options = GetBlockBasedTableOptions(); @@ -2450,7 +2450,7 @@ TEST_P(BlockBasedTableTest, BlockCacheLeak) { const MutableCFOptions moptions(opt); c.Finish(opt, ioptions, moptions, table_options, *ikc, &keys, &kvmap); - unique_ptr iter( + std::unique_ptr iter( c.NewIterator(moptions.prefix_extractor.get())); iter->SeekToFirst(); while (iter->Valid()) { @@ -2511,7 +2511,7 @@ TEST_P(BlockBasedTableTest, MemoryAllocator) { auto custom_memory_allocator = std::make_shared(); { Options opt; - unique_ptr ikc; + std::unique_ptr ikc; ikc.reset(new test::PlainInternalKeyComparator(opt.comparator)); opt.compression = kNoCompression; BlockBasedTableOptions table_options; @@ -2538,7 +2538,7 @@ TEST_P(BlockBasedTableTest, MemoryAllocator) { const MutableCFOptions moptions(opt); c.Finish(opt, ioptions, moptions, table_options, *ikc, &keys, &kvmap); - unique_ptr iter( + std::unique_ptr iter( c.NewIterator(moptions.prefix_extractor.get())); iter->SeekToFirst(); while (iter->Valid()) { @@ -2630,7 +2630,7 @@ TEST_F(PlainTableTest, BasicPlainTableProperties) { PlainTableFactory factory(plain_table_options); test::StringSink sink; - unique_ptr file_writer( + std::unique_ptr file_writer( test::GetWritableFileWriter(new test::StringSink(), "" /* don't care */)); Options options; const ImmutableCFOptions ioptions(options); @@ -2659,7 +2659,7 @@ TEST_F(PlainTableTest, BasicPlainTableProperties) { test::StringSink* ss = static_cast(file_writer->writable_file()); - unique_ptr file_reader( + std::unique_ptr file_reader( test::GetRandomAccessFileReader( new test::StringSource(ss->contents(), 72242, true))); @@ -3253,7 +3253,7 @@ TEST_F(PrefixTest, PrefixAndWholeKeyTest) { TEST_P(BlockBasedTableTest, DISABLED_TableWithGlobalSeqno) { BlockBasedTableOptions bbto = GetBlockBasedTableOptions(); test::StringSink* sink = new test::StringSink(); - unique_ptr file_writer( + std::unique_ptr file_writer( test::GetWritableFileWriter(sink, "" /* don't care */)); Options options; options.table_factory.reset(NewBlockBasedTableFactory(bbto)); @@ -3291,7 +3291,7 @@ TEST_P(BlockBasedTableTest, DISABLED_TableWithGlobalSeqno) { // Helper function to get version, global_seqno, global_seqno_offset std::function GetVersionAndGlobalSeqno = [&]() { - unique_ptr file_reader( + std::unique_ptr file_reader( test::GetRandomAccessFileReader( new test::StringSource(ss_rw.contents(), 73342, true))); @@ -3320,9 +3320,9 @@ TEST_P(BlockBasedTableTest, DISABLED_TableWithGlobalSeqno) { }; // Helper function to get the contents of the table InternalIterator - unique_ptr table_reader; + std::unique_ptr table_reader; std::function GetTableInternalIter = [&]() { - unique_ptr file_reader( + std::unique_ptr file_reader( test::GetRandomAccessFileReader( new test::StringSource(ss_rw.contents(), 73342, true))); @@ -3435,7 +3435,7 @@ TEST_P(BlockBasedTableTest, BlockAlignTest) { BlockBasedTableOptions bbto = GetBlockBasedTableOptions(); bbto.block_align = true; test::StringSink* sink = new test::StringSink(); - unique_ptr file_writer( + std::unique_ptr file_writer( test::GetWritableFileWriter(sink, "" /* don't care */)); Options options; options.compression = kNoCompression; @@ -3467,7 +3467,7 @@ TEST_P(BlockBasedTableTest, BlockAlignTest) { file_writer->Flush(); test::RandomRWStringSink ss_rw(sink); - unique_ptr file_reader( + std::unique_ptr file_reader( test::GetRandomAccessFileReader( new test::StringSource(ss_rw.contents(), 73342, true))); @@ -3525,7 +3525,7 @@ TEST_P(BlockBasedTableTest, PropertiesBlockRestartPointTest) { BlockBasedTableOptions bbto = GetBlockBasedTableOptions(); bbto.block_align = true; test::StringSink* sink = new test::StringSink(); - unique_ptr file_writer( + std::unique_ptr file_writer( test::GetWritableFileWriter(sink, "" /* don't care */)); Options options; @@ -3560,7 +3560,7 @@ TEST_P(BlockBasedTableTest, PropertiesBlockRestartPointTest) { file_writer->Flush(); test::RandomRWStringSink ss_rw(sink); - unique_ptr file_reader( + std::unique_ptr file_reader( test::GetRandomAccessFileReader( new test::StringSource(ss_rw.contents(), 73342, true))); diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index f2da6580d..1430bebd2 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -1143,11 +1143,12 @@ class ReportFileOpEnv : public EnvWrapper { counters_.bytes_written_ = 0; } - Status NewSequentialFile(const std::string& f, unique_ptr* r, + Status NewSequentialFile(const std::string& f, + std::unique_ptr* r, const EnvOptions& soptions) override { class CountingFile : public SequentialFile { private: - unique_ptr target_; + std::unique_ptr target_; ReportFileOpCounters* counters_; public: @@ -1175,11 +1176,11 @@ class ReportFileOpEnv : public EnvWrapper { } Status NewRandomAccessFile(const std::string& f, - unique_ptr* r, + std::unique_ptr* r, const EnvOptions& soptions) override { class CountingFile : public RandomAccessFile { private: - unique_ptr target_; + std::unique_ptr target_; ReportFileOpCounters* counters_; public: @@ -1204,11 +1205,11 @@ class ReportFileOpEnv : public EnvWrapper { return s; } - Status NewWritableFile(const std::string& f, unique_ptr* r, + Status NewWritableFile(const std::string& f, std::unique_ptr* r, const EnvOptions& soptions) override { class CountingFile : public WritableFile { private: - unique_ptr target_; + std::unique_ptr target_; ReportFileOpCounters* counters_; public: @@ -5680,7 +5681,7 @@ void VerifyDBFromDB(std::string& truth_db_name) { void Replay(ThreadState* /*thread*/, DBWithColumnFamilies* db_with_cfh) { Status s; - unique_ptr trace_reader; + std::unique_ptr trace_reader; s = NewFileTraceReader(FLAGS_env, EnvOptions(), FLAGS_trace_file, &trace_reader); if (!s.ok()) { diff --git a/tools/db_bench_tool_test.cc b/tools/db_bench_tool_test.cc index 67426066e..dfc461193 100644 --- a/tools/db_bench_tool_test.cc +++ b/tools/db_bench_tool_test.cc @@ -279,7 +279,7 @@ const std::string options_file_content = R"OPTIONS_FILE( TEST_F(DBBenchTest, OptionsFileFromFile) { const std::string kOptionsFileName = test_path_ + "/OPTIONS_flash"; - unique_ptr writable; + std::unique_ptr writable; ASSERT_OK(Env::Default()->NewWritableFile(kOptionsFileName, &writable, EnvOptions())); ASSERT_OK(writable->Append(options_file_content)); diff --git a/tools/db_repl_stress.cc b/tools/db_repl_stress.cc index 5901b9777..c640b5945 100644 --- a/tools/db_repl_stress.cc +++ b/tools/db_repl_stress.cc @@ -67,7 +67,7 @@ struct ReplicationThread { static void ReplicationThreadBody(void* arg) { ReplicationThread* t = reinterpret_cast(arg); DB* db = t->db; - unique_ptr iter; + std::unique_ptr iter; SequenceNumber currentSeqNum = 1; while (!t->stop.load(std::memory_order_acquire)) { iter.reset(); diff --git a/tools/db_stress.cc b/tools/db_stress.cc index 341cd2f80..a05ce426f 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -940,7 +940,7 @@ class SharedState { if (status.ok()) { status = FLAGS_env->GetFileSize(FLAGS_expected_values_path, &size); } - unique_ptr wfile; + std::unique_ptr wfile; if (status.ok() && size == 0) { const EnvOptions soptions; status = FLAGS_env->NewWritableFile(FLAGS_expected_values_path, &wfile, @@ -2689,7 +2689,7 @@ class NonBatchedOpsStressTest : public StressTest { } if (!thread->rand.OneIn(2)) { // Use iterator to verify this range - unique_ptr iter( + std::unique_ptr iter( db_->NewIterator(options, column_families_[cf])); iter->Seek(Key(start)); for (auto i = start; i < end; i++) { @@ -3591,7 +3591,7 @@ class AtomicFlushStressTest : public StressTest { options.total_order_seek = true; assert(thread != nullptr); auto shared = thread->shared; - std::vector > iters(column_families_.size()); + std::vector > iters(column_families_.size()); for (size_t i = 0; i != column_families_.size(); ++i) { iters[i].reset(db_->NewIterator(options, column_families_[i])); } diff --git a/tools/ldb_cmd.cc b/tools/ldb_cmd.cc index b4c74d1b9..8ca385447 100644 --- a/tools/ldb_cmd.cc +++ b/tools/ldb_cmd.cc @@ -1964,11 +1964,11 @@ void DumpWalFile(std::string wal_file, bool print_header, bool print_values, bool is_write_committed, LDBCommandExecuteResult* exec_state) { Env* env_ = Env::Default(); EnvOptions soptions; - unique_ptr wal_file_reader; + std::unique_ptr wal_file_reader; Status status; { - unique_ptr file; + std::unique_ptr file; status = env_->NewSequentialFile(wal_file, &file, soptions); if (status.ok()) { wal_file_reader.reset( diff --git a/tools/sst_dump_test.cc b/tools/sst_dump_test.cc index beab224d1..9032123cc 100644 --- a/tools/sst_dump_test.cc +++ b/tools/sst_dump_test.cc @@ -43,7 +43,7 @@ void createSST(const std::string& file_name, std::shared_ptr tf; tf.reset(new rocksdb::BlockBasedTableFactory(table_options)); - unique_ptr file; + std::unique_ptr file; Env* env = Env::Default(); EnvOptions env_options; ReadOptions read_options; @@ -51,7 +51,7 @@ void createSST(const std::string& file_name, const ImmutableCFOptions imoptions(opts); const MutableCFOptions moptions(opts); rocksdb::InternalKeyComparator ikc(opts.comparator); - unique_ptr tb; + std::unique_ptr tb; ASSERT_OK(env->NewWritableFile(file_name, &file, env_options)); diff --git a/tools/sst_dump_tool.cc b/tools/sst_dump_tool.cc index e3341e34b..d2e823a98 100644 --- a/tools/sst_dump_tool.cc +++ b/tools/sst_dump_tool.cc @@ -83,7 +83,7 @@ Status SstFileReader::GetTableReader(const std::string& file_path) { // read table magic number Footer footer; - unique_ptr file; + std::unique_ptr file; uint64_t file_size = 0; Status s = options_.env->NewRandomAccessFile(file_path, &file, soptions_); if (s.ok()) { @@ -126,7 +126,7 @@ Status SstFileReader::GetTableReader(const std::string& file_path) { Status SstFileReader::NewTableReader( const ImmutableCFOptions& /*ioptions*/, const EnvOptions& /*soptions*/, const InternalKeyComparator& /*internal_comparator*/, uint64_t file_size, - unique_ptr* /*table_reader*/) { + std::unique_ptr* /*table_reader*/) { // We need to turn off pre-fetching of index and filter nodes for // BlockBasedTable if (BlockBasedTableFactory::kName == options_.table_factory->Name()) { @@ -148,7 +148,7 @@ Status SstFileReader::VerifyChecksum() { } Status SstFileReader::DumpTable(const std::string& out_filename) { - unique_ptr out_file; + std::unique_ptr out_file; Env* env = Env::Default(); env->NewWritableFile(out_filename, &out_file, soptions_); Status s = table_reader_->DumpTable(out_file.get(), @@ -159,21 +159,21 @@ Status SstFileReader::DumpTable(const std::string& out_filename) { uint64_t SstFileReader::CalculateCompressedTableSize( const TableBuilderOptions& tb_options, size_t block_size) { - unique_ptr out_file; - unique_ptr env(NewMemEnv(Env::Default())); + std::unique_ptr out_file; + std::unique_ptr env(NewMemEnv(Env::Default())); env->NewWritableFile(testFileName, &out_file, soptions_); - unique_ptr dest_writer; + std::unique_ptr dest_writer; dest_writer.reset( new WritableFileWriter(std::move(out_file), testFileName, soptions_)); BlockBasedTableOptions table_options; table_options.block_size = block_size; BlockBasedTableFactory block_based_tf(table_options); - unique_ptr table_builder; + std::unique_ptr table_builder; table_builder.reset(block_based_tf.NewTableBuilder( tb_options, TablePropertiesCollectorFactory::Context::kUnknownColumnFamily, dest_writer.get())); - unique_ptr iter(table_reader_->NewIterator( + std::unique_ptr iter(table_reader_->NewIterator( ReadOptions(), moptions_.prefix_extractor.get())); for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { if (!iter->status().ok()) { diff --git a/tools/sst_dump_tool_imp.h b/tools/sst_dump_tool_imp.h index ca60dd93c..a0bad085d 100644 --- a/tools/sst_dump_tool_imp.h +++ b/tools/sst_dump_tool_imp.h @@ -57,7 +57,7 @@ class SstFileReader { const EnvOptions& soptions, const InternalKeyComparator& internal_comparator, uint64_t file_size, - unique_ptr* table_reader); + std::unique_ptr* table_reader); std::string file_name_; uint64_t read_num_; @@ -70,13 +70,13 @@ class SstFileReader { Options options_; Status init_result_; - unique_ptr table_reader_; - unique_ptr file_; + std::unique_ptr table_reader_; + std::unique_ptr file_; const ImmutableCFOptions ioptions_; const MutableCFOptions moptions_; InternalKeyComparator internal_comparator_; - unique_ptr table_properties_; + std::unique_ptr table_properties_; }; } // namespace rocksdb diff --git a/util/auto_roll_logger_test.cc b/util/auto_roll_logger_test.cc index 5a6b3abc1..284a98152 100644 --- a/util/auto_roll_logger_test.cc +++ b/util/auto_roll_logger_test.cc @@ -230,7 +230,7 @@ TEST_F(AutoRollLoggerTest, CompositeRollByTimeAndSizeLogger) { TEST_F(AutoRollLoggerTest, CreateLoggerFromOptions) { DBOptions options; NoSleepEnv nse(Env::Default()); - shared_ptr logger; + std::shared_ptr logger; // Normal logger ASSERT_OK(CreateLoggerFromOptions(kTestDir, options, &logger)); @@ -273,7 +273,7 @@ TEST_F(AutoRollLoggerTest, CreateLoggerFromOptions) { TEST_F(AutoRollLoggerTest, LogFlushWhileRolling) { DBOptions options; - shared_ptr logger; + std::shared_ptr logger; InitTestDb(); options.max_log_file_size = 1024 * 5; diff --git a/util/delete_scheduler.cc b/util/delete_scheduler.cc index 1d51055a3..a8078b94a 100644 --- a/util/delete_scheduler.cc +++ b/util/delete_scheduler.cc @@ -275,7 +275,7 @@ Status DeleteScheduler::DeleteTrashFile(const std::string& path_in_trash, Status my_status = env_->NumFileLinks(path_in_trash, &num_hard_links); if (my_status.ok()) { if (num_hard_links == 1) { - unique_ptr wf; + std::unique_ptr wf; my_status = env_->ReopenWritableFile(path_in_trash, &wf, EnvOptions()); if (my_status.ok()) { diff --git a/util/fault_injection_test_env.cc b/util/fault_injection_test_env.cc index b3232093e..64e9da1aa 100644 --- a/util/fault_injection_test_env.cc +++ b/util/fault_injection_test_env.cc @@ -29,7 +29,7 @@ std::string GetDirName(const std::string filename) { // A basic file truncation function suitable for this test. Status Truncate(Env* env, const std::string& filename, uint64_t length) { - unique_ptr orig_file; + std::unique_ptr orig_file; const EnvOptions options; Status s = env->NewSequentialFile(filename, &orig_file, options); if (!s.ok()) { @@ -46,7 +46,7 @@ Status Truncate(Env* env, const std::string& filename, uint64_t length) { #endif if (s.ok()) { std::string tmp_name = GetDirName(filename) + "/truncate.tmp"; - unique_ptr tmp_file; + std::unique_ptr tmp_file; s = env->NewWritableFile(tmp_name, &tmp_file, options); if (s.ok()) { s = tmp_file->Append(result); @@ -103,7 +103,7 @@ Status TestDirectory::Fsync() { } TestWritableFile::TestWritableFile(const std::string& fname, - unique_ptr&& f, + std::unique_ptr&& f, FaultInjectionTestEnv* env) : state_(fname), target_(std::move(f)), @@ -157,8 +157,8 @@ Status TestWritableFile::Sync() { } Status FaultInjectionTestEnv::NewDirectory(const std::string& name, - unique_ptr* result) { - unique_ptr r; + std::unique_ptr* result) { + std::unique_ptr r; Status s = target()->NewDirectory(name, &r); assert(s.ok()); if (!s.ok()) { @@ -168,9 +168,9 @@ Status FaultInjectionTestEnv::NewDirectory(const std::string& name, return Status::OK(); } -Status FaultInjectionTestEnv::NewWritableFile(const std::string& fname, - unique_ptr* result, - const EnvOptions& soptions) { +Status FaultInjectionTestEnv::NewWritableFile( + const std::string& fname, std::unique_ptr* result, + const EnvOptions& soptions) { if (!IsFilesystemActive()) { return GetError(); } @@ -198,7 +198,7 @@ Status FaultInjectionTestEnv::NewWritableFile(const std::string& fname, } Status FaultInjectionTestEnv::ReopenWritableFile( - const std::string& fname, unique_ptr* result, + const std::string& fname, std::unique_ptr* result, const EnvOptions& soptions) { if (!IsFilesystemActive()) { return GetError(); diff --git a/util/fault_injection_test_env.h b/util/fault_injection_test_env.h index d88a49155..d3775d3a3 100644 --- a/util/fault_injection_test_env.h +++ b/util/fault_injection_test_env.h @@ -56,7 +56,7 @@ struct FileState { class TestWritableFile : public WritableFile { public: explicit TestWritableFile(const std::string& fname, - unique_ptr&& f, + std::unique_ptr&& f, FaultInjectionTestEnv* env); virtual ~TestWritableFile(); virtual Status Append(const Slice& data) override; @@ -77,7 +77,7 @@ class TestWritableFile : public WritableFile { private: FileState state_; - unique_ptr target_; + std::unique_ptr target_; bool writable_file_opened_; FaultInjectionTestEnv* env_; }; @@ -94,7 +94,7 @@ class TestDirectory : public Directory { private: FaultInjectionTestEnv* env_; std::string dirname_; - unique_ptr dir_; + std::unique_ptr dir_; }; class FaultInjectionTestEnv : public EnvWrapper { @@ -104,14 +104,14 @@ class FaultInjectionTestEnv : public EnvWrapper { virtual ~FaultInjectionTestEnv() {} Status NewDirectory(const std::string& name, - unique_ptr* result) override; + std::unique_ptr* result) override; Status NewWritableFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& soptions) override; Status ReopenWritableFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& soptions) override; Status NewRandomAccessFile(const std::string& fname, diff --git a/util/file_reader_writer.cc b/util/file_reader_writer.cc index 4810a318d..821d657b0 100644 --- a/util/file_reader_writer.cc +++ b/util/file_reader_writer.cc @@ -802,7 +802,7 @@ std::unique_ptr NewReadaheadRandomAccessFile( } Status NewWritableFile(Env* env, const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) { Status s = env->NewWritableFile(fname, result, options); TEST_KILL_RANDOM("NewWritableFile:0", rocksdb_kill_odds * REDUCE_ODDS2); diff --git a/util/file_reader_writer.h b/util/file_reader_writer.h index f6b0c7bcb..ec7acebcc 100644 --- a/util/file_reader_writer.h +++ b/util/file_reader_writer.h @@ -319,7 +319,7 @@ class FilePrefetchBuffer { }; extern Status NewWritableFile(Env* env, const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options); bool ReadOneLine(std::istringstream* iss, SequentialFile* seq_file, std::string* output, bool* has_data, Status* result); diff --git a/util/file_reader_writer_test.cc b/util/file_reader_writer_test.cc index 3ca44ecc0..72dd625c1 100644 --- a/util/file_reader_writer_test.cc +++ b/util/file_reader_writer_test.cc @@ -71,8 +71,8 @@ TEST_F(WritableFileWriterTest, RangeSync) { EnvOptions env_options; env_options.bytes_per_sync = kMb; - unique_ptr wf(new FakeWF); - unique_ptr writer( + std::unique_ptr wf(new FakeWF); + std::unique_ptr writer( new WritableFileWriter(std::move(wf), "" /* don't care */, env_options)); Random r(301); std::unique_ptr large_buf(new char[10 * kMb]); @@ -147,14 +147,14 @@ TEST_F(WritableFileWriterTest, IncrementalBuffer) { env_options.writable_file_max_buffer_size = (attempt < kNumAttempts / 2) ? 512 * 1024 : 700 * 1024; std::string actual; - unique_ptr wf(new FakeWF(&actual, + std::unique_ptr wf(new FakeWF(&actual, #ifndef ROCKSDB_LITE - attempt % 2 == 1, + attempt % 2 == 1, #else - false, + false, #endif - no_flush)); - unique_ptr writer(new WritableFileWriter( + no_flush)); + std::unique_ptr writer(new WritableFileWriter( std::move(wf), "" /* don't care */, env_options)); std::string target; @@ -206,9 +206,9 @@ TEST_F(WritableFileWriterTest, AppendStatusReturn) { bool use_direct_io_; bool io_error_; }; - unique_ptr wf(new FakeWF()); + std::unique_ptr wf(new FakeWF()); wf->Setuse_direct_io(true); - unique_ptr writer( + std::unique_ptr writer( new WritableFileWriter(std::move(wf), "" /* don't care */, EnvOptions())); ASSERT_OK(writer->Append(std::string(2 * kMb, 'a'))); diff --git a/util/file_util.cc b/util/file_util.cc index aa2994b1e..bf56592ef 100644 --- a/util/file_util.cc +++ b/util/file_util.cc @@ -19,16 +19,16 @@ Status CopyFile(Env* env, const std::string& source, const std::string& destination, uint64_t size, bool use_fsync) { const EnvOptions soptions; Status s; - unique_ptr src_reader; - unique_ptr dest_writer; + std::unique_ptr src_reader; + std::unique_ptr dest_writer; { - unique_ptr srcfile; + std::unique_ptr srcfile; s = env->NewSequentialFile(source, &srcfile, soptions); if (!s.ok()) { return s; } - unique_ptr destfile; + std::unique_ptr destfile; s = env->NewWritableFile(destination, &destfile, soptions); if (!s.ok()) { return s; @@ -71,9 +71,9 @@ Status CreateFile(Env* env, const std::string& destination, const std::string& contents, bool use_fsync) { const EnvOptions soptions; Status s; - unique_ptr dest_writer; + std::unique_ptr dest_writer; - unique_ptr destfile; + std::unique_ptr destfile; s = env->NewWritableFile(destination, &destfile, soptions); if (!s.ok()) { return s; diff --git a/util/log_write_bench.cc b/util/log_write_bench.cc index b4e12b948..5c9b3e84b 100644 --- a/util/log_write_bench.cc +++ b/util/log_write_bench.cc @@ -35,9 +35,9 @@ void RunBenchmark() { Env* env = Env::Default(); EnvOptions env_options = env->OptimizeForLogWrite(EnvOptions()); env_options.bytes_per_sync = FLAGS_bytes_per_sync; - unique_ptr file; + std::unique_ptr file; env->NewWritableFile(file_name, &file, env_options); - unique_ptr writer; + std::unique_ptr writer; writer.reset(new WritableFileWriter(std::move(file), env_options)); std::string record; diff --git a/util/slice_transform_test.cc b/util/slice_transform_test.cc index ddbb9f4bf..2eb56af6d 100644 --- a/util/slice_transform_test.cc +++ b/util/slice_transform_test.cc @@ -24,7 +24,7 @@ TEST_F(SliceTransformTest, CapPrefixTransform) { std::string s; s = "abcdefge"; - unique_ptr transform; + std::unique_ptr transform; transform.reset(NewCappedPrefixTransform(6)); ASSERT_EQ(transform->Transform(s).ToString(), "abcdef"); @@ -115,7 +115,7 @@ TEST_F(SliceTransformDBTest, CapPrefix) { ASSERT_OK(db()->Put(wo, "foo3", "bar3")); ASSERT_OK(db()->Flush(fo)); - unique_ptr iter(db()->NewIterator(ro)); + std::unique_ptr iter(db()->NewIterator(ro)); iter->Seek("foo"); ASSERT_OK(iter->status()); diff --git a/util/testutil.cc b/util/testutil.cc index 0983f759c..b1a79fe93 100644 --- a/util/testutil.cc +++ b/util/testutil.cc @@ -126,19 +126,19 @@ const Comparator* Uint64Comparator() { WritableFileWriter* GetWritableFileWriter(WritableFile* wf, const std::string& fname) { - unique_ptr file(wf); + std::unique_ptr file(wf); return new WritableFileWriter(std::move(file), fname, EnvOptions()); } RandomAccessFileReader* GetRandomAccessFileReader(RandomAccessFile* raf) { - unique_ptr file(raf); + std::unique_ptr file(raf); return new RandomAccessFileReader(std::move(file), "[test RandomAccessFileReader]"); } SequentialFileReader* GetSequentialFileReader(SequentialFile* se, const std::string& fname) { - unique_ptr file(se); + std::unique_ptr file(se); return new SequentialFileReader(std::move(file), fname); } diff --git a/util/testutil.h b/util/testutil.h index c16c0cbe5..c8c7d60d2 100644 --- a/util/testutil.h +++ b/util/testutil.h @@ -64,7 +64,7 @@ class ErrorEnv : public EnvWrapper { num_writable_file_errors_(0) { } virtual Status NewWritableFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& soptions) override { result->reset(); if (writable_file_error_) { @@ -554,7 +554,7 @@ class StringEnv : public EnvWrapper { const Status WriteToNewFile(const std::string& file_name, const std::string& content) { - unique_ptr r; + std::unique_ptr r; auto s = NewWritableFile(file_name, &r, EnvOptions()); if (!s.ok()) { return s; @@ -567,7 +567,8 @@ class StringEnv : public EnvWrapper { } // The following text is boilerplate that forwards all methods to target() - Status NewSequentialFile(const std::string& f, unique_ptr* r, + Status NewSequentialFile(const std::string& f, + std::unique_ptr* r, const EnvOptions& /*options*/) override { auto iter = files_.find(f); if (iter == files_.end()) { @@ -577,11 +578,11 @@ class StringEnv : public EnvWrapper { return Status::OK(); } Status NewRandomAccessFile(const std::string& /*f*/, - unique_ptr* /*r*/, + std::unique_ptr* /*r*/, const EnvOptions& /*options*/) override { return Status::NotSupported(); } - Status NewWritableFile(const std::string& f, unique_ptr* r, + Status NewWritableFile(const std::string& f, std::unique_ptr* r, const EnvOptions& /*options*/) override { auto iter = files_.find(f); if (iter != files_.end()) { @@ -591,7 +592,7 @@ class StringEnv : public EnvWrapper { return Status::OK(); } virtual Status NewDirectory(const std::string& /*name*/, - unique_ptr* /*result*/) override { + std::unique_ptr* /*result*/) override { return Status::NotSupported(); } Status FileExists(const std::string& f) override { diff --git a/util/trace_replay.cc b/util/trace_replay.cc index cd2e3ee95..bebce24ce 100644 --- a/util/trace_replay.cc +++ b/util/trace_replay.cc @@ -103,7 +103,7 @@ Status Tracer::WriteTrace(const Trace& trace) { Status Tracer::Close() { return WriteFooter(); } Replayer::Replayer(DB* db, const std::vector& handles, - unique_ptr&& reader) + std::unique_ptr&& reader) : trace_reader_(std::move(reader)) { assert(db != nullptr); db_ = static_cast(db->GetRootDB()); diff --git a/util/trace_replay.h b/util/trace_replay.h index b324696f0..1436d4470 100644 --- a/util/trace_replay.h +++ b/util/trace_replay.h @@ -71,7 +71,7 @@ class Tracer { Status WriteTrace(const Trace& trace); Env* env_; - unique_ptr trace_writer_; + std::unique_ptr trace_writer_; }; // Replay RocksDB operations from a trace. diff --git a/utilities/backupable/backupable_db.cc b/utilities/backupable/backupable_db.cc index 4cafc6ab1..e51b724c9 100644 --- a/utilities/backupable/backupable_db.cc +++ b/utilities/backupable/backupable_db.cc @@ -479,9 +479,9 @@ class BackupEngineImpl : public BackupEngine { // backup state data BackupID latest_backup_id_; BackupID latest_valid_backup_id_; - std::map> backups_; - std::map>> corrupt_backups_; + std::map> backups_; + std::map>> + corrupt_backups_; std::unordered_map> backuped_file_infos_; std::atomic stop_backup_; @@ -492,10 +492,10 @@ class BackupEngineImpl : public BackupEngine { Env* backup_env_; // directories - unique_ptr backup_directory_; - unique_ptr shared_directory_; - unique_ptr meta_directory_; - unique_ptr private_directory_; + std::unique_ptr backup_directory_; + std::unique_ptr shared_directory_; + std::unique_ptr meta_directory_; + std::unique_ptr private_directory_; static const size_t kDefaultCopyFileBufferSize = 5 * 1024 * 1024LL; // 5MB size_t copy_file_buffer_size_; @@ -616,7 +616,7 @@ Status BackupEngineImpl::Initialize() { } assert(backups_.find(backup_id) == backups_.end()); backups_.insert(std::make_pair( - backup_id, unique_ptr(new BackupMeta( + backup_id, std::unique_ptr(new BackupMeta( GetBackupMetaFile(backup_id, false /* tmp */), GetBackupMetaFile(backup_id, true /* tmp */), &backuped_file_infos_, backup_env_)))); @@ -761,7 +761,7 @@ Status BackupEngineImpl::CreateNewBackupWithMetadata( } auto ret = backups_.insert(std::make_pair( - new_backup_id, unique_ptr(new BackupMeta( + new_backup_id, std::unique_ptr(new BackupMeta( GetBackupMetaFile(new_backup_id, false /* tmp */), GetBackupMetaFile(new_backup_id, true /* tmp */), &backuped_file_infos_, backup_env_)))); @@ -869,7 +869,7 @@ Status BackupEngineImpl::CreateNewBackupWithMetadata( s = new_backup->StoreToFile(options_.sync); } if (s.ok() && options_.sync) { - unique_ptr backup_private_directory; + std::unique_ptr backup_private_directory; backup_env_->NewDirectory( GetAbsolutePath(GetPrivateFileRel(new_backup_id, false)), &backup_private_directory); @@ -1188,8 +1188,8 @@ Status BackupEngineImpl::CopyOrCreateFile( std::function progress_callback) { assert(src.empty() != contents.empty()); Status s; - unique_ptr dst_file; - unique_ptr src_file; + std::unique_ptr dst_file; + std::unique_ptr src_file; EnvOptions env_options; env_options.use_mmap_writes = false; // TODO:(gzh) maybe use direct reads/writes here if possible @@ -1213,10 +1213,10 @@ Status BackupEngineImpl::CopyOrCreateFile( return s; } - unique_ptr dest_writer( + std::unique_ptr dest_writer( new WritableFileWriter(std::move(dst_file), dst, env_options)); - unique_ptr src_reader; - unique_ptr buf; + std::unique_ptr src_reader; + std::unique_ptr buf; if (!src.empty()) { src_reader.reset(new SequentialFileReader(std::move(src_file), src)); buf.reset(new char[copy_file_buffer_size_]); @@ -1416,7 +1416,7 @@ Status BackupEngineImpl::CalculateChecksum(const std::string& src, Env* src_env, return s; } - unique_ptr src_reader( + std::unique_ptr src_reader( new SequentialFileReader(std::move(src_file), src)); std::unique_ptr buf(new char[copy_file_buffer_size_]); Slice data; @@ -1634,15 +1634,15 @@ Status BackupEngineImpl::BackupMeta::LoadFromFile( const std::unordered_map& abs_path_to_size) { assert(Empty()); Status s; - unique_ptr backup_meta_file; + std::unique_ptr backup_meta_file; s = env_->NewSequentialFile(meta_filename_, &backup_meta_file, EnvOptions()); if (!s.ok()) { return s; } - unique_ptr backup_meta_reader( + std::unique_ptr backup_meta_reader( new SequentialFileReader(std::move(backup_meta_file), meta_filename_)); - unique_ptr buf(new char[max_backup_meta_file_size_ + 1]); + std::unique_ptr buf(new char[max_backup_meta_file_size_ + 1]); Slice data; s = backup_meta_reader->Read(max_backup_meta_file_size_, &data, buf.get()); @@ -1736,7 +1736,7 @@ Status BackupEngineImpl::BackupMeta::LoadFromFile( Status BackupEngineImpl::BackupMeta::StoreToFile(bool sync) { Status s; - unique_ptr backup_meta_file; + std::unique_ptr backup_meta_file; EnvOptions env_options; env_options.use_mmap_writes = false; env_options.use_direct_writes = false; @@ -1745,7 +1745,7 @@ Status BackupEngineImpl::BackupMeta::StoreToFile(bool sync) { return s; } - unique_ptr buf(new char[max_backup_meta_file_size_]); + std::unique_ptr buf(new char[max_backup_meta_file_size_]); size_t len = 0, buf_size = max_backup_meta_file_size_; len += snprintf(buf.get(), buf_size, "%" PRId64 "\n", timestamp_); len += snprintf(buf.get() + len, buf_size - len, "%" PRIu64 "\n", @@ -1762,7 +1762,8 @@ Status BackupEngineImpl::BackupMeta::StoreToFile(bool sync) { else if (len + hex_meta_strlen >= buf_size) { backup_meta_file->Append(Slice(buf.get(), len)); buf.reset(); - unique_ptr new_reset_buf(new char[max_backup_meta_file_size_]); + std::unique_ptr new_reset_buf( + new char[max_backup_meta_file_size_]); buf.swap(new_reset_buf); len = 0; } @@ -1776,7 +1777,7 @@ Status BackupEngineImpl::BackupMeta::StoreToFile(bool sync) { "%" ROCKSDB_PRIszt "\n", files_.size()) >= buf_size) { backup_meta_file->Append(Slice(buf.get(), len)); buf.reset(); - unique_ptr new_reset_buf(new char[max_backup_meta_file_size_]); + std::unique_ptr new_reset_buf(new char[max_backup_meta_file_size_]); buf.swap(new_reset_buf); len = 0; } @@ -1794,7 +1795,8 @@ Status BackupEngineImpl::BackupMeta::StoreToFile(bool sync) { if (newlen >= buf_size) { backup_meta_file->Append(Slice(buf.get(), len)); buf.reset(); - unique_ptr new_reset_buf(new char[max_backup_meta_file_size_]); + std::unique_ptr new_reset_buf( + new char[max_backup_meta_file_size_]); buf.swap(new_reset_buf); len = 0; } diff --git a/utilities/backupable/backupable_db_test.cc b/utilities/backupable/backupable_db_test.cc index 9fdc058fd..15098570b 100644 --- a/utilities/backupable/backupable_db_test.cc +++ b/utilities/backupable/backupable_db_test.cc @@ -179,7 +179,8 @@ class TestEnv : public EnvWrapper { bool fail_reads_; }; - Status NewSequentialFile(const std::string& f, unique_ptr* r, + Status NewSequentialFile(const std::string& f, + std::unique_ptr* r, const EnvOptions& options) override { MutexLock l(&mutex_); if (dummy_sequential_file_) { @@ -191,7 +192,7 @@ class TestEnv : public EnvWrapper { } } - Status NewWritableFile(const std::string& f, unique_ptr* r, + Status NewWritableFile(const std::string& f, std::unique_ptr* r, const EnvOptions& options) override { MutexLock l(&mutex_); written_files_.push_back(f); @@ -308,7 +309,7 @@ class TestEnv : public EnvWrapper { void SetNewDirectoryFailure(bool fail) { new_directory_failure_ = fail; } virtual Status NewDirectory(const std::string& name, - unique_ptr* result) override { + std::unique_ptr* result) override { if (new_directory_failure_) { return Status::IOError("SimulatedFailure"); } @@ -427,7 +428,7 @@ class FileManager : public EnvWrapper { } Status WriteToFile(const std::string& fname, const std::string& data) { - unique_ptr file; + std::unique_ptr file; EnvOptions env_options; env_options.use_mmap_writes = false; Status s = EnvWrapper::NewWritableFile(fname, &file, env_options); @@ -620,22 +621,22 @@ class BackupableDBTest : public testing::Test { std::shared_ptr logger_; // envs - unique_ptr db_chroot_env_; - unique_ptr backup_chroot_env_; - unique_ptr test_db_env_; - unique_ptr test_backup_env_; - unique_ptr file_manager_; + std::unique_ptr db_chroot_env_; + std::unique_ptr backup_chroot_env_; + std::unique_ptr test_db_env_; + std::unique_ptr test_backup_env_; + std::unique_ptr file_manager_; // all the dbs! DummyDB* dummy_db_; // BackupableDB owns dummy_db_ - unique_ptr db_; - unique_ptr backup_engine_; + std::unique_ptr db_; + std::unique_ptr backup_engine_; // options Options options_; protected: - unique_ptr backupable_options_; + std::unique_ptr backupable_options_; }; // BackupableDBTest void AppendPath(const std::string& path, std::vector& v) { diff --git a/utilities/blob_db/blob_db_impl.h b/utilities/blob_db/blob_db_impl.h index 4809f006e..8d5148def 100644 --- a/utilities/blob_db/blob_db_impl.h +++ b/utilities/blob_db/blob_db_impl.h @@ -348,7 +348,8 @@ class BlobDBImpl : public BlobDB { ColumnFamilyOptions cf_options_; EnvOptions env_options_; - // Raw pointer of statistic. db_options_ has a shared_ptr to hold ownership. + // Raw pointer of statistic. db_options_ has a std::shared_ptr to hold + // ownership. Statistics* statistics_; // by default this is "blob_dir" under dbname_ diff --git a/utilities/cassandra/cassandra_functional_test.cc b/utilities/cassandra/cassandra_functional_test.cc index 3e612b3ad..653e6da72 100644 --- a/utilities/cassandra/cassandra_functional_test.cc +++ b/utilities/cassandra/cassandra_functional_test.cc @@ -101,7 +101,7 @@ public: virtual std::unique_ptr CreateCompactionFilter( const CompactionFilter::Context& /*context*/) override { - return unique_ptr(new CassandraCompactionFilter( + return std::unique_ptr(new CassandraCompactionFilter( purge_ttl_on_expiration_, gc_grace_period_in_seconds_)); } diff --git a/utilities/cassandra/format.cc b/utilities/cassandra/format.cc index 4a22658de..42cd7206b 100644 --- a/utilities/cassandra/format.cc +++ b/utilities/cassandra/format.cc @@ -266,7 +266,7 @@ RowValue RowValue::ConvertExpiredColumnsToTombstones(bool* changed) const { std::static_pointer_cast(column); if(expiring_column->Expired()) { - shared_ptr tombstone = expiring_column->ToTombstone(); + std::shared_ptr tombstone = expiring_column->ToTombstone(); new_columns.push_back(tombstone); *changed = true; continue; diff --git a/utilities/checkpoint/checkpoint_impl.cc b/utilities/checkpoint/checkpoint_impl.cc index 48f9200fb..9863ac1d5 100644 --- a/utilities/checkpoint/checkpoint_impl.cc +++ b/utilities/checkpoint/checkpoint_impl.cc @@ -133,7 +133,7 @@ Status CheckpointImpl::CreateCheckpoint(const std::string& checkpoint_dir, s = db_->GetEnv()->RenameFile(full_private_path, checkpoint_dir); } if (s.ok()) { - unique_ptr checkpoint_directory; + std::unique_ptr checkpoint_directory; db_->GetEnv()->NewDirectory(checkpoint_dir, &checkpoint_directory); if (checkpoint_directory != nullptr) { s = checkpoint_directory->Fsync(); diff --git a/utilities/column_aware_encoding_exp.cc b/utilities/column_aware_encoding_exp.cc index 988a59b3c..c251c985e 100644 --- a/utilities/column_aware_encoding_exp.cc +++ b/utilities/column_aware_encoding_exp.cc @@ -88,7 +88,7 @@ class ColumnAwareEncodingExp { EnvOptions env_options; if (CompressionTypeSupported(compression_type)) { fprintf(stdout, "[%s]\n", FLAGS_compression_type.c_str()); - unique_ptr encoded_out_file; + std::unique_ptr encoded_out_file; std::unique_ptr env(NewMemEnv(Env::Default())); if (!FLAGS_encoded_file.empty()) { @@ -116,7 +116,7 @@ class ColumnAwareEncodingExp { uint64_t encode_time = sw.ElapsedNanosSafe(false /* reset */); fprintf(stdout, "Encode time: %" PRIu64 "\n", encode_time); if (decode) { - unique_ptr decoded_out_file; + std::unique_ptr decoded_out_file; if (!FLAGS_decoded_file.empty()) { env->NewWritableFile(FLAGS_decoded_file, &decoded_out_file, env_options); diff --git a/utilities/date_tiered/date_tiered_test.cc b/utilities/date_tiered/date_tiered_test.cc index c81d95402..35f15584e 100644 --- a/utilities/date_tiered/date_tiered_test.cc +++ b/utilities/date_tiered/date_tiered_test.cc @@ -132,7 +132,7 @@ class DateTieredTest : public testing::Test { Options options_; KVMap::iterator kv_it_; const std::string kNewValue_ = "new_value"; - unique_ptr test_comp_filter_; + std::unique_ptr test_comp_filter_; }; // Puts a set of values and checks its presence using Get during ttl diff --git a/utilities/document/json_document_test.cc b/utilities/document/json_document_test.cc index 977905b91..9d79c41cf 100644 --- a/utilities/document/json_document_test.cc +++ b/utilities/document/json_document_test.cc @@ -249,21 +249,23 @@ TEST_F(JSONDocumentTest, OperatorEqualsTest) { ASSERT_TRUE(JSONDocument(static_cast(15)) == JSONDocument(static_cast(15))); - unique_ptr arrayWithInt8Doc(JSONDocument::ParseJSON("[8]")); + std::unique_ptr arrayWithInt8Doc( + JSONDocument::ParseJSON("[8]")); ASSERT_TRUE(arrayWithInt8Doc != nullptr); ASSERT_TRUE(arrayWithInt8Doc->IsArray()); ASSERT_TRUE((*arrayWithInt8Doc)[0].IsInt64()); ASSERT_TRUE((*arrayWithInt8Doc)[0] == JSONDocument(static_cast(8))); - unique_ptr arrayWithInt16Doc(JSONDocument::ParseJSON("[512]")); + std::unique_ptr arrayWithInt16Doc( + JSONDocument::ParseJSON("[512]")); ASSERT_TRUE(arrayWithInt16Doc != nullptr); ASSERT_TRUE(arrayWithInt16Doc->IsArray()); ASSERT_TRUE((*arrayWithInt16Doc)[0].IsInt64()); ASSERT_TRUE((*arrayWithInt16Doc)[0] == JSONDocument(static_cast(512))); - unique_ptr arrayWithInt32Doc( - JSONDocument::ParseJSON("[1000000]")); + std::unique_ptr arrayWithInt32Doc( + JSONDocument::ParseJSON("[1000000]")); ASSERT_TRUE(arrayWithInt32Doc != nullptr); ASSERT_TRUE(arrayWithInt32Doc->IsArray()); ASSERT_TRUE((*arrayWithInt32Doc)[0].IsInt64()); @@ -277,8 +279,8 @@ TEST_F(JSONDocumentTest, OperatorEqualsTest) { } TEST_F(JSONDocumentTest, JSONDocumentBuilderTest) { - unique_ptr parsedArray( - JSONDocument::ParseJSON("[1, [123, \"a\", \"b\"], {\"b\":\"c\"}]")); + std::unique_ptr parsedArray( + JSONDocument::ParseJSON("[1, [123, \"a\", \"b\"], {\"b\":\"c\"}]")); ASSERT_TRUE(parsedArray != nullptr); JSONDocumentBuilder builder; diff --git a/utilities/env_librados_test.cc b/utilities/env_librados_test.cc index 7d9b252ea..fb10224e7 100644 --- a/utilities/env_librados_test.cc +++ b/utilities/env_librados_test.cc @@ -108,7 +108,7 @@ public: TEST_F(EnvLibradosTest, Basics) { uint64_t file_size; - unique_ptr writable_file; + std::unique_ptr writable_file; std::vector children; ASSERT_OK(env_->CreateDir("/dir")); @@ -150,8 +150,8 @@ TEST_F(EnvLibradosTest, Basics) { ASSERT_EQ(3U, file_size); // Check that opening non-existent file fails. - unique_ptr seq_file; - unique_ptr rand_file; + std::unique_ptr seq_file; + std::unique_ptr rand_file; ASSERT_TRUE( !env_->NewSequentialFile("/dir/non_existent", &seq_file, soptions_).ok()); ASSERT_TRUE(!seq_file); @@ -169,9 +169,9 @@ TEST_F(EnvLibradosTest, Basics) { } TEST_F(EnvLibradosTest, ReadWrite) { - unique_ptr writable_file; - unique_ptr seq_file; - unique_ptr rand_file; + std::unique_ptr writable_file; + std::unique_ptr seq_file; + std::unique_ptr rand_file; Slice result; char scratch[100]; @@ -210,7 +210,7 @@ TEST_F(EnvLibradosTest, ReadWrite) { TEST_F(EnvLibradosTest, Locks) { FileLock* lock = nullptr; - unique_ptr writable_file; + std::unique_ptr writable_file; ASSERT_OK(env_->CreateDir("/dir")); @@ -229,7 +229,7 @@ TEST_F(EnvLibradosTest, Misc) { ASSERT_OK(env_->GetTestDirectory(&test_dir)); ASSERT_TRUE(!test_dir.empty()); - unique_ptr writable_file; + std::unique_ptr writable_file; ASSERT_TRUE(!env_->NewWritableFile("/a/b", &writable_file, soptions_).ok()); ASSERT_OK(env_->NewWritableFile("/a", &writable_file, soptions_)); @@ -249,14 +249,14 @@ TEST_F(EnvLibradosTest, LargeWrite) { write_data.append(1, 'h'); } - unique_ptr writable_file; + std::unique_ptr writable_file; ASSERT_OK(env_->CreateDir("/dir")); ASSERT_OK(env_->NewWritableFile("/dir/g", &writable_file, soptions_)); ASSERT_OK(writable_file->Append("foo")); ASSERT_OK(writable_file->Append(write_data)); writable_file.reset(); - unique_ptr seq_file; + std::unique_ptr seq_file; Slice result; ASSERT_OK(env_->NewSequentialFile("/dir/g", &seq_file, soptions_)); ASSERT_OK(seq_file->Read(3, &result, scratch)); // Read "foo". @@ -282,7 +282,7 @@ TEST_F(EnvLibradosTest, FrequentlySmallWrite) { write_data.append(1, 'h'); } - unique_ptr writable_file; + std::unique_ptr writable_file; ASSERT_OK(env_->CreateDir("/dir")); ASSERT_OK(env_->NewWritableFile("/dir/g", &writable_file, soptions_)); ASSERT_OK(writable_file->Append("foo")); @@ -292,7 +292,7 @@ TEST_F(EnvLibradosTest, FrequentlySmallWrite) { } writable_file.reset(); - unique_ptr seq_file; + std::unique_ptr seq_file; Slice result; ASSERT_OK(env_->NewSequentialFile("/dir/g", &seq_file, soptions_)); ASSERT_OK(seq_file->Read(3, &result, scratch)); // Read "foo". @@ -317,7 +317,7 @@ TEST_F(EnvLibradosTest, Truncate) { write_data.append(1, 'h'); } - unique_ptr writable_file; + std::unique_ptr writable_file; ASSERT_OK(env_->CreateDir("/dir")); ASSERT_OK(env_->NewWritableFile("/dir/g", &writable_file, soptions_)); ASSERT_OK(writable_file->Append(write_data)); @@ -801,7 +801,7 @@ public: TEST_F(EnvLibradosMutipoolTest, Basics) { uint64_t file_size; - unique_ptr writable_file; + std::unique_ptr writable_file; std::vector children; std::vector v = {"/tmp/dir1", "/tmp/dir2", "/tmp/dir3", "/tmp/dir4", "dir"}; @@ -850,8 +850,8 @@ TEST_F(EnvLibradosMutipoolTest, Basics) { ASSERT_EQ(3U, file_size); // Check that opening non-existent file fails. - unique_ptr seq_file; - unique_ptr rand_file; + std::unique_ptr seq_file; + std::unique_ptr rand_file; ASSERT_TRUE( !env_->NewSequentialFile(dir_non_existent.c_str(), &seq_file, soptions_).ok()); ASSERT_TRUE(!seq_file); diff --git a/utilities/env_mirror.cc b/utilities/env_mirror.cc index d14de97d0..327d8e162 100644 --- a/utilities/env_mirror.cc +++ b/utilities/env_mirror.cc @@ -16,7 +16,7 @@ namespace rocksdb { // Env's. This is useful for debugging purposes. class SequentialFileMirror : public SequentialFile { public: - unique_ptr a_, b_; + std::unique_ptr a_, b_; std::string fname; explicit SequentialFileMirror(std::string f) : fname(f) {} @@ -60,7 +60,7 @@ class SequentialFileMirror : public SequentialFile { class RandomAccessFileMirror : public RandomAccessFile { public: - unique_ptr a_, b_; + std::unique_ptr a_, b_; std::string fname; explicit RandomAccessFileMirror(std::string f) : fname(f) {} @@ -95,7 +95,7 @@ class RandomAccessFileMirror : public RandomAccessFile { class WritableFileMirror : public WritableFile { public: - unique_ptr a_, b_; + std::unique_ptr a_, b_; std::string fname; explicit WritableFileMirror(std::string f) : fname(f) {} @@ -191,7 +191,7 @@ class WritableFileMirror : public WritableFile { }; Status EnvMirror::NewSequentialFile(const std::string& f, - unique_ptr* r, + std::unique_ptr* r, const EnvOptions& options) { if (f.find("/proc/") == 0) { return a_->NewSequentialFile(f, r, options); @@ -208,7 +208,7 @@ Status EnvMirror::NewSequentialFile(const std::string& f, } Status EnvMirror::NewRandomAccessFile(const std::string& f, - unique_ptr* r, + std::unique_ptr* r, const EnvOptions& options) { if (f.find("/proc/") == 0) { return a_->NewRandomAccessFile(f, r, options); @@ -225,7 +225,7 @@ Status EnvMirror::NewRandomAccessFile(const std::string& f, } Status EnvMirror::NewWritableFile(const std::string& f, - unique_ptr* r, + std::unique_ptr* r, const EnvOptions& options) { if (f.find("/proc/") == 0) return a_->NewWritableFile(f, r, options); WritableFileMirror* mf = new WritableFileMirror(f); @@ -241,7 +241,7 @@ Status EnvMirror::NewWritableFile(const std::string& f, Status EnvMirror::ReuseWritableFile(const std::string& fname, const std::string& old_fname, - unique_ptr* r, + std::unique_ptr* r, const EnvOptions& options) { if (fname.find("/proc/") == 0) return a_->ReuseWritableFile(fname, old_fname, r, options); diff --git a/utilities/env_mirror_test.cc b/utilities/env_mirror_test.cc index 2bf8ec858..812595ca1 100644 --- a/utilities/env_mirror_test.cc +++ b/utilities/env_mirror_test.cc @@ -32,7 +32,7 @@ class EnvMirrorTest : public testing::Test { TEST_F(EnvMirrorTest, Basics) { uint64_t file_size; - unique_ptr writable_file; + std::unique_ptr writable_file; std::vector children; ASSERT_OK(env_->CreateDir("/dir")); @@ -91,8 +91,8 @@ TEST_F(EnvMirrorTest, Basics) { ASSERT_EQ(3U, file_size); // Check that opening non-existent file fails. - unique_ptr seq_file; - unique_ptr rand_file; + std::unique_ptr seq_file; + std::unique_ptr rand_file; ASSERT_TRUE( !env_->NewSequentialFile("/dir/non_existent", &seq_file, soptions_).ok()); ASSERT_TRUE(!seq_file); @@ -110,9 +110,9 @@ TEST_F(EnvMirrorTest, Basics) { } TEST_F(EnvMirrorTest, ReadWrite) { - unique_ptr writable_file; - unique_ptr seq_file; - unique_ptr rand_file; + std::unique_ptr writable_file; + std::unique_ptr seq_file; + std::unique_ptr rand_file; Slice result; char scratch[100]; @@ -162,7 +162,7 @@ TEST_F(EnvMirrorTest, Misc) { ASSERT_OK(env_->GetTestDirectory(&test_dir)); ASSERT_TRUE(!test_dir.empty()); - unique_ptr writable_file; + std::unique_ptr writable_file; ASSERT_OK(env_->NewWritableFile("/a/b", &writable_file, soptions_)); // These are no-ops, but we test they return success. @@ -181,13 +181,13 @@ TEST_F(EnvMirrorTest, LargeWrite) { write_data.append(1, static_cast(i)); } - unique_ptr writable_file; + std::unique_ptr writable_file; ASSERT_OK(env_->NewWritableFile("/dir/f", &writable_file, soptions_)); ASSERT_OK(writable_file->Append("foo")); ASSERT_OK(writable_file->Append(write_data)); writable_file.reset(); - unique_ptr seq_file; + std::unique_ptr seq_file; Slice result; ASSERT_OK(env_->NewSequentialFile("/dir/f", &seq_file, soptions_)); ASSERT_OK(seq_file->Read(3, &result, scratch)); // Read "foo". diff --git a/utilities/env_timed.cc b/utilities/env_timed.cc index 6afd45bf9..86455ee65 100644 --- a/utilities/env_timed.cc +++ b/utilities/env_timed.cc @@ -18,21 +18,21 @@ class TimedEnv : public EnvWrapper { explicit TimedEnv(Env* base_env) : EnvWrapper(base_env) {} virtual Status NewSequentialFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { PERF_TIMER_GUARD(env_new_sequential_file_nanos); return EnvWrapper::NewSequentialFile(fname, result, options); } virtual Status NewRandomAccessFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { PERF_TIMER_GUARD(env_new_random_access_file_nanos); return EnvWrapper::NewRandomAccessFile(fname, result, options); } virtual Status NewWritableFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { PERF_TIMER_GUARD(env_new_writable_file_nanos); return EnvWrapper::NewWritableFile(fname, result, options); @@ -40,21 +40,21 @@ class TimedEnv : public EnvWrapper { virtual Status ReuseWritableFile(const std::string& fname, const std::string& old_fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { PERF_TIMER_GUARD(env_reuse_writable_file_nanos); return EnvWrapper::ReuseWritableFile(fname, old_fname, result, options); } virtual Status NewRandomRWFile(const std::string& fname, - unique_ptr* result, + std::unique_ptr* result, const EnvOptions& options) override { PERF_TIMER_GUARD(env_new_random_rw_file_nanos); return EnvWrapper::NewRandomRWFile(fname, result, options); } virtual Status NewDirectory(const std::string& name, - unique_ptr* result) override { + std::unique_ptr* result) override { PERF_TIMER_GUARD(env_new_directory_nanos); return EnvWrapper::NewDirectory(name, result); } @@ -131,7 +131,7 @@ class TimedEnv : public EnvWrapper { } virtual Status NewLogger(const std::string& fname, - shared_ptr* result) override { + std::shared_ptr* result) override { PERF_TIMER_GUARD(env_new_logger_nanos); return EnvWrapper::NewLogger(fname, result); } diff --git a/utilities/options/options_util_test.cc b/utilities/options/options_util_test.cc index bf830190c..4c12f1a67 100644 --- a/utilities/options/options_util_test.cc +++ b/utilities/options/options_util_test.cc @@ -104,8 +104,8 @@ class DummyTableFactory : public TableFactory { virtual Status NewTableReader( const TableReaderOptions& /*table_reader_options*/, - unique_ptr&& /*file*/, uint64_t /*file_size*/, - unique_ptr* /*table_reader*/, + std::unique_ptr&& /*file*/, + uint64_t /*file_size*/, std::unique_ptr* /*table_reader*/, bool /*prefetch_index_and_filter_in_cache*/) const override { return Status::NotSupported(); } diff --git a/utilities/persistent_cache/block_cache_tier.cc b/utilities/persistent_cache/block_cache_tier.cc index 1ebf8ae6b..f7f72df6d 100644 --- a/utilities/persistent_cache/block_cache_tier.cc +++ b/utilities/persistent_cache/block_cache_tier.cc @@ -263,7 +263,7 @@ Status BlockCacheTier::InsertImpl(const Slice& key, const Slice& data) { return Status::OK(); } -Status BlockCacheTier::Lookup(const Slice& key, unique_ptr* val, +Status BlockCacheTier::Lookup(const Slice& key, std::unique_ptr* val, size_t* size) { StopWatchNano timer(opt_.env, /*auto_start=*/ true); @@ -287,7 +287,7 @@ Status BlockCacheTier::Lookup(const Slice& key, unique_ptr* val, assert(file->refs_); - unique_ptr scratch(new char[lba.size_]); + std::unique_ptr scratch(new char[lba.size_]); Slice blk_key; Slice blk_val; @@ -369,7 +369,7 @@ bool BlockCacheTier::Reserve(const size_t size) { const double retain_fac = (100 - kEvictPct) / static_cast(100); while (size + size_ > opt_.cache_size * retain_fac) { - unique_ptr f(metadata_.Evict()); + std::unique_ptr f(metadata_.Evict()); if (!f) { // nothing is evictable return false; diff --git a/utilities/persistent_cache/block_cache_tier_file.h b/utilities/persistent_cache/block_cache_tier_file.h index ef5dbab04..e38b6c9a1 100644 --- a/utilities/persistent_cache/block_cache_tier_file.h +++ b/utilities/persistent_cache/block_cache_tier_file.h @@ -149,7 +149,7 @@ class RandomAccessCacheFile : public BlockCacheFile { public: explicit RandomAccessCacheFile(Env* const env, const std::string& dir, const uint32_t cache_id, - const shared_ptr& log) + const std::shared_ptr& log) : BlockCacheFile(env, dir, cache_id), log_(log) {} virtual ~RandomAccessCacheFile() {} diff --git a/utilities/persistent_cache/persistent_cache_bench.cc b/utilities/persistent_cache/persistent_cache_bench.cc index 7d26c3a7d..64d75c7a5 100644 --- a/utilities/persistent_cache/persistent_cache_bench.cc +++ b/utilities/persistent_cache/persistent_cache_bench.cc @@ -251,7 +251,7 @@ class CacheTierBenchmark { // create data for a key by filling with a certain pattern std::unique_ptr NewBlock(const uint64_t val) { - unique_ptr data(new char[FLAGS_iosize]); + std::unique_ptr data(new char[FLAGS_iosize]); memset(data.get(), val % 255, FLAGS_iosize); return data; } diff --git a/utilities/persistent_cache/persistent_cache_test.h b/utilities/persistent_cache/persistent_cache_test.h index 37e842f2e..ad99ea864 100644 --- a/utilities/persistent_cache/persistent_cache_test.h +++ b/utilities/persistent_cache/persistent_cache_test.h @@ -157,7 +157,7 @@ class PersistentCacheTierTest : public testing::Test { memset(edata, '0' + (i % 10), sizeof(edata)); auto k = prefix + PaddedNumber(i, /*count=*/8); Slice key(k); - unique_ptr block; + std::unique_ptr block; size_t block_size; if (eviction_enabled) { @@ -210,7 +210,7 @@ class PersistentCacheTierTest : public testing::Test { } const std::string path_; - shared_ptr log_; + std::shared_ptr log_; std::shared_ptr cache_; std::atomic key_{0}; size_t max_keys_ = 0; diff --git a/utilities/spatialdb/spatial_db.cc b/utilities/spatialdb/spatial_db.cc index 627eb9de6..b34976eb8 100644 --- a/utilities/spatialdb/spatial_db.cc +++ b/utilities/spatialdb/spatial_db.cc @@ -473,7 +473,7 @@ class SpatialIndexCursor : public Cursor { } - unique_ptr value_getter_; + std::unique_ptr value_getter_; bool valid_; Status status_; diff --git a/utilities/trace/file_trace_reader_writer.cc b/utilities/trace/file_trace_reader_writer.cc index 36baefc7b..38767c092 100644 --- a/utilities/trace/file_trace_reader_writer.cc +++ b/utilities/trace/file_trace_reader_writer.cc @@ -86,13 +86,13 @@ Status FileTraceWriter::Write(const Slice& data) { Status NewFileTraceReader(Env* env, const EnvOptions& env_options, const std::string& trace_filename, std::unique_ptr* trace_reader) { - unique_ptr trace_file; + std::unique_ptr trace_file; Status s = env->NewRandomAccessFile(trace_filename, &trace_file, env_options); if (!s.ok()) { return s; } - unique_ptr file_reader; + std::unique_ptr file_reader; file_reader.reset( new RandomAccessFileReader(std::move(trace_file), trace_filename)); trace_reader->reset(new FileTraceReader(std::move(file_reader))); @@ -102,13 +102,13 @@ Status NewFileTraceReader(Env* env, const EnvOptions& env_options, Status NewFileTraceWriter(Env* env, const EnvOptions& env_options, const std::string& trace_filename, std::unique_ptr* trace_writer) { - unique_ptr trace_file; + std::unique_ptr trace_file; Status s = env->NewWritableFile(trace_filename, &trace_file, env_options); if (!s.ok()) { return s; } - unique_ptr file_writer; + std::unique_ptr file_writer; file_writer.reset(new WritableFileWriter(std::move(trace_file), trace_filename, env_options)); trace_writer->reset(new FileTraceWriter(std::move(file_writer))); diff --git a/utilities/trace/file_trace_reader_writer.h b/utilities/trace/file_trace_reader_writer.h index b363a3f09..c0cc8882d 100644 --- a/utilities/trace/file_trace_reader_writer.h +++ b/utilities/trace/file_trace_reader_writer.h @@ -22,7 +22,7 @@ class FileTraceReader : public TraceReader { virtual Status Close() override; private: - unique_ptr file_reader_; + std::unique_ptr file_reader_; Slice result_; size_t offset_; char* const buffer_; @@ -41,7 +41,7 @@ class FileTraceWriter : public TraceWriter { virtual Status Close() override; private: - unique_ptr file_writer_; + std::unique_ptr file_writer_; }; } // namespace rocksdb diff --git a/utilities/transactions/transaction_lock_mgr.cc b/utilities/transactions/transaction_lock_mgr.cc index cd70c329d..8086f7c7c 100644 --- a/utilities/transactions/transaction_lock_mgr.cc +++ b/utilities/transactions/transaction_lock_mgr.cc @@ -222,9 +222,9 @@ void TransactionLockMgr::RemoveColumnFamily(uint32_t column_family_id) { } } -// Look up the LockMap shared_ptr for a given column_family_id. +// Look up the LockMap std::shared_ptr for a given column_family_id. // Note: The LockMap is only valid as long as the caller is still holding on -// to the returned shared_ptr. +// to the returned std::shared_ptr. std::shared_ptr TransactionLockMgr::GetLockMap( uint32_t column_family_id) { // First check thread-local cache diff --git a/utilities/transactions/write_prepared_txn_db.cc b/utilities/transactions/write_prepared_txn_db.cc index 57da28a77..fed2cb35b 100644 --- a/utilities/transactions/write_prepared_txn_db.cc +++ b/utilities/transactions/write_prepared_txn_db.cc @@ -379,9 +379,9 @@ void WritePreparedTxnDB::Init(const TransactionDBOptions& /* unused */) { // around. INC_STEP_FOR_MAX_EVICTED = std::max(COMMIT_CACHE_SIZE / 100, static_cast(1)); - snapshot_cache_ = unique_ptr[]>( + snapshot_cache_ = std::unique_ptr[]>( new std::atomic[SNAPSHOT_CACHE_SIZE] {}); - commit_cache_ = unique_ptr[]>( + commit_cache_ = std::unique_ptr[]>( new std::atomic[COMMIT_CACHE_SIZE] {}); } diff --git a/utilities/ttl/ttl_test.cc b/utilities/ttl/ttl_test.cc index ee7b317aa..f434d1857 100644 --- a/utilities/ttl/ttl_test.cc +++ b/utilities/ttl/ttl_test.cc @@ -370,14 +370,14 @@ class TtlTest : public testing::Test { static const int64_t kSampleSize_ = 100; std::string dbname_; DBWithTTL* db_ttl_; - unique_ptr env_; + std::unique_ptr env_; private: Options options_; KVMap kvmap_; KVMap::iterator kv_it_; const std::string kNewValue_ = "new_value"; - unique_ptr test_comp_filter_; + std::unique_ptr test_comp_filter_; }; // class TtlTest // If TTL is non positive or not provided, the behaviour is TTL = infinity