call SanitizeDBOptionsByCFOptions() in the right place
Summary: It only covers Open() with default column family right now Test Plan: make release Reviewers: igor, yhchiang, sdong Reviewed By: sdong Subscribers: leveldb Differential Revision: https://reviews.facebook.net/D22467
This commit is contained in:
parent
a84234a61b
commit
9b58c73c7c
@ -290,8 +290,10 @@ DBOptions SanitizeOptions(const std::string& dbname, const DBOptions& src) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
Status SanitizeDBOptionsByCFOptions(
|
Status SanitizeDBOptionsByCFOptions(
|
||||||
DBOptions* db_opts,
|
const DBOptions* db_opts,
|
||||||
const std::vector<ColumnFamilyDescriptor>& column_families) {
|
const std::vector<ColumnFamilyDescriptor>& column_families) {
|
||||||
Status s;
|
Status s;
|
||||||
for (auto cf : column_families) {
|
for (auto cf : column_families) {
|
||||||
@ -303,7 +305,6 @@ Status SanitizeDBOptionsByCFOptions(
|
|||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
CompressionType GetCompressionFlush(const Options& options) {
|
CompressionType GetCompressionFlush(const Options& options) {
|
||||||
// Compressing memtable flushes might not help unless the sequential load
|
// Compressing memtable flushes might not help unless the sequential load
|
||||||
// optimization is used for leveled compaction. Otherwise the CPU and
|
// optimization is used for leveled compaction. Otherwise the CPU and
|
||||||
@ -4802,11 +4803,7 @@ Status DB::Open(const Options& options, const std::string& dbname, DB** dbptr) {
|
|||||||
column_families.push_back(
|
column_families.push_back(
|
||||||
ColumnFamilyDescriptor(kDefaultColumnFamilyName, cf_options));
|
ColumnFamilyDescriptor(kDefaultColumnFamilyName, cf_options));
|
||||||
std::vector<ColumnFamilyHandle*> handles;
|
std::vector<ColumnFamilyHandle*> handles;
|
||||||
Status s = SanitizeDBOptionsByCFOptions(&db_options, column_families);
|
Status s = DB::Open(db_options, dbname, column_families, &handles, dbptr);
|
||||||
if (!s.ok()) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
s = DB::Open(db_options, dbname, column_families, &handles, dbptr);
|
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
assert(handles.size() == 1);
|
assert(handles.size() == 1);
|
||||||
// i can delete the handle since DBImpl is always holding a reference to
|
// i can delete the handle since DBImpl is always holding a reference to
|
||||||
@ -4819,6 +4816,10 @@ Status DB::Open(const Options& options, const std::string& dbname, DB** dbptr) {
|
|||||||
Status DB::Open(const DBOptions& db_options, const std::string& dbname,
|
Status DB::Open(const DBOptions& db_options, const std::string& dbname,
|
||||||
const std::vector<ColumnFamilyDescriptor>& column_families,
|
const std::vector<ColumnFamilyDescriptor>& column_families,
|
||||||
std::vector<ColumnFamilyHandle*>* handles, DB** dbptr) {
|
std::vector<ColumnFamilyHandle*>* handles, DB** dbptr) {
|
||||||
|
Status s = SanitizeDBOptionsByCFOptions(&db_options, column_families);
|
||||||
|
if (!s.ok()) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
if (db_options.db_paths.size() > 1) {
|
if (db_options.db_paths.size() > 1) {
|
||||||
for (auto& cfd : column_families) {
|
for (auto& cfd : column_families) {
|
||||||
if (cfd.options.compaction_style != kCompactionStyleUniversal) {
|
if (cfd.options.compaction_style != kCompactionStyleUniversal) {
|
||||||
@ -4844,7 +4845,7 @@ Status DB::Open(const DBOptions& db_options, const std::string& dbname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
DBImpl* impl = new DBImpl(db_options, dbname);
|
DBImpl* impl = new DBImpl(db_options, dbname);
|
||||||
Status s = impl->env_->CreateDirIfMissing(impl->options_.wal_dir);
|
s = impl->env_->CreateDirIfMissing(impl->options_.wal_dir);
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
for (auto db_path : impl->options_.db_paths) {
|
for (auto db_path : impl->options_.db_paths) {
|
||||||
s = impl->env_->CreateDirIfMissing(db_path.path);
|
s = impl->env_->CreateDirIfMissing(db_path.path);
|
||||||
|
@ -556,7 +556,7 @@ public:
|
|||||||
WritableFile* file,
|
WritableFile* file,
|
||||||
CompressionType compression_type) const;
|
CompressionType compression_type) const;
|
||||||
|
|
||||||
virtual Status SanitizeDBOptions(DBOptions* db_opts) const override {
|
virtual Status SanitizeDBOptions(const DBOptions* db_opts) const override {
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ class TableFactory {
|
|||||||
//
|
//
|
||||||
// If the function cannot find a way to sanitize the input DB Options,
|
// If the function cannot find a way to sanitize the input DB Options,
|
||||||
// a non-ok Status will be returned.
|
// a non-ok Status will be returned.
|
||||||
virtual Status SanitizeDBOptions(DBOptions* db_opts) const = 0;
|
virtual Status SanitizeDBOptions(const DBOptions* db_opts) const = 0;
|
||||||
|
|
||||||
// Return a string that contains printable format of table configurations.
|
// Return a string that contains printable format of table configurations.
|
||||||
// RocksDB prints configurations at DB Open().
|
// RocksDB prints configurations at DB Open().
|
||||||
|
@ -43,7 +43,7 @@ class AdaptiveTableFactory : public TableFactory {
|
|||||||
override;
|
override;
|
||||||
|
|
||||||
// Sanitizes the specified DB Options.
|
// Sanitizes the specified DB Options.
|
||||||
Status SanitizeDBOptions(DBOptions* db_opts) const override {
|
Status SanitizeDBOptions(const DBOptions* db_opts) const override {
|
||||||
if (db_opts->allow_mmap_reads == false) {
|
if (db_opts->allow_mmap_reads == false) {
|
||||||
return Status::NotSupported(
|
return Status::NotSupported(
|
||||||
"AdaptiveTable with allow_mmap_reads == false is not supported.");
|
"AdaptiveTable with allow_mmap_reads == false is not supported.");
|
||||||
|
@ -45,7 +45,7 @@ class BlockBasedTableFactory : public TableFactory {
|
|||||||
WritableFile* file, CompressionType compression_type) const override;
|
WritableFile* file, CompressionType compression_type) const override;
|
||||||
|
|
||||||
// Sanitizes the specified DB Options.
|
// Sanitizes the specified DB Options.
|
||||||
Status SanitizeDBOptions(DBOptions* db_opts) const override {
|
Status SanitizeDBOptions(const DBOptions* db_opts) const override {
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class CuckooTableFactory : public TableFactory {
|
|||||||
CompressionType compression_type) const override;
|
CompressionType compression_type) const override;
|
||||||
|
|
||||||
// Sanitizes the specified DB Options.
|
// Sanitizes the specified DB Options.
|
||||||
Status SanitizeDBOptions(DBOptions* db_opts) const override {
|
Status SanitizeDBOptions(const DBOptions* db_opts) const override {
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ class PlainTableFactory : public TableFactory {
|
|||||||
static const char kValueTypeSeqId0 = 0xFF;
|
static const char kValueTypeSeqId0 = 0xFF;
|
||||||
|
|
||||||
// Sanitizes the specified DB Options.
|
// Sanitizes the specified DB Options.
|
||||||
Status SanitizeDBOptions(DBOptions* db_opts) const override {
|
Status SanitizeDBOptions(const DBOptions* db_opts) const override {
|
||||||
if (db_opts->allow_mmap_reads == false) {
|
if (db_opts->allow_mmap_reads == false) {
|
||||||
return Status::NotSupported(
|
return Status::NotSupported(
|
||||||
"PlainTable with allow_mmap_reads == false is not supported.");
|
"PlainTable with allow_mmap_reads == false is not supported.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user