diff --git a/db/builder.cc b/db/builder.cc index c592a964727dd32d7c8b0440245a826fd8300441..5c90d348cf2a6e3ff9607f98663c6bc2d22e1193 100644 --- a/db/builder.cc +++ b/db/builder.cc @@ -121,8 +121,8 @@ Status BuildTable( file->SetIOPriority(io_priority); file->SetWriteLifeTimeHint(write_hint); - file_writer.reset(new WritableFileWriter(std::move(file), env_options, - ioptions.statistics)); + file_writer.reset(new WritableFileWriter( + std::move(file), fname, env_options, ioptions.statistics)); builder = NewTableBuilder( ioptions, mutable_cf_options, internal_comparator, int_tbl_prop_collector_factories, column_family_id, diff --git a/db/c.cc b/db/c.cc index f9793ceb038d0323a34d2bdd2cd17e5f1e6710c4..4beb719885fbd4063b3655a9db583f605cfd0fa3 100644 --- a/db/c.cc +++ b/db/c.cc @@ -2433,11 +2433,13 @@ void rocksdb_options_set_max_write_buffer_number_to_maintain( opt->rep.max_write_buffer_number_to_maintain = n; } -void rocksdb_options_set_enable_pipelined_write(rocksdb_options_t* opt, unsigned char v) { +void rocksdb_options_set_enable_pipelined_write(rocksdb_options_t* opt, + unsigned char v) { opt->rep.enable_pipelined_write = v; } -void rocksdb_options_set_max_subcompactions(rocksdb_options_t* opt, uint32_t n) { +void rocksdb_options_set_max_subcompactions(rocksdb_options_t* opt, + uint32_t n) { opt->rep.max_subcompactions = n; } diff --git a/db/compaction_iterator.cc b/db/compaction_iterator.cc index 7b096ca04a93b18a49c5e1fc300993bb4bf2750a..5f1a5c3dac64be05b84cdd1581686c53f6cabb23 100644 --- a/db/compaction_iterator.cc +++ b/db/compaction_iterator.cc @@ -18,8 +18,8 @@ CompactionIterator::CompactionIterator( SequenceNumber earliest_write_conflict_snapshot, const SnapshotChecker* snapshot_checker, Env* env, bool report_detailed_time, bool expect_valid_internal_key, - RangeDelAggregator* range_del_agg, - const Compaction* compaction, const CompactionFilter* compaction_filter, + RangeDelAggregator* range_del_agg, const Compaction* compaction, + const CompactionFilter* compaction_filter, const std::atomic* shutting_down, const SequenceNumber preserve_deletes_seqnum) : CompactionIterator( diff --git a/db/compaction_iterator_test.cc b/db/compaction_iterator_test.cc index aa929f19f548ab924d740444f4e16e8f74aad9f8..75eba90b6c82845c5525bcd453090b0b7f64a222 100644 --- a/db/compaction_iterator_test.cc +++ b/db/compaction_iterator_test.cc @@ -247,9 +247,8 @@ class CompactionIteratorTest : public testing::TestWithParam { c_iter_.reset(new CompactionIterator( iter_.get(), cmp_, merge_helper_.get(), last_sequence, &snapshots_, earliest_write_conflict_snapshot, snapshot_checker_.get(), - Env::Default(), false /* report_detailed_time */, - false, range_del_agg_.get(), std::move(compaction), filter, - &shutting_down_)); + Env::Default(), false /* report_detailed_time */, false, + range_del_agg_.get(), std::move(compaction), filter, &shutting_down_)); } void AddSnapshot(SequenceNumber snapshot, diff --git a/db/compaction_job.cc b/db/compaction_job.cc index 44eedffb6b7aac9a8f8af3ce58c7d4544284dfec..f17f2e34a3bd71b27bf0273cb255099ef3df6456 100644 --- a/db/compaction_job.cc +++ b/db/compaction_job.cc @@ -1464,8 +1464,9 @@ Status CompactionJob::OpenCompactionOutputFile( writable_file->SetWriteLifeTimeHint(write_hint_); writable_file->SetPreallocationBlockSize(static_cast( sub_compact->compaction->OutputFilePreallocationSize())); - sub_compact->outfile.reset(new WritableFileWriter( - std::move(writable_file), env_options_, db_options_.statistics.get())); + sub_compact->outfile.reset( + new WritableFileWriter(std::move(writable_file), fname, env_options_, + db_options_.statistics.get())); // If the Column family flag is to only optimize filters for hits, // we can skip creating filters if this is the bottommost_level where diff --git a/db/compaction_job_test.cc b/db/compaction_job_test.cc index e32b5a078d45b40896ea53ef0ed77c79960d5064..3febded80c6314a77988f7c4aa9c58c4be907535 100644 --- a/db/compaction_job_test.cc +++ b/db/compaction_job_test.cc @@ -205,7 +205,7 @@ class CompactionJobTest : public testing::Test { manifest, &file, env_->OptimizeForManifestWrite(env_options_)); ASSERT_OK(s); unique_ptr file_writer( - new WritableFileWriter(std::move(file), env_options_)); + new WritableFileWriter(std::move(file), manifest, env_options_)); { log::Writer log(std::move(file_writer), 0, false); std::string record; diff --git a/db/db_impl.cc b/db/db_impl.cc index 7e4c0471b25191414b70b5b304acc9f127bc7bf0..8af35e6d1bf2bdabfb56ef2b1a469940f2e5bdc8 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -3143,7 +3143,8 @@ Status DBImpl::TraceIteratorSeek(const uint32_t& cf_id, const Slice& key) { return s; } -Status DBImpl::TraceIteratorSeekForPrev(const uint32_t& cf_id, const Slice& key) { +Status DBImpl::TraceIteratorSeekForPrev(const uint32_t& cf_id, + const Slice& key) { Status s; if (tracer_) { InstrumentedMutexLock lock(&trace_mutex_); diff --git a/db/db_impl.h b/db/db_impl.h index 36428f33eaa966fa1b99c542b34bec2c4ec845b2..4f122c38d74b74f0ef55afd54280c57fa60e2f67 100644 --- a/db/db_impl.h +++ b/db/db_impl.h @@ -22,9 +22,9 @@ #include "db/column_family.h" #include "db/compaction_job.h" #include "db/dbformat.h" -#include "db/external_sst_file_ingestion_job.h" #include "db/error_handler.h" #include "db/event_helpers.h" +#include "db/external_sst_file_ingestion_job.h" #include "db/flush_job.h" #include "db/flush_scheduler.h" #include "db/internal_stats.h" diff --git a/db/db_impl_open.cc b/db/db_impl_open.cc index 4e68327dd5d07c65dcee7861714a542df0f72922..173ca4e4e98cb296e0373dcd057dfa42646b7bc9 100644 --- a/db/db_impl_open.cc +++ b/db/db_impl_open.cc @@ -232,7 +232,7 @@ Status DBImpl::NewDB() { file->SetPreallocationBlockSize( immutable_db_options_.manifest_preallocation_size); unique_ptr file_writer( - new WritableFileWriter(std::move(file), env_options)); + new WritableFileWriter(std::move(file), manifest, env_options)); log::Writer log(std::move(file_writer), 0, false); std::string record; new_db.EncodeTo(&record); @@ -1075,10 +1075,10 @@ Status DBImpl::Open(const DBOptions& db_options, const std::string& dbname, impl->immutable_db_options_.env->OptimizeForLogWrite( soptions, BuildDBOptions(impl->immutable_db_options_, impl->mutable_db_options_)); - s = NewWritableFile( - impl->immutable_db_options_.env, - LogFileName(impl->immutable_db_options_.wal_dir, new_log_number), - &lfile, opt_env_options); + std::string log_fname = + LogFileName(impl->immutable_db_options_.wal_dir, new_log_number); + s = NewWritableFile(impl->immutable_db_options_.env, log_fname, &lfile, + opt_env_options); if (s.ok()) { lfile->SetWriteLifeTimeHint(write_hint); lfile->SetPreallocationBlockSize( @@ -1086,8 +1086,8 @@ Status DBImpl::Open(const DBOptions& db_options, const std::string& dbname, { InstrumentedMutexLock wl(&impl->log_write_mutex_); impl->logfile_number_ = new_log_number; - unique_ptr file_writer( - new WritableFileWriter(std::move(lfile), opt_env_options)); + unique_ptr file_writer(new WritableFileWriter( + std::move(lfile), log_fname, opt_env_options)); impl->logs_.emplace_back( new_log_number, new log::Writer( diff --git a/db/db_impl_write.cc b/db/db_impl_write.cc index de4c9b3c8f0688760959708308888cde0df4adb6..366f7e74e77a7ff0b02d09e56b802583d4c05b68 100644 --- a/db/db_impl_write.cc +++ b/db/db_impl_write.cc @@ -1319,6 +1319,8 @@ Status DBImpl::SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context, auto write_hint = CalculateWALWriteHint(); mutex_.Unlock(); { + std::string log_fname = + LogFileName(immutable_db_options_.wal_dir, new_log_number); if (creating_new_log) { EnvOptions opt_env_opt = env_->OptimizeForLogWrite(env_options_, db_options); @@ -1326,14 +1328,12 @@ Status DBImpl::SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context, ROCKS_LOG_INFO(immutable_db_options_.info_log, "reusing log %" PRIu64 " from recycle list\n", recycle_log_number); - s = env_->ReuseWritableFile( - LogFileName(immutable_db_options_.wal_dir, new_log_number), - LogFileName(immutable_db_options_.wal_dir, recycle_log_number), - &lfile, opt_env_opt); + std::string old_log_fname = + LogFileName(immutable_db_options_.wal_dir, recycle_log_number); + s = env_->ReuseWritableFile(log_fname, old_log_fname, &lfile, + opt_env_opt); } else { - s = NewWritableFile( - env_, LogFileName(immutable_db_options_.wal_dir, new_log_number), - &lfile, opt_env_opt); + s = NewWritableFile(env_, log_fname, &lfile, opt_env_opt); } if (s.ok()) { // Our final size should be less than write_buffer_size @@ -1344,7 +1344,7 @@ Status DBImpl::SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context, lfile->SetPreallocationBlockSize(preallocate_block_size); lfile->SetWriteLifeTimeHint(write_hint); unique_ptr file_writer( - new WritableFileWriter(std::move(lfile), opt_env_opt)); + new WritableFileWriter(std::move(lfile), log_fname, opt_env_opt)); new_log = new log::Writer( std::move(file_writer), new_log_number, immutable_db_options_.recycle_log_file_num > 0, manual_wal_flush_); diff --git a/db/db_wal_test.cc b/db/db_wal_test.cc index 0349bdc8dae5145e838108577f37c005c17f5c25..1c5bfb6d58a921d8e8597b07fde9831eb3e0368d 100644 --- a/db/db_wal_test.cc +++ b/db/db_wal_test.cc @@ -815,7 +815,7 @@ class RecoveryTestHelper { unique_ptr file; ASSERT_OK(db_options.env->NewWritableFile(fname, &file, env_options)); unique_ptr file_writer( - new WritableFileWriter(std::move(file), env_options)); + new WritableFileWriter(std::move(file), fname, env_options)); current_log_writer.reset( new log::Writer(std::move(file_writer), current_log_number, db_options.recycle_log_file_num > 0)); diff --git a/db/flush_job_test.cc b/db/flush_job_test.cc index 324037478a85d9b7f54753cf820b450eb7847498..041edeaa4b17b1cdc3f9f369deefdc03a85bf91a 100644 --- a/db/flush_job_test.cc +++ b/db/flush_job_test.cc @@ -62,7 +62,7 @@ class FlushJobTest : public testing::Test { manifest, &file, env_->OptimizeForManifestWrite(env_options_)); ASSERT_OK(s); unique_ptr file_writer( - new WritableFileWriter(std::move(file), EnvOptions())); + new WritableFileWriter(std::move(file), manifest, EnvOptions())); { log::Writer log(std::move(file_writer), 0, false); std::string record; diff --git a/db/log_test.cc b/db/log_test.cc index 992851fe26b3c2ab3f5485f287f22bb176d814cc..2b6e8314191f0fe7e89a79ba93c2ab9f0ded305b 100644 --- a/db/log_test.cc +++ b/db/log_test.cc @@ -159,7 +159,7 @@ class LogTest : public ::testing::TestWithParam { LogTest() : reader_contents_(), dest_holder_(test::GetWritableFileWriter( - new test::StringSink(&reader_contents_))), + new test::StringSink(&reader_contents_), "" /* don't care */)), source_holder_(test::GetSequentialFileReader( new StringSource(reader_contents_), "" /* file name */)), writer_(std::move(dest_holder_), 123, GetParam()), @@ -718,7 +718,8 @@ TEST_P(LogTest, Recycle) { Write("xxxxxxxxxxxxxxxx"); } unique_ptr dest_holder(test::GetWritableFileWriter( - new test::OverwritingStringSink(get_reader_contents()))); + new test::OverwritingStringSink(get_reader_contents()), + "" /* don't care */)); Writer recycle_writer(std::move(dest_holder), 123, true); recycle_writer.AddRecord(Slice("foooo")); recycle_writer.AddRecord(Slice("bar")); diff --git a/db/range_del_aggregator.cc b/db/range_del_aggregator.cc index d9269458a7ca1d959d863575a1880423e56c2759..c9a65af4ad5fbb5751391bbbaf94e7094ec0b68a 100644 --- a/db/range_del_aggregator.cc +++ b/db/range_del_aggregator.cc @@ -76,7 +76,9 @@ class UncollapsedRangeDelMap : public RangeDelMap { return false; } - void AddTombstone(RangeTombstone tombstone) override { rep_.emplace(tombstone); } + void AddTombstone(RangeTombstone tombstone) override { + rep_.emplace(tombstone); + } size_t Size() const override { return rep_.size(); } diff --git a/db/snapshot_checker.h b/db/snapshot_checker.h index 4570aee9c6180a403917e7b18b6bce013826cf0c..67d17bd6d12ec92e237b3703c611581274a633a1 100644 --- a/db/snapshot_checker.h +++ b/db/snapshot_checker.h @@ -19,8 +19,9 @@ class SnapshotChecker { class DisableGCSnapshotChecker : public SnapshotChecker { public: virtual ~DisableGCSnapshotChecker() {} - virtual bool IsInSnapshot(SequenceNumber /*sequence*/, - SequenceNumber /*snapshot_sequence*/) const override { + virtual bool IsInSnapshot( + SequenceNumber /*sequence*/, + SequenceNumber /*snapshot_sequence*/) const override { // By returning false, we prevent all the values from being GCed return false; } diff --git a/db/table_properties_collector_test.cc b/db/table_properties_collector_test.cc index a51a36f628a4636ef705d79bd858962d4086f175..2147bf3fa1be80bb60599202437be6cbd55764de 100644 --- a/db/table_properties_collector_test.cc +++ b/db/table_properties_collector_test.cc @@ -46,7 +46,8 @@ void MakeBuilder(const Options& options, const ImmutableCFOptions& ioptions, std::unique_ptr* writable, std::unique_ptr* builder) { unique_ptr wf(new test::StringSink); - writable->reset(new WritableFileWriter(std::move(wf), EnvOptions())); + writable->reset( + new WritableFileWriter(std::move(wf), "" /* don't care */, EnvOptions())); int unknown_level = -1; builder->reset(NewTableBuilder( ioptions, moptions, internal_comparator, int_tbl_prop_collector_factories, diff --git a/db/version_set.cc b/db/version_set.cc index ede91c6133496a842e1eff15f347bcfbcdd9db42..67a0246301479bba3f3f487e9cf972e250f42954 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -2901,16 +2901,17 @@ Status VersionSet::ProcessManifestWrites( // create new manifest file ROCKS_LOG_INFO(db_options_->info_log, "Creating manifest %" PRIu64 "\n", pending_manifest_file_number_); + std::string descriptor_fname = + DescriptorFileName(dbname_, pending_manifest_file_number_); unique_ptr descriptor_file; - s = NewWritableFile( - env_, DescriptorFileName(dbname_, pending_manifest_file_number_), - &descriptor_file, opt_env_opts); + 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::move(descriptor_file), opt_env_opts)); + unique_ptr file_writer(new WritableFileWriter( + std::move(descriptor_file), descriptor_fname, opt_env_opts)); descriptor_log_.reset( new log::Writer(std::move(file_writer), 0, false)); s = WriteSnapshot(descriptor_log_.get()); diff --git a/db/version_set_test.cc b/db/version_set_test.cc index 7ad823cb423e12f711e6f96876d372690181092b..26fb18dd038fedeaee7ae6eb0da649f439ee7492 100644 --- a/db/version_set_test.cc +++ b/db/version_set_test.cc @@ -566,7 +566,7 @@ class ManifestWriterTest : public testing::Test { manifest, &file, env_->OptimizeForManifestWrite(env_options_)); ASSERT_OK(s); unique_ptr file_writer( - new WritableFileWriter(std::move(file), env_options_)); + new WritableFileWriter(std::move(file), manifest, env_options_)); { log::Writer log(std::move(file_writer), 0, false); std::string record; diff --git a/db/wal_manager_test.cc b/db/wal_manager_test.cc index 3bcc19888d559234bec6cfbf97aca037e3a849ac..838fad2b1d948cc4b7bc5a388c5bd3cecd8a9b02 100644 --- a/db/wal_manager_test.cc +++ b/db/wal_manager_test.cc @@ -79,7 +79,7 @@ class WalManagerTest : public testing::Test { unique_ptr file; ASSERT_OK(env_->NewWritableFile(fname, &file, env_options_)); unique_ptr file_writer( - new WritableFileWriter(std::move(file), env_options_)); + new WritableFileWriter(std::move(file), fname, env_options_)); current_log_writer_.reset(new log::Writer(std::move(file_writer), 0, false)); } @@ -130,7 +130,7 @@ TEST_F(WalManagerTest, ReadFirstRecordCache) { ASSERT_EQ(s, 0U); unique_ptr file_writer( - new WritableFileWriter(std::move(file), EnvOptions())); + new WritableFileWriter(std::move(file), path, EnvOptions())); log::Writer writer(std::move(file_writer), 1, db_options_.recycle_log_file_num > 0); WriteBatch batch; diff --git a/include/rocksdb/slice.h b/include/rocksdb/slice.h index 2eeedb9cf68be6124e2098f5465c92d37e587346..b2db059d3a692ed424a36205b6c5790f51d7b99d 100644 --- a/include/rocksdb/slice.h +++ b/include/rocksdb/slice.h @@ -48,7 +48,7 @@ class Slice { #ifdef __cpp_lib_string_view // Create a slice that refers to the same contents as "sv" /* implicit */ - Slice(std::string_view sv) : data_(sv.data()), size_(sv.size()) { } + Slice(std::string_view sv) : data_(sv.data()), size_(sv.size()) {} #endif // Create a slice that refers to s[0,strlen(s)-1] diff --git a/options/options_parser.cc b/options/options_parser.cc index 35bbc82cd2ab51a085c647bd8f3c6c32eb33655f..f9144b67d77549e1ac31d715ebf1c6a80d1340a2 100644 --- a/options/options_parser.cc +++ b/options/options_parser.cc @@ -49,7 +49,7 @@ Status PersistRocksDBOptions(const DBOptions& db_opt, return s; } unique_ptr writable; - writable.reset(new WritableFileWriter(std::move(wf), EnvOptions(), + writable.reset(new WritableFileWriter(std::move(wf), file_name, EnvOptions(), nullptr /* statistics */)); std::string options_file_content; diff --git a/port/win/env_win.cc b/port/win/env_win.cc index 043443920ed828b9c68810e78e407991619892d0..814207e3c34949c5db48087c0254854e12510c70 100644 --- a/port/win/env_win.cc +++ b/port/win/env_win.cc @@ -716,30 +716,27 @@ Status WinEnvIO::LinkFile(const std::string& src, return result; } -Status WinEnvIO::NumFileLinks(const std::string& fname, - uint64_t* count) { +Status WinEnvIO::NumFileLinks(const std::string& fname, uint64_t* count) { Status s; - HANDLE handle = ::CreateFileA(fname.c_str(), 0, - FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, - NULL); + HANDLE handle = ::CreateFileA( + fname.c_str(), 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if (INVALID_HANDLE_VALUE == handle) { auto lastError = GetLastError(); - s = IOErrorFromWindowsError( - "NumFileLinks: " + fname, lastError); + s = IOErrorFromWindowsError("NumFileLinks: " + fname, lastError); return s; } UniqueCloseHandlePtr handle_guard(handle, CloseHandleFunc); FILE_STANDARD_INFO standard_info; - if (0 != GetFileInformationByHandleEx(handle, FileStandardInfo, - &standard_info, sizeof(standard_info))) { + if (0 != GetFileInformationByHandleEx(handle, FileStandardInfo, + &standard_info, + sizeof(standard_info))) { *count = standard_info.NumberOfLinks; } else { auto lastError = GetLastError(); - s = IOErrorFromWindowsError("GetFileInformationByHandleEx: " + fname, lastError); + s = IOErrorFromWindowsError("GetFileInformationByHandleEx: " + fname, + lastError); } return s; } diff --git a/port/win/env_win.h b/port/win/env_win.h index 08c1534f34ccd247fea9e7d1df14d14096f2cf7c..81b323a71199121aa961508178fda33be5f66d74 100644 --- a/port/win/env_win.h +++ b/port/win/env_win.h @@ -145,7 +145,7 @@ public: const std::string& target); virtual Status NumFileLinks(const std::string& /*fname*/, - uint64_t* /*count*/); + uint64_t* /*count*/); virtual Status AreFilesSame(const std::string& first, const std::string& second, bool* res); @@ -271,8 +271,7 @@ public: Status LinkFile(const std::string& src, const std::string& target) override; - Status NumFileLinks(const std::string& fname, - uint64_t* count) override; + Status NumFileLinks(const std::string& fname, uint64_t* count) override; Status AreFilesSame(const std::string& first, const std::string& second, bool* res) override; diff --git a/table/block_builder.h b/table/block_builder.h index 52b9571162a77238dbfe72d1b87778916be68793..3b7fc1768bc97b6649b4ac5f5848408d9732f8da 100644 --- a/table/block_builder.h +++ b/table/block_builder.h @@ -60,7 +60,7 @@ class BlockBuilder { private: const int block_restart_interval_; - //TODO(myabandeh): put it into a separate IndexBlockBuilder + // TODO(myabandeh): put it into a separate IndexBlockBuilder const bool use_delta_encoding_; // Refer to BlockIter::DecodeCurrentValue for format of delta encoded values const bool use_value_delta_encoding_; diff --git a/table/block_test.cc b/table/block_test.cc index 009740a283c565605d5db5f4a41c339ef1c0bc4e..0ca6ec3f6dece22587757ef9630811a778dcfc82 100644 --- a/table/block_test.cc +++ b/table/block_test.cc @@ -70,10 +70,10 @@ void GenerateRandomKVs(std::vector *keys, // Same as GenerateRandomKVs but the values are BlockHandle void GenerateRandomKBHs(std::vector *keys, - std::vector *values, const int from, - const int len, const int step = 1, - const int padding_size = 0, - const int keys_share_prefix = 1) { + std::vector *values, const int from, + const int len, const int step = 1, + const int padding_size = 0, + const int keys_share_prefix = 1) { Random rnd(302); uint64_t offset = 0; diff --git a/table/cuckoo_table_builder_test.cc b/table/cuckoo_table_builder_test.cc index 0d24da719437c104e7043544ba8d05c489844e18..27eacf6ec95490305eaa486db8c8eb4bc6d3e630 100644 --- a/table/cuckoo_table_builder_test.cc +++ b/table/cuckoo_table_builder_test.cc @@ -156,7 +156,7 @@ TEST_F(CuckooBuilderTest, SuccessWithEmptyFile) { fname = test::PerThreadDBPath("EmptyFile"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); unique_ptr file_writer( - new WritableFileWriter(std::move(writable_file), EnvOptions())); + new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, 4, 100, BytewiseComparator(), 1, false, false, GetSliceHash, 0 /* column_family_id */, @@ -192,7 +192,7 @@ TEST_F(CuckooBuilderTest, WriteSuccessNoCollisionFullKey) { fname = test::PerThreadDBPath("NoCollisionFullKey"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); unique_ptr file_writer( - new WritableFileWriter(std::move(writable_file), EnvOptions())); + new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 100, BytewiseComparator(), 1, false, false, GetSliceHash, 0 /* column_family_id */, @@ -240,7 +240,7 @@ TEST_F(CuckooBuilderTest, WriteSuccessWithCollisionFullKey) { fname = test::PerThreadDBPath("WithCollisionFullKey"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); unique_ptr file_writer( - new WritableFileWriter(std::move(writable_file), EnvOptions())); + new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 100, BytewiseComparator(), 1, false, false, GetSliceHash, 0 /* column_family_id */, @@ -289,7 +289,7 @@ TEST_F(CuckooBuilderTest, WriteSuccessWithCollisionAndCuckooBlock) { fname = test::PerThreadDBPath("WithCollisionFullKey2"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); unique_ptr file_writer( - new WritableFileWriter(std::move(writable_file), EnvOptions())); + new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder( file_writer.get(), kHashTableRatio, num_hash_fun, 100, BytewiseComparator(), cuckoo_block_size, false, false, GetSliceHash, @@ -342,7 +342,7 @@ TEST_F(CuckooBuilderTest, WithCollisionPathFullKey) { fname = test::PerThreadDBPath("WithCollisionPathFullKey"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); unique_ptr file_writer( - new WritableFileWriter(std::move(writable_file), EnvOptions())); + new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 100, BytewiseComparator(), 1, false, false, GetSliceHash, 0 /* column_family_id */, @@ -392,7 +392,7 @@ TEST_F(CuckooBuilderTest, WithCollisionPathFullKeyAndCuckooBlock) { fname = test::PerThreadDBPath("WithCollisionPathFullKeyAndCuckooBlock"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); unique_ptr file_writer( - new WritableFileWriter(std::move(writable_file), EnvOptions())); + new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 100, BytewiseComparator(), 2, false, false, GetSliceHash, 0 /* column_family_id */, @@ -435,7 +435,7 @@ TEST_F(CuckooBuilderTest, WriteSuccessNoCollisionUserKey) { fname = test::PerThreadDBPath("NoCollisionUserKey"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); unique_ptr file_writer( - new WritableFileWriter(std::move(writable_file), EnvOptions())); + new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 100, BytewiseComparator(), 1, false, false, GetSliceHash, 0 /* column_family_id */, @@ -479,7 +479,7 @@ TEST_F(CuckooBuilderTest, WriteSuccessWithCollisionUserKey) { fname = test::PerThreadDBPath("WithCollisionUserKey"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); unique_ptr file_writer( - new WritableFileWriter(std::move(writable_file), EnvOptions())); + new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 100, BytewiseComparator(), 1, false, false, GetSliceHash, 0 /* column_family_id */, @@ -525,7 +525,7 @@ TEST_F(CuckooBuilderTest, WithCollisionPathUserKey) { fname = test::PerThreadDBPath("WithCollisionPathUserKey"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); unique_ptr file_writer( - new WritableFileWriter(std::move(writable_file), EnvOptions())); + new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 2, BytewiseComparator(), 1, false, false, GetSliceHash, 0 /* column_family_id */, @@ -570,7 +570,7 @@ TEST_F(CuckooBuilderTest, FailWhenCollisionPathTooLong) { fname = test::PerThreadDBPath("WithCollisionPathUserKey"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); unique_ptr file_writer( - new WritableFileWriter(std::move(writable_file), EnvOptions())); + new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 2, BytewiseComparator(), 1, false, false, GetSliceHash, 0 /* column_family_id */, @@ -598,7 +598,7 @@ TEST_F(CuckooBuilderTest, FailWhenSameKeyInserted) { fname = test::PerThreadDBPath("FailWhenSameKeyInserted"); ASSERT_OK(env_->NewWritableFile(fname, &writable_file, env_options_)); unique_ptr file_writer( - new WritableFileWriter(std::move(writable_file), EnvOptions())); + new WritableFileWriter(std::move(writable_file), fname, EnvOptions())); CuckooTableBuilder builder(file_writer.get(), kHashTableRatio, num_hash_fun, 100, BytewiseComparator(), 1, false, false, GetSliceHash, 0 /* column_family_id */, diff --git a/table/cuckoo_table_reader_test.cc b/table/cuckoo_table_reader_test.cc index 3aeca5e132f45e0e56c4bfef2bbfde74c1819b11..36083c54747cdac8d280110f27f614948357d176 100644 --- a/table/cuckoo_table_reader_test.cc +++ b/table/cuckoo_table_reader_test.cc @@ -96,7 +96,7 @@ class CuckooReaderTest : public testing::Test { std::unique_ptr writable_file; ASSERT_OK(env->NewWritableFile(fname, &writable_file, env_options)); unique_ptr file_writer( - new WritableFileWriter(std::move(writable_file), env_options)); + new WritableFileWriter(std::move(writable_file), fname, env_options)); CuckooTableBuilder builder( file_writer.get(), 0.9, kNumHashFunc, 100, ucomp, 2, false, false, @@ -412,7 +412,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( - new WritableFileWriter(std::move(writable_file), env_options)); + new WritableFileWriter(std::move(writable_file), fname, env_options)); CuckooTableBuilder builder( file_writer.get(), hash_ratio, 64, 1000, test::Uint64Comparator(), 5, false, FLAGS_identity_as_first_hash, nullptr, 0 /* column_family_id */, diff --git a/table/data_block_hash_index_test.cc b/table/data_block_hash_index_test.cc index c2b059893fedb439e4172dcd5b00f3645e890af9..dc62917f2a101fe14a0b7e881ba02b4be2052a27 100644 --- a/table/data_block_hash_index_test.cc +++ b/table/data_block_hash_index_test.cc @@ -553,7 +553,8 @@ void TestBoundary(InternalKey& ik1, std::string& v1, InternalKey& ik2, EnvOptions soptions; soptions.use_mmap_reads = ioptions.allow_mmap_reads; - file_writer.reset(test::GetWritableFileWriter(new test::StringSink())); + file_writer.reset( + test::GetWritableFileWriter(new test::StringSink(), "" /* don't care */)); unique_ptr builder; std::vector> int_tbl_prop_collector_factories; diff --git a/table/index_builder.cc b/table/index_builder.cc index 5eaecbad10cfbf531d607e789cfd9888606a68d5..cd28c42a8b0a399dc311dba97b1a2095fcdc18e2 100644 --- a/table/index_builder.cc +++ b/table/index_builder.cc @@ -210,7 +210,5 @@ Status PartitionedIndexBuilder::Finish( } } -size_t PartitionedIndexBuilder::NumPartitions() const { - return partition_cnt_; -} +size_t PartitionedIndexBuilder::NumPartitions() const { return partition_cnt_; } } // namespace rocksdb diff --git a/table/index_builder.h b/table/index_builder.h index 147108d3b14a8dc02ef0f6756a8372950b07c066..87d7b7a71bf07a78bf27a0ccf7c77a4dc093d555 100644 --- a/table/index_builder.h +++ b/table/index_builder.h @@ -181,9 +181,7 @@ class ShortenedIndexBuilder : public IndexBuilder { return Status::OK(); } - virtual size_t IndexSize() const override { - return index_size_; - } + virtual size_t IndexSize() const override { return index_size_; } virtual bool seperator_is_key_plus_seq() override { return seperator_is_key_plus_seq_; @@ -353,12 +351,8 @@ class PartitionedIndexBuilder : public IndexBuilder { IndexBlocks* index_blocks, const BlockHandle& last_partition_block_handle) override; - virtual size_t IndexSize() const override { - return index_size_; - } - size_t TopLevelIndexSize(uint64_t) const { - return top_level_index_size_; - } + virtual size_t IndexSize() const override { return index_size_; } + size_t TopLevelIndexSize(uint64_t) const { return top_level_index_size_; } size_t NumPartitions() const; inline bool ShouldCutFilterBlock() { diff --git a/table/mock_table.cc b/table/mock_table.cc index 54bab73d8a33f672aa347948821175dbcaa22b9a..a5473b30bc80951ba894a8d8c1c471b0340ba0b1 100644 --- a/table/mock_table.cc +++ b/table/mock_table.cc @@ -93,7 +93,7 @@ Status MockTableFactory::CreateMockTable(Env* env, const std::string& fname, return s; } - WritableFileWriter file_writer(std::move(file), EnvOptions()); + WritableFileWriter file_writer(std::move(file), fname, EnvOptions()); uint32_t id = GetAndWriteNextID(&file_writer); file_system_.files.insert({id, std::move(file_contents)}); diff --git a/table/sst_file_writer.cc b/table/sst_file_writer.cc index ae189daa599e63cbdcac22b92d15fb1c7793c337..e0c4c31896b091fbac32b9012126e0b7b2a12f19 100644 --- a/table/sst_file_writer.cc +++ b/table/sst_file_writer.cc @@ -238,7 +238,7 @@ Status SstFileWriter::Open(const std::string& file_path) { nullptr /* compression_dict */, r->skip_filters, r->column_family_name, unknown_level); r->file_writer.reset( - new WritableFileWriter(std::move(sst_file), r->env_options)); + new WritableFileWriter(std::move(sst_file), file_path, r->env_options)); // TODO(tec) : If table_factory is using compressed block cache, we will // be adding the external sst file blocks into it, which is wasteful. diff --git a/table/table_reader_bench.cc b/table/table_reader_bench.cc index b05e3e05265dddd4ea339d33041e078b668d421c..4032c4a5a1e9739f34ae1ad86463afe70485544f 100644 --- a/table/table_reader_bench.cc +++ b/table/table_reader_bench.cc @@ -94,7 +94,8 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options, std::vector > int_tbl_prop_collector_factories; - file_writer.reset(new WritableFileWriter(std::move(file), env_options)); + file_writer.reset( + new WritableFileWriter(std::move(file), file_name, env_options)); int unknown_level = -1; tb = opts.table_factory->NewTableBuilder( TableBuilderOptions( diff --git a/table/table_test.cc b/table/table_test.cc index af648bc053282a61d30a034c4abf7b61a52dda6c..26383fa81797bd0d4c076561d6382e83f981980a 100644 --- a/table/table_test.cc +++ b/table/table_test.cc @@ -323,7 +323,8 @@ class TableConstructor: public Constructor { const stl_wrappers::KVMap& kv_map) override { Reset(); soptions.use_mmap_reads = ioptions.allow_mmap_reads; - file_writer_.reset(test::GetWritableFileWriter(new test::StringSink())); + file_writer_.reset(test::GetWritableFileWriter(new test::StringSink(), + "" /* don't care */)); unique_ptr builder; std::vector> int_tbl_prop_collector_factories; @@ -2550,7 +2551,7 @@ TEST_F(PlainTableTest, BasicPlainTableProperties) { PlainTableFactory factory(plain_table_options); test::StringSink sink; unique_ptr file_writer( - test::GetWritableFileWriter(new test::StringSink())); + test::GetWritableFileWriter(new test::StringSink(), "" /* don't care */)); Options options; const ImmutableCFOptions ioptions(options); const MutableCFOptions moptions(options); @@ -3150,7 +3151,8 @@ TEST_F(PrefixTest, PrefixAndWholeKeyTest) { TEST_P(BlockBasedTableTest, DISABLED_TableWithGlobalSeqno) { BlockBasedTableOptions bbto = GetBlockBasedTableOptions(); test::StringSink* sink = new test::StringSink(); - unique_ptr file_writer(test::GetWritableFileWriter(sink)); + unique_ptr file_writer( + test::GetWritableFileWriter(sink, "" /* don't care */)); Options options; options.table_factory.reset(NewBlockBasedTableFactory(bbto)); const ImmutableCFOptions ioptions(options); @@ -3331,7 +3333,8 @@ TEST_P(BlockBasedTableTest, BlockAlignTest) { BlockBasedTableOptions bbto = GetBlockBasedTableOptions(); bbto.block_align = true; test::StringSink* sink = new test::StringSink(); - unique_ptr file_writer(test::GetWritableFileWriter(sink)); + unique_ptr file_writer( + test::GetWritableFileWriter(sink, "" /* don't care */)); Options options; options.compression = kNoCompression; options.table_factory.reset(NewBlockBasedTableFactory(bbto)); @@ -3420,7 +3423,8 @@ TEST_P(BlockBasedTableTest, PropertiesBlockRestartPointTest) { BlockBasedTableOptions bbto = GetBlockBasedTableOptions(); bbto.block_align = true; test::StringSink* sink = new test::StringSink(); - unique_ptr file_writer(test::GetWritableFileWriter(sink)); + unique_ptr file_writer( + test::GetWritableFileWriter(sink, "" /* don't care */)); Options options; options.compression = kNoCompression; diff --git a/tools/db_stress.cc b/tools/db_stress.cc index a7cfd51d6651855f01802af2a9bb05b29a72f7d9..337ddab2a5ba0c510e5026c09127ad8a0975fcfd 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -591,7 +591,7 @@ enum RepFactory StringToRepFactory(const char* ctype) { #ifdef _MSC_VER #pragma warning(push) // truncation of constant value on static_cast -#pragma warning(disable: 4309) +#pragma warning(disable : 4309) #endif bool GetNextPrefix(const rocksdb::Slice& src, std::string* v) { std::string ret = src.ToString(); @@ -1997,14 +1997,14 @@ class StressTest { } else if (prefixBound <= prob_op && prob_op < writeBound) { // OPERATION write TestPut(thread, write_opts, read_opts, rand_column_families, rand_keys, - value, lock); + value, lock); } else if (writeBound <= prob_op && prob_op < delBound) { // OPERATION delete TestDelete(thread, write_opts, rand_column_families, rand_keys, lock); } else if (delBound <= prob_op && prob_op < delRangeBound) { // OPERATION delete range TestDeleteRange(thread, write_opts, rand_column_families, rand_keys, - lock); + lock); } else { // OPERATION iterate TestIterate(thread, read_opts, rand_column_families, rand_keys); @@ -2022,8 +2022,7 @@ class StressTest { virtual bool ShouldAcquireMutexOnKey() const { return false; } virtual std::vector GenerateColumnFamilies( - const int /* num_column_families */, - int rand_column_family) const { + const int /* num_column_families */, int rand_column_family) const { return {rand_column_family}; } diff --git a/tools/sst_dump_test.cc b/tools/sst_dump_test.cc index 17b59fd773c92bd8a9d20e5dab940a174e62cbb9..beab224d129ee54c4c543e384fa662f7e9c2ed55 100644 --- a/tools/sst_dump_test.cc +++ b/tools/sst_dump_test.cc @@ -59,7 +59,7 @@ void createSST(const std::string& file_name, std::vector > int_tbl_prop_collector_factories; std::unique_ptr file_writer( - new WritableFileWriter(std::move(file), EnvOptions())); + new WritableFileWriter(std::move(file), file_name, EnvOptions())); std::string column_family_name; int unknown_level = -1; tb.reset(opts.table_factory->NewTableBuilder( @@ -92,12 +92,11 @@ void cleanup(const std::string& file_name) { // Test for sst dump tool "raw" mode class SSTDumpToolTest : public testing::Test { std::string testDir_; -public: + + public: BlockBasedTableOptions table_options_; - SSTDumpToolTest() { - testDir_ = test::TmpDir(); - } + SSTDumpToolTest() { testDir_ = test::TmpDir(); } ~SSTDumpToolTest() {} @@ -107,9 +106,9 @@ public: return path; } - template + template void PopulateCommandArgs(const std::string& file_path, const char* command, - char* (&usage)[N]) const { + char* (&usage)[N]) const { for (int i = 0; i < static_cast(N); ++i) { usage[i] = new char[optLength]; } diff --git a/tools/sst_dump_tool.cc b/tools/sst_dump_tool.cc index f7a097a3a8e213e3680932dc5eb9991d884711bc..6ca56aad98c9c10e46311a6f4919b44fc6092678 100644 --- a/tools/sst_dump_tool.cc +++ b/tools/sst_dump_tool.cc @@ -163,7 +163,8 @@ uint64_t SstFileReader::CalculateCompressedTableSize( unique_ptr env(NewMemEnv(Env::Default())); env->NewWritableFile(testFileName, &out_file, soptions_); unique_ptr dest_writer; - dest_writer.reset(new WritableFileWriter(std::move(out_file), soptions_)); + 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); diff --git a/tools/trace_analyzer_test.cc b/tools/trace_analyzer_test.cc index 49cd31ba3b38af0efb038915d5da13cb6c1eca52..e29b5353202b9d90f56e56c3eb80bc4b8fd1f593 100644 --- a/tools/trace_analyzer_test.cc +++ b/tools/trace_analyzer_test.cc @@ -37,7 +37,7 @@ namespace rocksdb { namespace { static const int kMaxArgCount = 100; static const size_t kArgBufferSize = 100000; -} +} // namespace // The helper functions for the test class TraceAnalyzerTest : public testing::Test { @@ -77,7 +77,7 @@ class TraceAnalyzerTest : public testing::Test { ASSERT_OK(db_->Write(wo, &batch)); ASSERT_OK(db_->Get(ro, "a", &value)); - std::this_thread::sleep_for (std::chrono::seconds(1)); + std::this_thread::sleep_for(std::chrono::seconds(1)); db_->Get(ro, "g", &value); ASSERT_OK(db_->EndTrace()); diff --git a/tools/trace_analyzer_tool.cc b/tools/trace_analyzer_tool.cc index fc95b6a08f9a8f25af124ef0a4efcf00318b874e..e93a1426603bbaa4dd0355a5e504ab9b468fdb73 100644 --- a/tools/trace_analyzer_tool.cc +++ b/tools/trace_analyzer_tool.cc @@ -740,7 +740,8 @@ Status TraceAnalyzer::MakeStatisticCorrelation(TraceStats& stats, // Process the statistics of QPS Status TraceAnalyzer::MakeStatisticQPS() { - uint32_t duration = static_cast((end_time_ - begin_time_) / 1000000); + uint32_t duration = + static_cast((end_time_ - begin_time_) / 1000000); int ret; Status s; std::vector> type_qps( @@ -1794,5 +1795,5 @@ int trace_analyzer_tool(int argc, char** argv) { } } // namespace rocksdb -#endif // Endif of Gflag -#endif // RocksDB LITE +#endif // Endif of Gflag +#endif // RocksDB LITE diff --git a/util/coding.h b/util/coding.h index 27a638347f6e77924dad2468edceb0de9d56a2c6..4046a2b60bfb38c51326089ba1d3c0da8df503b2 100644 --- a/util/coding.h +++ b/util/coding.h @@ -64,7 +64,8 @@ extern Slice GetLengthPrefixedSlice(const char* data); extern Slice GetSliceUntil(Slice* slice, char delimiter); -// Borrowed from https://github.com/facebook/fbthrift/blob/449a5f77f9f9bae72c9eb5e78093247eef185c04/thrift/lib/cpp/util/VarintUtils-inl.h#L202-L208 +// Borrowed from +// https://github.com/facebook/fbthrift/blob/449a5f77f9f9bae72c9eb5e78093247eef185c04/thrift/lib/cpp/util/VarintUtils-inl.h#L202-L208 constexpr inline uint64_t i64ToZigzag(const int64_t l) { return (static_cast(l) << 1) ^ static_cast(l >> 63); } diff --git a/util/file_reader_writer.h b/util/file_reader_writer.h index 93155fa3c5acb7373031e2cce650ce8eb3732d35..a2c90f2b33040b776379091638a738bbb576161c 100644 --- a/util/file_reader_writer.h +++ b/util/file_reader_writer.h @@ -125,6 +125,7 @@ class RandomAccessFileReader { class WritableFileWriter { private: std::unique_ptr writable_file_; + std::string file_name_; AlignedBuffer buf_; size_t max_buffer_size_; // Actually written data size can be used for truncate @@ -144,8 +145,10 @@ class WritableFileWriter { public: WritableFileWriter(std::unique_ptr&& file, - const EnvOptions& options, Statistics* stats = nullptr) + const std::string& _file_name, const EnvOptions& options, + Statistics* stats = nullptr) : writable_file_(std::move(file)), + file_name_(_file_name), buf_(), max_buffer_size_(options.writable_file_max_buffer_size), filesize_(0), @@ -169,6 +172,8 @@ class WritableFileWriter { ~WritableFileWriter() { Close(); } + std::string file_name() const { return file_name_; } + Status Append(const Slice& data); Status Pad(const size_t pad_bytes); diff --git a/util/file_reader_writer_test.cc b/util/file_reader_writer_test.cc index 4425f87a0a1d4148bcc889845d62a792879a9ec3..3ca44ecc0959335dcede6854ad2c5032858a87de 100644 --- a/util/file_reader_writer_test.cc +++ b/util/file_reader_writer_test.cc @@ -73,7 +73,7 @@ TEST_F(WritableFileWriterTest, RangeSync) { env_options.bytes_per_sync = kMb; unique_ptr wf(new FakeWF); unique_ptr writer( - new WritableFileWriter(std::move(wf), env_options)); + new WritableFileWriter(std::move(wf), "" /* don't care */, env_options)); Random r(301); std::unique_ptr large_buf(new char[10 * kMb]); for (int i = 0; i < 1000; i++) { @@ -154,8 +154,8 @@ TEST_F(WritableFileWriterTest, IncrementalBuffer) { false, #endif no_flush)); - unique_ptr writer( - new WritableFileWriter(std::move(wf), env_options)); + unique_ptr writer(new WritableFileWriter( + std::move(wf), "" /* don't care */, env_options)); std::string target; for (int i = 0; i < 20; i++) { @@ -209,7 +209,7 @@ TEST_F(WritableFileWriterTest, AppendStatusReturn) { unique_ptr wf(new FakeWF()); wf->Setuse_direct_io(true); unique_ptr writer( - new WritableFileWriter(std::move(wf), EnvOptions())); + new WritableFileWriter(std::move(wf), "" /* don't care */, EnvOptions())); ASSERT_OK(writer->Append(std::string(2 * kMb, 'a'))); @@ -238,8 +238,9 @@ class ReadaheadRandomAccessFileTest return std::string(result.data(), result.size()); } void ResetSourceStr(const std::string& str = "") { - auto write_holder = std::unique_ptr( - test::GetWritableFileWriter(new test::StringSink(&control_contents_))); + auto write_holder = + std::unique_ptr(test::GetWritableFileWriter( + new test::StringSink(&control_contents_), "" /* don't care */)); write_holder->Append(Slice(str)); write_holder->Flush(); auto read_holder = std::unique_ptr( diff --git a/util/file_util.cc b/util/file_util.cc index ee8b3fb53717109332a05df2d718eacc70176add..79ba83716972308277c5955dbe82e9b4bd9aa25f 100644 --- a/util/file_util.cc +++ b/util/file_util.cc @@ -42,7 +42,8 @@ Status CopyFile(Env* env, const std::string& source, } } src_reader.reset(new SequentialFileReader(std::move(srcfile), source)); - dest_writer.reset(new WritableFileWriter(std::move(destfile), soptions)); + dest_writer.reset( + new WritableFileWriter(std::move(destfile), destination, soptions)); } char buffer[4096]; @@ -77,7 +78,8 @@ Status CreateFile(Env* env, const std::string& destination, if (!s.ok()) { return s; } - dest_writer.reset(new WritableFileWriter(std::move(destfile), soptions)); + dest_writer.reset( + new WritableFileWriter(std::move(destfile), destination, soptions)); return dest_writer->Append(Slice(contents)); } diff --git a/util/testutil.cc b/util/testutil.cc index 6094d7ba0a57acd940478ecd6805bb2564abf92e..0983f759ce96fc5268339a9862e73c8ea0b904d2 100644 --- a/util/testutil.cc +++ b/util/testutil.cc @@ -124,9 +124,10 @@ const Comparator* Uint64Comparator() { return &uint64comp; } -WritableFileWriter* GetWritableFileWriter(WritableFile* wf) { +WritableFileWriter* GetWritableFileWriter(WritableFile* wf, + const std::string& fname) { unique_ptr file(wf); - return new WritableFileWriter(std::move(file), EnvOptions()); + return new WritableFileWriter(std::move(file), fname, EnvOptions()); } RandomAccessFileReader* GetRandomAccessFileReader(RandomAccessFile* raf) { diff --git a/util/testutil.h b/util/testutil.h index ffdaa5ad60ac9642820db23388616efd8dc965ae..7b43da6c73b380d2efed0ff0ba5a320816e70287 100644 --- a/util/testutil.h +++ b/util/testutil.h @@ -183,7 +183,8 @@ class VectorIterator : public InternalIterator { std::vector values_; size_t current_; }; -extern WritableFileWriter* GetWritableFileWriter(WritableFile* wf); +extern WritableFileWriter* GetWritableFileWriter(WritableFile* wf, + const std::string& fname); extern RandomAccessFileReader* GetRandomAccessFileReader(RandomAccessFile* raf); diff --git a/utilities/backupable/backupable_db.cc b/utilities/backupable/backupable_db.cc index efc73b236c663d6a1cee31a5e6b58f1ec76b1fad..73ca39b7079938a4adeebae936556800b05ac846 100644 --- a/utilities/backupable/backupable_db.cc +++ b/utilities/backupable/backupable_db.cc @@ -1214,7 +1214,7 @@ Status BackupEngineImpl::CopyOrCreateFile( } unique_ptr dest_writer( - new WritableFileWriter(std::move(dst_file), env_options)); + new WritableFileWriter(std::move(dst_file), dst, env_options)); unique_ptr src_reader; unique_ptr buf; if (!src.empty()) { diff --git a/utilities/blob_db/blob_db_impl.cc b/utilities/blob_db/blob_db_impl.cc index 6426612fd3b47b882d987e067abc7188f1878148..ea176369f1466592f92e5ec51a6e46eab761520b 100644 --- a/utilities/blob_db/blob_db_impl.cc +++ b/utilities/blob_db/blob_db_impl.cc @@ -338,7 +338,7 @@ Status BlobDBImpl::CreateWriterLocked(const std::shared_ptr& bfile) { } std::unique_ptr fwriter; - fwriter.reset(new WritableFileWriter(std::move(wfile), env_options_)); + fwriter.reset(new WritableFileWriter(std::move(wfile), fpath, env_options_)); uint64_t boffset = bfile->GetFileSize(); if (debug_level_ >= 2 && boffset) { @@ -562,8 +562,8 @@ class BlobDBImpl::BlobInserter : public WriteBatch::Handler { return Status::NotSupported( "Blob DB doesn't support non-default column family."); } - Status s = blob_db_impl_->PutBlobValue(options_, key, value, - kNoExpiration, &batch_); + Status s = blob_db_impl_->PutBlobValue(options_, key, value, kNoExpiration, + &batch_); return s; } diff --git a/utilities/env_mirror.cc b/utilities/env_mirror.cc index e4da918346becf0d10b78a6ab96ebe9fc0d3ac0a..d14de97d00d1f3fd6c3612184fb0b4f74709d688 100644 --- a/utilities/env_mirror.cc +++ b/utilities/env_mirror.cc @@ -64,7 +64,8 @@ class RandomAccessFileMirror : public RandomAccessFile { std::string fname; explicit RandomAccessFileMirror(std::string f) : fname(f) {} - Status Read(uint64_t offset, size_t n, Slice* result, char* scratch) const override { + Status Read(uint64_t offset, size_t n, Slice* result, + char* scratch) const override { Status as = a_->Read(offset, n, result, scratch); if (as == Status::OK()) { char* bscratch = new char[n]; diff --git a/utilities/simulator_cache/sim_cache.cc b/utilities/simulator_cache/sim_cache.cc index e7750dd5e27d05224677c2b65d8dd470d68f152c..bdf6c5aa8792f9a3cc747e738a91abafb812d924 100644 --- a/utilities/simulator_cache/sim_cache.cc +++ b/utilities/simulator_cache/sim_cache.cc @@ -46,7 +46,8 @@ class CacheActivityLogger { if (!status.ok()) { return status; } - file_writer_.reset(new WritableFileWriter(std::move(log_file), env_opts)); + file_writer_.reset(new WritableFileWriter(std::move(log_file), + activity_log_file, env_opts)); max_logging_size_ = max_logging_size; activity_logging_enabled_.store(true); diff --git a/utilities/trace/file_trace_reader_writer.cc b/utilities/trace/file_trace_reader_writer.cc index dde36aa93c561e5b13346dbab952c4e768f6b6a2..36baefc7bc25b7783cbc371ba13c6a74779cedfe 100644 --- a/utilities/trace/file_trace_reader_writer.cc +++ b/utilities/trace/file_trace_reader_writer.cc @@ -109,7 +109,8 @@ Status NewFileTraceWriter(Env* env, const EnvOptions& env_options, } unique_ptr file_writer; - file_writer.reset(new WritableFileWriter(std::move(trace_file), env_options)); + file_writer.reset(new WritableFileWriter(std::move(trace_file), + trace_filename, env_options)); trace_writer->reset(new FileTraceWriter(std::move(file_writer))); return s; }