Skip to content

Commit c57050b

Browse files
Maysam Yabandehfacebook-github-bot
authored andcommitted
Use the default copy constructor in Options
Summary: Our current implementation of (semi-)copy constructor of DBOptions and ColumnFamilyOptions seems to intend value by value copy, which is what the default copy constructor does anyway. Moreover not using the default constructor has the risk of forgetting to add newly added options. As an example, allow_2pc seems to be forgotten in the copy constructor which was causing one of the unit tests not seeing its effect. Closes #2888 Differential Revision: D5846368 Pulled By: maysamyabandeh fbshipit-source-id: 1ee92a2aeae93886754b7bc039c3411ea2458683
1 parent c319792 commit c57050b

File tree

2 files changed

+3
-94
lines changed

2 files changed

+3
-94
lines changed

db/db_wal_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ TEST_F(DBWALTest, AvoidFlushDuringRecovery) {
10071007
Reopen(options);
10081008
ASSERT_EQ("v11", Get("foo"));
10091009
ASSERT_EQ("v12", Get("bar"));
1010-
ASSERT_EQ(2, TotalTableFiles());
1010+
ASSERT_EQ(3, TotalTableFiles());
10111011
}
10121012

10131013
TEST_F(DBWALTest, WalCleanupAfterAvoidFlushDuringRecovery) {

options/options.cc

Lines changed: 2 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -99,102 +99,11 @@ ColumnFamilyOptions::ColumnFamilyOptions()
9999
std::shared_ptr<TableFactory>(new BlockBasedTableFactory())) {}
100100

101101
ColumnFamilyOptions::ColumnFamilyOptions(const Options& options)
102-
: AdvancedColumnFamilyOptions(options),
103-
comparator(options.comparator),
104-
merge_operator(options.merge_operator),
105-
compaction_filter(options.compaction_filter),
106-
compaction_filter_factory(options.compaction_filter_factory),
107-
write_buffer_size(options.write_buffer_size),
108-
compression(options.compression),
109-
bottommost_compression(options.bottommost_compression),
110-
compression_opts(options.compression_opts),
111-
level0_file_num_compaction_trigger(
112-
options.level0_file_num_compaction_trigger),
113-
prefix_extractor(options.prefix_extractor),
114-
max_bytes_for_level_base(options.max_bytes_for_level_base),
115-
disable_auto_compactions(options.disable_auto_compactions),
116-
table_factory(options.table_factory) {}
102+
: ColumnFamilyOptions(*static_cast<const ColumnFamilyOptions*>(&options)) {}
117103

118104
DBOptions::DBOptions() {}
119-
120105
DBOptions::DBOptions(const Options& options)
121-
: create_if_missing(options.create_if_missing),
122-
create_missing_column_families(options.create_missing_column_families),
123-
error_if_exists(options.error_if_exists),
124-
paranoid_checks(options.paranoid_checks),
125-
env(options.env),
126-
rate_limiter(options.rate_limiter),
127-
sst_file_manager(options.sst_file_manager),
128-
info_log(options.info_log),
129-
info_log_level(options.info_log_level),
130-
max_open_files(options.max_open_files),
131-
max_file_opening_threads(options.max_file_opening_threads),
132-
max_total_wal_size(options.max_total_wal_size),
133-
statistics(options.statistics),
134-
use_fsync(options.use_fsync),
135-
db_paths(options.db_paths),
136-
db_log_dir(options.db_log_dir),
137-
wal_dir(options.wal_dir),
138-
delete_obsolete_files_period_micros(
139-
options.delete_obsolete_files_period_micros),
140-
max_background_jobs(options.max_background_jobs),
141-
base_background_compactions(options.base_background_compactions),
142-
max_background_compactions(options.max_background_compactions),
143-
max_subcompactions(options.max_subcompactions),
144-
max_background_flushes(options.max_background_flushes),
145-
max_log_file_size(options.max_log_file_size),
146-
log_file_time_to_roll(options.log_file_time_to_roll),
147-
keep_log_file_num(options.keep_log_file_num),
148-
recycle_log_file_num(options.recycle_log_file_num),
149-
max_manifest_file_size(options.max_manifest_file_size),
150-
table_cache_numshardbits(options.table_cache_numshardbits),
151-
WAL_ttl_seconds(options.WAL_ttl_seconds),
152-
WAL_size_limit_MB(options.WAL_size_limit_MB),
153-
manifest_preallocation_size(options.manifest_preallocation_size),
154-
allow_mmap_reads(options.allow_mmap_reads),
155-
allow_mmap_writes(options.allow_mmap_writes),
156-
use_direct_reads(options.use_direct_reads),
157-
use_direct_io_for_flush_and_compaction(
158-
options.use_direct_io_for_flush_and_compaction),
159-
allow_fallocate(options.allow_fallocate),
160-
is_fd_close_on_exec(options.is_fd_close_on_exec),
161-
skip_log_error_on_recovery(options.skip_log_error_on_recovery),
162-
stats_dump_period_sec(options.stats_dump_period_sec),
163-
advise_random_on_open(options.advise_random_on_open),
164-
db_write_buffer_size(options.db_write_buffer_size),
165-
write_buffer_manager(options.write_buffer_manager),
166-
access_hint_on_compaction_start(options.access_hint_on_compaction_start),
167-
new_table_reader_for_compaction_inputs(
168-
options.new_table_reader_for_compaction_inputs),
169-
compaction_readahead_size(options.compaction_readahead_size),
170-
random_access_max_buffer_size(options.random_access_max_buffer_size),
171-
writable_file_max_buffer_size(options.writable_file_max_buffer_size),
172-
use_adaptive_mutex(options.use_adaptive_mutex),
173-
bytes_per_sync(options.bytes_per_sync),
174-
wal_bytes_per_sync(options.wal_bytes_per_sync),
175-
listeners(options.listeners),
176-
enable_thread_tracking(options.enable_thread_tracking),
177-
delayed_write_rate(options.delayed_write_rate),
178-
enable_pipelined_write(options.enable_pipelined_write),
179-
allow_concurrent_memtable_write(options.allow_concurrent_memtable_write),
180-
enable_write_thread_adaptive_yield(
181-
options.enable_write_thread_adaptive_yield),
182-
write_thread_max_yield_usec(options.write_thread_max_yield_usec),
183-
write_thread_slow_yield_usec(options.write_thread_slow_yield_usec),
184-
skip_stats_update_on_db_open(options.skip_stats_update_on_db_open),
185-
wal_recovery_mode(options.wal_recovery_mode),
186-
row_cache(options.row_cache),
187-
#ifndef ROCKSDB_LITE
188-
wal_filter(options.wal_filter),
189-
#endif // ROCKSDB_LITE
190-
fail_if_options_file_error(options.fail_if_options_file_error),
191-
dump_malloc_stats(options.dump_malloc_stats),
192-
avoid_flush_during_recovery(options.avoid_flush_during_recovery),
193-
avoid_flush_during_shutdown(options.avoid_flush_during_shutdown),
194-
allow_ingest_behind(options.allow_ingest_behind),
195-
concurrent_prepare(options.concurrent_prepare),
196-
manual_wal_flush(options.manual_wal_flush) {
197-
}
106+
: DBOptions(*static_cast<const DBOptions*>(&options)) {}
198107

199108
void DBOptions::Dump(Logger* log) const {
200109
ImmutableDBOptions(*this).Dump(log);

0 commit comments

Comments
 (0)