Skip to content

Commit 9b0f7ff

Browse files
author
Lei Jin
committed
rename version_set options_ to db_options_ to avoid confusion
Summary: as title Test Plan: make release Reviewers: sdong, yhchiang, igor Reviewed By: igor Subscribers: leveldb Differential Revision: https://reviews.facebook.net/D23007
1 parent 2d57828 commit 9b0f7ff

File tree

2 files changed

+64
-62
lines changed

2 files changed

+64
-62
lines changed

db/version_set.cc

+53-51
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ Status Version::GetTableProperties(std::shared_ptr<const TableProperties>* tp,
514514
auto table_cache = cfd_->table_cache();
515515
auto ioptions = cfd_->ioptions();
516516
Status s = table_cache->GetTableProperties(
517-
vset_->storage_options_, cfd_->internal_comparator(), file_meta->fd,
517+
vset_->env_options_, cfd_->internal_comparator(), file_meta->fd,
518518
tp, true /* no io */);
519519
if (s.ok()) {
520520
return s;
@@ -531,12 +531,12 @@ Status Version::GetTableProperties(std::shared_ptr<const TableProperties>* tp,
531531
std::unique_ptr<RandomAccessFile> file;
532532
if (fname != nullptr) {
533533
s = ioptions->env->NewRandomAccessFile(
534-
*fname, &file, vset_->storage_options_);
534+
*fname, &file, vset_->env_options_);
535535
} else {
536536
s = ioptions->env->NewRandomAccessFile(
537-
TableFileName(vset_->options_->db_paths, file_meta->fd.GetNumber(),
537+
TableFileName(vset_->db_options_->db_paths, file_meta->fd.GetNumber(),
538538
file_meta->fd.GetPathId()),
539-
&file, vset_->storage_options_);
539+
&file, vset_->env_options_);
540540
}
541541
if (!s.ok()) {
542542
return s;
@@ -562,7 +562,7 @@ Status Version::GetPropertiesOfAllTables(TablePropertiesCollection* props) {
562562
for (int level = 0; level < num_levels_; level++) {
563563
for (const auto& file_meta : files_[level]) {
564564
auto fname =
565-
TableFileName(vset_->options_->db_paths, file_meta->fd.GetNumber(),
565+
TableFileName(vset_->db_options_->db_paths, file_meta->fd.GetNumber(),
566566
file_meta->fd.GetPathId());
567567
// 1. If the table is already present in table cache, load table
568568
// properties from there.
@@ -584,7 +584,7 @@ size_t Version::GetMemoryUsageByTableReaders() {
584584
for (auto& file_level : file_levels_) {
585585
for (size_t i = 0; i < file_level.num_files; i++) {
586586
total_usage += cfd_->table_cache()->GetMemoryUsageByTableReader(
587-
vset_->storage_options_, cfd_->internal_comparator(),
587+
vset_->env_options_, cfd_->internal_comparator(),
588588
file_level.files[i].fd);
589589
}
590590
}
@@ -864,7 +864,7 @@ bool Version::MaybeInitializeFileMetaData(FileMetaData* file_meta) {
864864
Status s = GetTableProperties(&tp, file_meta);
865865
file_meta->init_stats_from_file = true;
866866
if (!s.ok()) {
867-
Log(vset_->options_->info_log,
867+
Log(vset_->db_options_->info_log,
868868
"Unable to load table properties for file %" PRIu64 " --- %s\n",
869869
file_meta->fd.GetNumber(), s.ToString().c_str());
870870
return false;
@@ -1677,7 +1677,7 @@ class VersionSet::Builder {
16771677
for (auto& file_meta : *(levels_[level].added_files)) {
16781678
assert (!file_meta->table_reader_handle);
16791679
cfd_->table_cache()->FindTable(
1680-
base_->vset_->storage_options_, cfd_->internal_comparator(),
1680+
base_->vset_->env_options_, cfd_->internal_comparator(),
16811681
file_meta->fd, &file_meta->table_reader_handle, false);
16821682
if (file_meta->table_reader_handle != nullptr) {
16831683
// Load table_reader
@@ -1705,23 +1705,23 @@ class VersionSet::Builder {
17051705
}
17061706
};
17071707

1708-
VersionSet::VersionSet(const std::string& dbname, const DBOptions* options,
1709-
const EnvOptions& storage_options, Cache* table_cache,
1708+
VersionSet::VersionSet(const std::string& dbname, const DBOptions* db_options,
1709+
const EnvOptions& env_options, Cache* table_cache,
17101710
WriteController* write_controller)
1711-
: column_family_set_(new ColumnFamilySet(dbname, options, storage_options,
1711+
: column_family_set_(new ColumnFamilySet(dbname, db_options, env_options,
17121712
table_cache, write_controller)),
1713-
env_(options->env),
1713+
env_(db_options->env),
17141714
dbname_(dbname),
1715-
options_(options),
1715+
db_options_(db_options),
17161716
next_file_number_(2),
17171717
manifest_file_number_(0), // Filled by Recover()
17181718
pending_manifest_file_number_(0),
17191719
last_sequence_(0),
17201720
prev_log_number_(0),
17211721
current_version_number_(0),
17221722
manifest_file_size_(0),
1723-
storage_options_(storage_options),
1724-
storage_options_compactions_(storage_options_) {}
1723+
env_options_(env_options),
1724+
env_options_compactions_(env_options_) {}
17251725

17261726
VersionSet::~VersionSet() {
17271727
// we need to delete column_family_set_ because its destructor depends on
@@ -1823,7 +1823,7 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,
18231823

18241824
assert(pending_manifest_file_number_ == 0);
18251825
if (!descriptor_log_ ||
1826-
manifest_file_size_ > options_->max_manifest_file_size) {
1826+
manifest_file_size_ > db_options_->max_manifest_file_size) {
18271827
pending_manifest_file_number_ = NewFileNumber();
18281828
batch_edits.back()->SetNextFile(next_file_number_);
18291829
new_descriptor_log = true;
@@ -1851,7 +1851,8 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,
18511851

18521852
mu->Unlock();
18531853

1854-
if (!edit->IsColumnFamilyManipulation() && options_->max_open_files == -1) {
1854+
if (!edit->IsColumnFamilyManipulation() &&
1855+
db_options_->max_open_files == -1) {
18551856
// unlimited table cache. Pre-load table handle now.
18561857
// Need to do it out of the mutex.
18571858
builder->LoadTableHandlers();
@@ -1861,15 +1862,15 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,
18611862
// only one thread can be here at the same time
18621863
if (new_descriptor_log) {
18631864
// create manifest file
1864-
Log(options_->info_log,
1865+
Log(db_options_->info_log,
18651866
"Creating manifest %" PRIu64 "\n", pending_manifest_file_number_);
18661867
unique_ptr<WritableFile> descriptor_file;
18671868
s = env_->NewWritableFile(
18681869
DescriptorFileName(dbname_, pending_manifest_file_number_),
1869-
&descriptor_file, env_->OptimizeForManifestWrite(storage_options_));
1870+
&descriptor_file, env_->OptimizeForManifestWrite(env_options_));
18701871
if (s.ok()) {
18711872
descriptor_file->SetPreallocationBlockSize(
1872-
options_->manifest_preallocation_size);
1873+
db_options_->manifest_preallocation_size);
18731874
descriptor_log_.reset(new log::Writer(std::move(descriptor_file)));
18741875
s = WriteSnapshot(descriptor_log_.get());
18751876
}
@@ -1891,18 +1892,19 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,
18911892
}
18921893
}
18931894
if (s.ok()) {
1894-
if (options_->use_fsync) {
1895-
StopWatch sw(env_, options_->statistics.get(),
1895+
if (db_options_->use_fsync) {
1896+
StopWatch sw(env_, db_options_->statistics.get(),
18961897
MANIFEST_FILE_SYNC_MICROS);
18971898
s = descriptor_log_->file()->Fsync();
18981899
} else {
1899-
StopWatch sw(env_, options_->statistics.get(),
1900+
StopWatch sw(env_, db_options_->statistics.get(),
19001901
MANIFEST_FILE_SYNC_MICROS);
19011902
s = descriptor_log_->file()->Sync();
19021903
}
19031904
}
19041905
if (!s.ok()) {
1905-
Log(options_->info_log, "MANIFEST write: %s\n", s.ToString().c_str());
1906+
Log(db_options_->info_log, "MANIFEST write: %s\n",
1907+
s.ToString().c_str());
19061908
bool all_records_in = true;
19071909
for (auto& e : batch_edits) {
19081910
std::string record;
@@ -1913,7 +1915,7 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,
19131915
}
19141916
}
19151917
if (all_records_in) {
1916-
Log(options_->info_log,
1918+
Log(db_options_->info_log,
19171919
"MANIFEST contains log record despite error; advancing to new "
19181920
"version to prevent mismatch between in-memory and logged state"
19191921
" If paranoid is set, then the db is now in readonly mode.");
@@ -1929,7 +1931,7 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,
19291931
db_directory);
19301932
if (s.ok() && pending_manifest_file_number_ > manifest_file_number_) {
19311933
// delete old manifest file
1932-
Log(options_->info_log,
1934+
Log(db_options_->info_log,
19331935
"Deleting manifest %" PRIu64 " current manifest %" PRIu64 "\n",
19341936
manifest_file_number_, pending_manifest_file_number_);
19351937
// we don't care about an error here, PurgeObsoleteFiles will take care
@@ -1943,7 +1945,7 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,
19431945
new_manifest_file_size = descriptor_log_->file()->GetFileSize();
19441946
}
19451947

1946-
LogFlush(options_->info_log);
1948+
LogFlush(db_options_->info_log);
19471949
mu->Lock();
19481950
}
19491951

@@ -1979,12 +1981,12 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,
19791981
manifest_file_size_ = new_manifest_file_size;
19801982
prev_log_number_ = edit->prev_log_number_;
19811983
} else {
1982-
Log(options_->info_log, "Error in committing version %lu to [%s]",
1984+
Log(db_options_->info_log, "Error in committing version %lu to [%s]",
19831985
(unsigned long)v->GetVersionNumber(),
19841986
column_family_data->GetName().c_str());
19851987
delete v;
19861988
if (new_descriptor_log) {
1987-
Log(options_->info_log,
1989+
Log(db_options_->info_log,
19881990
"Deleting manifest %" PRIu64 " current manifest %" PRIu64 "\n",
19891991
manifest_file_number_, pending_manifest_file_number_);
19901992
descriptor_log_.reset();
@@ -2076,13 +2078,13 @@ Status VersionSet::Recover(
20762078
return Status::Corruption("CURRENT file corrupted");
20772079
}
20782080

2079-
Log(options_->info_log, "Recovering from manifest file: %s\n",
2081+
Log(db_options_->info_log, "Recovering from manifest file: %s\n",
20802082
manifest_filename.c_str());
20812083

20822084
manifest_filename = dbname_ + "/" + manifest_filename;
20832085
unique_ptr<SequentialFile> manifest_file;
20842086
s = env_->NewSequentialFile(manifest_filename, &manifest_file,
2085-
storage_options_);
2087+
env_options_);
20862088
if (!s.ok()) {
20872089
return s;
20882090
}
@@ -2209,7 +2211,7 @@ Status VersionSet::Recover(
22092211
if (cfd != nullptr) {
22102212
if (edit.has_log_number_) {
22112213
if (cfd->GetLogNumber() > edit.log_number_) {
2212-
Log(options_->info_log,
2214+
Log(db_options_->info_log,
22132215
"MANIFEST corruption detected, but ignored - Log numbers in "
22142216
"records NOT monotonically increasing");
22152217
} else {
@@ -2285,7 +2287,7 @@ Status VersionSet::Recover(
22852287
assert(builders_iter != builders.end());
22862288
auto builder = builders_iter->second;
22872289

2288-
if (options_->max_open_files == -1) {
2290+
if (db_options_->max_open_files == -1) {
22892291
// unlimited table cache. Pre-load table handle now.
22902292
// Need to do it out of the mutex.
22912293
builder->LoadTableHandlers();
@@ -2306,7 +2308,7 @@ Status VersionSet::Recover(
23062308
last_sequence_ = last_sequence;
23072309
prev_log_number_ = prev_log_number;
23082310

2309-
Log(options_->info_log,
2311+
Log(db_options_->info_log,
23102312
"Recovered from manifest file:%s succeeded,"
23112313
"manifest_file_number is %lu, next_file_number is %lu, "
23122314
"last_sequence is %lu, log_number is %lu,"
@@ -2318,7 +2320,7 @@ Status VersionSet::Recover(
23182320
column_family_set_->GetMaxColumnFamily());
23192321

23202322
for (auto cfd : *column_family_set_) {
2321-
Log(options_->info_log,
2323+
Log(db_options_->info_log,
23222324
"Column family [%s] (ID %u), log number is %" PRIu64 "\n",
23232325
cfd->GetName().c_str(), cfd->GetID(), cfd->GetLogNumber());
23242326
}
@@ -2401,7 +2403,7 @@ Status VersionSet::ListColumnFamilies(std::vector<std::string>* column_families,
24012403
#ifndef ROCKSDB_LITE
24022404
Status VersionSet::ReduceNumberOfLevels(const std::string& dbname,
24032405
const Options* options,
2404-
const EnvOptions& storage_options,
2406+
const EnvOptions& env_options,
24052407
int new_levels) {
24062408
if (new_levels <= 1) {
24072409
return Status::InvalidArgument(
@@ -2413,7 +2415,7 @@ Status VersionSet::ReduceNumberOfLevels(const std::string& dbname,
24132415
options->max_open_files - 10, options->table_cache_numshardbits,
24142416
options->table_cache_remove_scan_count_limit));
24152417
WriteController wc;
2416-
VersionSet versions(dbname, options, storage_options, tc.get(), &wc);
2418+
VersionSet versions(dbname, options, env_options, tc.get(), &wc);
24172419
Status status;
24182420

24192421
std::vector<ColumnFamilyDescriptor> dummy;
@@ -2484,7 +2486,7 @@ Status VersionSet::DumpManifest(Options& options, std::string& dscname,
24842486
bool verbose, bool hex) {
24852487
// Open the specified manifest file.
24862488
unique_ptr<SequentialFile> file;
2487-
Status s = options.env->NewSequentialFile(dscname, &file, storage_options_);
2489+
Status s = options.env->NewSequentialFile(dscname, &file, env_options_);
24882490
if (!s.ok()) {
24892491
return s;
24902492
}
@@ -2726,12 +2728,12 @@ bool VersionSet::ManifestContains(uint64_t manifest_file_number,
27262728
const std::string& record) const {
27272729
std::string fname =
27282730
DescriptorFileName(dbname_, manifest_file_number);
2729-
Log(options_->info_log, "ManifestContains: checking %s\n", fname.c_str());
2731+
Log(db_options_->info_log, "ManifestContains: checking %s\n", fname.c_str());
27302732
unique_ptr<SequentialFile> file;
2731-
Status s = env_->NewSequentialFile(fname, &file, storage_options_);
2733+
Status s = env_->NewSequentialFile(fname, &file, env_options_);
27322734
if (!s.ok()) {
2733-
Log(options_->info_log, "ManifestContains: %s\n", s.ToString().c_str());
2734-
Log(options_->info_log,
2735+
Log(db_options_->info_log, "ManifestContains: %s\n", s.ToString().c_str());
2736+
Log(db_options_->info_log,
27352737
"ManifestContains: is unable to reopen the manifest file %s",
27362738
fname.c_str());
27372739
return false;
@@ -2746,7 +2748,7 @@ bool VersionSet::ManifestContains(uint64_t manifest_file_number,
27462748
break;
27472749
}
27482750
}
2749-
Log(options_->info_log, "ManifestContains: result = %d\n", result ? 1 : 0);
2751+
Log(db_options_->info_log, "ManifestContains: result = %d\n", result ? 1 : 0);
27502752
return result;
27512753
}
27522754

@@ -2774,7 +2776,7 @@ uint64_t VersionSet::ApproximateOffsetOf(Version* v, const InternalKey& ikey) {
27742776
// approximate offset of "ikey" within the table.
27752777
TableReader* table_reader_ptr;
27762778
Iterator* iter = v->cfd_->table_cache()->NewIterator(
2777-
ReadOptions(), storage_options_, v->cfd_->internal_comparator(),
2779+
ReadOptions(), env_options_, v->cfd_->internal_comparator(),
27782780
files[i]->fd, &table_reader_ptr);
27792781
if (table_reader_ptr != nullptr) {
27802782
result += table_reader_ptr->ApproximateOffsetOf(ikey.Encode());
@@ -2836,14 +2838,14 @@ Iterator* VersionSet::MakeInputIterator(Compaction* c) {
28362838
const FileLevel* flevel = c->input_levels(which);
28372839
for (size_t i = 0; i < flevel->num_files; i++) {
28382840
list[num++] = cfd->table_cache()->NewIterator(
2839-
read_options, storage_options_compactions_,
2841+
read_options, env_options_compactions_,
28402842
cfd->internal_comparator(), flevel->files[i].fd, nullptr,
28412843
true /* for compaction */);
28422844
}
28432845
} else {
28442846
// Create concatenating iterator for the files from this level
28452847
list[num++] = NewTwoLevelIterator(new Version::LevelFileIteratorState(
2846-
cfd->table_cache(), read_options, storage_options_,
2848+
cfd->table_cache(), read_options, env_options_,
28472849
cfd->internal_comparator(), true /* for_compaction */,
28482850
false /* prefix enabled */),
28492851
new Version::LevelFileNumIterator(cfd->internal_comparator(),
@@ -2864,7 +2866,7 @@ bool VersionSet::VerifyCompactionFileConsistency(Compaction* c) {
28642866
#ifndef NDEBUG
28652867
Version* version = c->column_family_data()->current();
28662868
if (c->input_version() != version) {
2867-
Log(options_->info_log,
2869+
Log(db_options_->info_log,
28682870
"[%s] VerifyCompactionFileConsistency version mismatch",
28692871
c->column_family_data()->GetName().c_str());
28702872
}
@@ -2935,11 +2937,11 @@ void VersionSet::GetLiveFilesMetaData(std::vector<LiveFileMetaData>* metadata) {
29352937
LiveFileMetaData filemetadata;
29362938
filemetadata.column_family_name = cfd->GetName();
29372939
uint32_t path_id = file->fd.GetPathId();
2938-
if (path_id < options_->db_paths.size()) {
2939-
filemetadata.db_path = options_->db_paths[path_id].path;
2940+
if (path_id < db_options_->db_paths.size()) {
2941+
filemetadata.db_path = db_options_->db_paths[path_id].path;
29402942
} else {
2941-
assert(!options_->db_paths.empty());
2942-
filemetadata.db_path = options_->db_paths.back().path;
2943+
assert(!db_options_->db_paths.empty());
2944+
filemetadata.db_path = db_options_->db_paths.back().path;
29432945
}
29442946
filemetadata.name = MakeTableFileName("", file->fd.GetNumber());
29452947
filemetadata.level = level;

0 commit comments

Comments
 (0)