[column families] Implement DB::OpenWithColumnFamilies()
Summary: In addition to implementing OpenWithColumnFamilies, this diff also includes some minor changes: * Changed all column family names from Slice() to std::string. The performance of column family name handling is not critical, and it's more convenient and cleaner to have names as std::strings * Implemented ColumnFamilyOptions(const Options&) and DBOptions(const Options&) * Added ColumnFamilyOptions to VersionSet::ColumnFamilyData. ColumnFamilyOptions are specified on OpenWithColumnFamilies() and CreateColumnFamily() I will keep the diff in the Phabricator for a day or two and will push to the branch then. Feel free to comment even after the diff has been pushed. Test Plan: Added a simple unit test Reviewers: dhruba, haobo CC: leveldb Differential Revision: https://reviews.facebook.net/D15033
This commit is contained in:
parent
d3a2ba9c64
commit
72918efffe
@ -33,8 +33,15 @@ class ColumnFamilyTest {
|
|||||||
db_ = nullptr;
|
db_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Open() {
|
Status Open(vector<string> cf) {
|
||||||
ASSERT_OK(DB::Open(options_, dbname_, &db_));
|
vector<ColumnFamilyDescriptor> column_families;
|
||||||
|
for (auto x : cf) {
|
||||||
|
column_families.push_back(
|
||||||
|
ColumnFamilyDescriptor(x, ColumnFamilyOptions()));
|
||||||
|
}
|
||||||
|
vector <ColumnFamilyHandle> handles;
|
||||||
|
return DB::OpenWithColumnFamilies(db_options_, dbname_, column_families,
|
||||||
|
&handles, &db_);
|
||||||
}
|
}
|
||||||
|
|
||||||
Options options_;
|
Options options_;
|
||||||
@ -45,25 +52,26 @@ class ColumnFamilyTest {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST(ColumnFamilyTest, AddDrop) {
|
TEST(ColumnFamilyTest, AddDrop) {
|
||||||
Open();
|
ASSERT_OK(Open({"default"}));
|
||||||
ColumnFamilyHandle handles[4];
|
ColumnFamilyHandle handles[4];
|
||||||
ASSERT_OK(db_->CreateColumnFamily(column_family_options_, Slice("one"),
|
ASSERT_OK(
|
||||||
&handles[0]));
|
db_->CreateColumnFamily(column_family_options_, "one", &handles[0]));
|
||||||
ASSERT_OK(db_->CreateColumnFamily(column_family_options_, Slice("two"),
|
ASSERT_OK(
|
||||||
&handles[1]));
|
db_->CreateColumnFamily(column_family_options_, "two", &handles[1]));
|
||||||
ASSERT_OK(db_->CreateColumnFamily(column_family_options_, Slice("three"),
|
ASSERT_OK(
|
||||||
&handles[2]));
|
db_->CreateColumnFamily(column_family_options_, "three", &handles[2]));
|
||||||
ASSERT_OK(db_->DropColumnFamily(handles[1]));
|
ASSERT_OK(db_->DropColumnFamily(handles[1]));
|
||||||
ASSERT_OK(db_->CreateColumnFamily(column_family_options_, Slice("four"),
|
ASSERT_OK(
|
||||||
&handles[3]));
|
db_->CreateColumnFamily(column_family_options_, "four", &handles[3]));
|
||||||
Close();
|
Close();
|
||||||
Open(); // this will roll the manifest, column families should stay consistent
|
ASSERT_TRUE(Open({"default"}).IsInvalidArgument());
|
||||||
|
ASSERT_OK(Open({"default", "one", "three", "four"}));
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
vector<string> families;
|
vector<string> families;
|
||||||
DB::ListColumnFamilies(db_options_, dbname_, &families);
|
DB::ListColumnFamilies(db_options_, dbname_, &families);
|
||||||
sort(families.begin(), families.end());
|
sort(families.begin(), families.end());
|
||||||
ASSERT_TRUE(families == vector<string>({"four", "one", "three"}));
|
ASSERT_TRUE(families == vector<string>({"default", "four", "one", "three"}));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace rocksdb
|
} // namespace rocksdb
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
namespace rocksdb {
|
namespace rocksdb {
|
||||||
|
|
||||||
const Slice& default_column_family_name("default");
|
const std::string default_column_family_name("default");
|
||||||
|
|
||||||
void dumpLeveldbBuildVersion(Logger * log);
|
void dumpLeveldbBuildVersion(Logger * log);
|
||||||
|
|
||||||
@ -843,8 +843,10 @@ void DBImpl::PurgeObsoleteWALFiles() {
|
|||||||
|
|
||||||
// If externalTable is set, then apply recovered transactions
|
// If externalTable is set, then apply recovered transactions
|
||||||
// to that table. This is used for readonly mode.
|
// to that table. This is used for readonly mode.
|
||||||
Status DBImpl::Recover(VersionEdit* edit, MemTable* external_table,
|
Status DBImpl::Recover(
|
||||||
bool error_if_log_file_exist) {
|
VersionEdit* edit,
|
||||||
|
const std::vector<ColumnFamilyDescriptor>& column_families,
|
||||||
|
MemTable* external_table, bool error_if_log_file_exist) {
|
||||||
mutex_.AssertHeld();
|
mutex_.AssertHeld();
|
||||||
|
|
||||||
assert(db_lock_ == nullptr);
|
assert(db_lock_ == nullptr);
|
||||||
@ -894,6 +896,19 @@ Status DBImpl::Recover(VersionEdit* edit, MemTable* external_table,
|
|||||||
|
|
||||||
Status s = versions_->Recover();
|
Status s = versions_->Recover();
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
|
if (column_families.size() != versions_->column_families_.size()) {
|
||||||
|
return Status::InvalidArgument("Column family specifications mismatch");
|
||||||
|
}
|
||||||
|
for (auto cf : column_families) {
|
||||||
|
auto cf_iter = versions_->column_families_.find(cf.name);
|
||||||
|
if (cf_iter == versions_->column_families_.end()) {
|
||||||
|
return Status::InvalidArgument("Column family specifications mismatch");
|
||||||
|
}
|
||||||
|
auto cf_data_iter = versions_->column_family_data_.find(cf_iter->second);
|
||||||
|
assert(cf_data_iter != versions_->column_family_data_.end());
|
||||||
|
cf_data_iter->second.options = cf.options;
|
||||||
|
}
|
||||||
|
|
||||||
SequenceNumber max_sequence(0);
|
SequenceNumber max_sequence(0);
|
||||||
|
|
||||||
// Recover from all newer log files than the ones named in the
|
// Recover from all newer log files than the ones named in the
|
||||||
@ -2862,15 +2877,23 @@ std::vector<Status> DBImpl::MultiGet(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Status DBImpl::CreateColumnFamily(const ColumnFamilyOptions& options,
|
Status DBImpl::CreateColumnFamily(const ColumnFamilyOptions& options,
|
||||||
const Slice& column_family,
|
const std::string& column_family_name,
|
||||||
ColumnFamilyHandle* handle) {
|
ColumnFamilyHandle* handle) {
|
||||||
VersionEdit edit(0);
|
VersionEdit edit(0);
|
||||||
edit.AddColumnFamily(column_family.ToString());
|
edit.AddColumnFamily(column_family_name);
|
||||||
MutexLock l(&mutex_);
|
MutexLock l(&mutex_);
|
||||||
++versions_->max_column_family_;
|
++versions_->max_column_family_;
|
||||||
handle->id = versions_->max_column_family_;
|
handle->id = versions_->max_column_family_;
|
||||||
edit.SetColumnFamily(handle->id);
|
edit.SetColumnFamily(handle->id);
|
||||||
return versions_->LogAndApply(&edit, &mutex_);
|
Status s = versions_->LogAndApply(&edit, &mutex_);
|
||||||
|
if (s.ok()) {
|
||||||
|
// add to internal data structures
|
||||||
|
versions_->column_families_[column_family_name] = handle->id;
|
||||||
|
versions_->column_family_data_.insert(
|
||||||
|
{handle->id,
|
||||||
|
VersionSet::ColumnFamilyData(column_family_name, options)});
|
||||||
|
}
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status DBImpl::DropColumnFamily(const ColumnFamilyHandle& column_family) {
|
Status DBImpl::DropColumnFamily(const ColumnFamilyHandle& column_family) {
|
||||||
@ -2878,7 +2901,19 @@ Status DBImpl::DropColumnFamily(const ColumnFamilyHandle& column_family) {
|
|||||||
edit.DropColumnFamily();
|
edit.DropColumnFamily();
|
||||||
edit.SetColumnFamily(column_family.id);
|
edit.SetColumnFamily(column_family.id);
|
||||||
MutexLock l(&mutex_);
|
MutexLock l(&mutex_);
|
||||||
return versions_->LogAndApply(&edit, &mutex_);
|
auto data_iter = versions_->column_family_data_.find(column_family.id);
|
||||||
|
if (data_iter == versions_->column_family_data_.end()) {
|
||||||
|
return Status::NotFound("Column family not found");
|
||||||
|
}
|
||||||
|
Status s = versions_->LogAndApply(&edit, &mutex_);
|
||||||
|
if (s.ok()) {
|
||||||
|
// remove from internal data structures
|
||||||
|
auto cf_iter = versions_->column_families_.find(data_iter->second.name);
|
||||||
|
assert(cf_iter != versions_->column_families_.end());
|
||||||
|
versions_->column_families_.erase(cf_iter);
|
||||||
|
versions_->column_family_data_.erase(data_iter);
|
||||||
|
}
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DBImpl::KeyMayExist(const ReadOptions& options,
|
bool DBImpl::KeyMayExist(const ReadOptions& options,
|
||||||
@ -3803,7 +3838,7 @@ Status DB::Merge(const WriteOptions& opt,
|
|||||||
|
|
||||||
// Default implementation -- returns not supported status
|
// Default implementation -- returns not supported status
|
||||||
Status DB::CreateColumnFamily(const ColumnFamilyOptions& options,
|
Status DB::CreateColumnFamily(const ColumnFamilyOptions& options,
|
||||||
const Slice& column_family,
|
const std::string& column_family_name,
|
||||||
ColumnFamilyHandle* handle) {
|
ColumnFamilyHandle* handle) {
|
||||||
return Status::NotSupported("");
|
return Status::NotSupported("");
|
||||||
}
|
}
|
||||||
@ -3814,8 +3849,33 @@ Status DB::DropColumnFamily(const ColumnFamilyHandle& column_family) {
|
|||||||
DB::~DB() { }
|
DB::~DB() { }
|
||||||
|
|
||||||
Status DB::Open(const Options& options, const std::string& dbname, DB** dbptr) {
|
Status DB::Open(const Options& options, const std::string& dbname, DB** dbptr) {
|
||||||
|
DBOptions db_options(options);
|
||||||
|
ColumnFamilyOptions cf_options(options);
|
||||||
|
std::vector<ColumnFamilyDescriptor> column_families;
|
||||||
|
column_families.push_back(
|
||||||
|
ColumnFamilyDescriptor(default_column_family_name, cf_options));
|
||||||
|
std::vector<ColumnFamilyHandle> handles;
|
||||||
|
return DB::OpenWithColumnFamilies(db_options, dbname, column_families,
|
||||||
|
&handles, dbptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status DB::OpenWithColumnFamilies(
|
||||||
|
const DBOptions& db_options, const std::string& dbname,
|
||||||
|
const std::vector<ColumnFamilyDescriptor>& column_families,
|
||||||
|
std::vector<ColumnFamilyHandle>* handles, DB** dbptr) {
|
||||||
*dbptr = nullptr;
|
*dbptr = nullptr;
|
||||||
EnvOptions soptions;
|
EnvOptions soptions;
|
||||||
|
// TODO temporary until we change DBImpl to accept
|
||||||
|
// DBOptions instead of Options
|
||||||
|
ColumnFamilyOptions default_column_family_options;
|
||||||
|
for (auto cfd : column_families) {
|
||||||
|
if (cfd.name == default_column_family_name) {
|
||||||
|
default_column_family_options = cfd.options;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// default options
|
||||||
|
Options options(db_options, default_column_family_options);
|
||||||
|
|
||||||
if (options.block_cache != nullptr && options.no_block_cache) {
|
if (options.block_cache != nullptr && options.no_block_cache) {
|
||||||
return Status::InvalidArgument(
|
return Status::InvalidArgument(
|
||||||
@ -3836,7 +3896,8 @@ Status DB::Open(const Options& options, const std::string& dbname, DB** dbptr) {
|
|||||||
}
|
}
|
||||||
impl->mutex_.Lock();
|
impl->mutex_.Lock();
|
||||||
VersionEdit edit(impl->NumberLevels());
|
VersionEdit edit(impl->NumberLevels());
|
||||||
s = impl->Recover(&edit); // Handles create_if_missing, error_if_exists
|
// Handles create_if_missing, error_if_exists
|
||||||
|
s = impl->Recover(&edit, column_families);
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
uint64_t new_log_number = impl->versions_->NewFileNumber();
|
uint64_t new_log_number = impl->versions_->NewFileNumber();
|
||||||
unique_ptr<WritableFile> lfile;
|
unique_ptr<WritableFile> lfile;
|
||||||
@ -3854,6 +3915,13 @@ Status DB::Open(const Options& options, const std::string& dbname, DB** dbptr) {
|
|||||||
s = impl->versions_->LogAndApply(&edit, &impl->mutex_);
|
s = impl->versions_->LogAndApply(&edit, &impl->mutex_);
|
||||||
}
|
}
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
|
// set column family handles
|
||||||
|
handles->clear();
|
||||||
|
for (auto cf : column_families) {
|
||||||
|
auto cf_iter = impl->versions_->column_families_.find(cf.name);
|
||||||
|
assert(cf_iter != impl->versions_->column_families_.end());
|
||||||
|
handles->push_back(ColumnFamilyHandle(cf_iter->second));
|
||||||
|
}
|
||||||
delete impl->InstallSuperVersion(new DBImpl::SuperVersion());
|
delete impl->InstallSuperVersion(new DBImpl::SuperVersion());
|
||||||
impl->mem_->SetLogNumber(impl->logfile_number_);
|
impl->mem_->SetLogNumber(impl->logfile_number_);
|
||||||
impl->DeleteObsoleteFiles();
|
impl->DeleteObsoleteFiles();
|
||||||
@ -3878,19 +3946,12 @@ Status DB::Open(const Options& options, const std::string& dbname, DB** dbptr) {
|
|||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
*dbptr = impl;
|
*dbptr = impl;
|
||||||
} else {
|
} else {
|
||||||
|
handles->clear();
|
||||||
delete impl;
|
delete impl;
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status DB::OpenWithColumnFamilies(
|
|
||||||
const DBOptions& db_options, const std::string& name,
|
|
||||||
const std::vector<ColumnFamilyDescriptor>& column_families,
|
|
||||||
std::vector<ColumnFamilyHandle>* handles, DB** dbptr) {
|
|
||||||
// TODO
|
|
||||||
return Status::NotSupported("Working on it");
|
|
||||||
}
|
|
||||||
|
|
||||||
Status DB::ListColumnFamilies(const DBOptions& db_options,
|
Status DB::ListColumnFamilies(const DBOptions& db_options,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
std::vector<std::string>* column_families) {
|
std::vector<std::string>* column_families) {
|
||||||
|
@ -62,7 +62,7 @@ class DBImpl : public DB {
|
|||||||
const std::vector<Slice>& keys, std::vector<std::string>* values);
|
const std::vector<Slice>& keys, std::vector<std::string>* values);
|
||||||
|
|
||||||
virtual Status CreateColumnFamily(const ColumnFamilyOptions& options,
|
virtual Status CreateColumnFamily(const ColumnFamilyOptions& options,
|
||||||
const Slice& column_family,
|
const std::string& column_family,
|
||||||
ColumnFamilyHandle* handle);
|
ColumnFamilyHandle* handle);
|
||||||
virtual Status DropColumnFamily(const ColumnFamilyHandle& column_family);
|
virtual Status DropColumnFamily(const ColumnFamilyHandle& column_family);
|
||||||
|
|
||||||
@ -293,8 +293,10 @@ class DBImpl : public DB {
|
|||||||
// Recover the descriptor from persistent storage. May do a significant
|
// Recover the descriptor from persistent storage. May do a significant
|
||||||
// amount of work to recover recently logged updates. Any changes to
|
// amount of work to recover recently logged updates. Any changes to
|
||||||
// be made to the descriptor are added to *edit.
|
// be made to the descriptor are added to *edit.
|
||||||
Status Recover(VersionEdit* edit, MemTable* external_table = nullptr,
|
Status Recover(VersionEdit* edit,
|
||||||
bool error_if_log_file_exist = false);
|
const std::vector<ColumnFamilyDescriptor>& column_families,
|
||||||
|
MemTable* external_table = nullptr,
|
||||||
|
bool error_if_log_file_exist = false);
|
||||||
|
|
||||||
void MaybeIgnoreError(Status* s) const;
|
void MaybeIgnoreError(Status* s) const;
|
||||||
|
|
||||||
|
@ -86,7 +86,12 @@ Status DB::OpenForReadOnly(const Options& options, const std::string& dbname,
|
|||||||
DBImplReadOnly* impl = new DBImplReadOnly(options, dbname);
|
DBImplReadOnly* impl = new DBImplReadOnly(options, dbname);
|
||||||
impl->mutex_.Lock();
|
impl->mutex_.Lock();
|
||||||
VersionEdit edit(impl->NumberLevels());
|
VersionEdit edit(impl->NumberLevels());
|
||||||
Status s = impl->Recover(&edit, impl->GetMemTable(),
|
DBOptions db_options(options);
|
||||||
|
ColumnFamilyOptions cf_options(options);
|
||||||
|
std::vector<ColumnFamilyDescriptor> column_families;
|
||||||
|
column_families.push_back(
|
||||||
|
ColumnFamilyDescriptor(default_column_family_name, cf_options));
|
||||||
|
Status s = impl->Recover(&edit, column_families, impl->GetMemTable(),
|
||||||
error_if_log_file_exist);
|
error_if_log_file_exist);
|
||||||
impl->mutex_.Unlock();
|
impl->mutex_.Unlock();
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
|
@ -1443,6 +1443,11 @@ Status VersionSet::Recover() {
|
|||||||
uint64_t prev_log_number = 0;
|
uint64_t prev_log_number = 0;
|
||||||
Builder builder(this, current_);
|
Builder builder(this, current_);
|
||||||
|
|
||||||
|
// add default column family
|
||||||
|
column_families_.insert({default_column_family_name, 0});
|
||||||
|
column_family_data_.insert(
|
||||||
|
{0, ColumnFamilyData(default_column_family_name)});
|
||||||
|
|
||||||
{
|
{
|
||||||
LogReporter reporter;
|
LogReporter reporter;
|
||||||
reporter.status = &s;
|
reporter.status = &s;
|
||||||
@ -1847,6 +1852,11 @@ Status VersionSet::WriteSnapshot(log::Writer* log) {
|
|||||||
// Save column families
|
// Save column families
|
||||||
for (auto cf : column_families_) {
|
for (auto cf : column_families_) {
|
||||||
VersionEdit edit(0);
|
VersionEdit edit(0);
|
||||||
|
if (cf.second == 0) {
|
||||||
|
// default column family is always there,
|
||||||
|
// no need to explicitly write it
|
||||||
|
continue;
|
||||||
|
}
|
||||||
edit.AddColumnFamily(cf.first);
|
edit.AddColumnFamily(cf.first);
|
||||||
edit.SetColumnFamily(cf.second);
|
edit.SetColumnFamily(cf.second);
|
||||||
std::string record;
|
std::string record;
|
||||||
|
@ -439,7 +439,11 @@ class VersionSet {
|
|||||||
// column family metadata
|
// column family metadata
|
||||||
struct ColumnFamilyData {
|
struct ColumnFamilyData {
|
||||||
std::string name;
|
std::string name;
|
||||||
|
ColumnFamilyOptions options;
|
||||||
explicit ColumnFamilyData(const std::string& name) : name(name) {}
|
explicit ColumnFamilyData(const std::string& name) : name(name) {}
|
||||||
|
ColumnFamilyData(const std::string& name,
|
||||||
|
const ColumnFamilyOptions& options)
|
||||||
|
: name(name), options(options) {}
|
||||||
};
|
};
|
||||||
std::unordered_map<std::string, uint32_t> column_families_;
|
std::unordered_map<std::string, uint32_t> column_families_;
|
||||||
std::unordered_map<uint32_t, ColumnFamilyData> column_family_data_;
|
std::unordered_map<uint32_t, ColumnFamilyData> column_family_data_;
|
||||||
|
@ -26,6 +26,6 @@ struct ColumnFamilyHandle {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ColumnFamilyHandle default_column_family = ColumnFamilyHandle();
|
const ColumnFamilyHandle default_column_family = ColumnFamilyHandle();
|
||||||
extern const Slice& default_column_family_name;
|
extern const std::string default_column_family_name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
#include "rocksdb/iterator.h"
|
#include "rocksdb/iterator.h"
|
||||||
#include "rocksdb/options.h"
|
#include "rocksdb/options.h"
|
||||||
#include "rocksdb/types.h"
|
#include "rocksdb/types.h"
|
||||||
@ -26,8 +27,11 @@ struct ColumnFamilyHandle;
|
|||||||
extern const ColumnFamilyHandle default_column_family;
|
extern const ColumnFamilyHandle default_column_family;
|
||||||
|
|
||||||
struct ColumnFamilyDescriptor {
|
struct ColumnFamilyDescriptor {
|
||||||
Slice name;
|
std::string name;
|
||||||
ColumnFamilyOptions options;
|
ColumnFamilyOptions options;
|
||||||
|
ColumnFamilyDescriptor(const std::string& name,
|
||||||
|
const ColumnFamilyOptions& options)
|
||||||
|
: name(name), options(options) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update Makefile if you change these
|
// Update Makefile if you change these
|
||||||
@ -117,7 +121,7 @@ class DB {
|
|||||||
// Create a column_family and return the handle of column family
|
// Create a column_family and return the handle of column family
|
||||||
// through the argument handle.
|
// through the argument handle.
|
||||||
virtual Status CreateColumnFamily(const ColumnFamilyOptions& options,
|
virtual Status CreateColumnFamily(const ColumnFamilyOptions& options,
|
||||||
const Slice& column_family,
|
const std::string& column_family_name,
|
||||||
ColumnFamilyHandle* handle);
|
ColumnFamilyHandle* handle);
|
||||||
|
|
||||||
// Drop a column family specified by column_family handle.
|
// Drop a column family specified by column_family handle.
|
||||||
|
@ -68,6 +68,8 @@ struct CompressionOptions {
|
|||||||
strategy(strategy){}
|
strategy(strategy){}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Options;
|
||||||
|
|
||||||
struct ColumnFamilyOptions {
|
struct ColumnFamilyOptions {
|
||||||
// -------------------
|
// -------------------
|
||||||
// Parameters that affect behavior
|
// Parameters that affect behavior
|
||||||
@ -426,6 +428,8 @@ struct ColumnFamilyOptions {
|
|||||||
|
|
||||||
// Create ColumnFamilyOptions with default values for all fields
|
// Create ColumnFamilyOptions with default values for all fields
|
||||||
ColumnFamilyOptions();
|
ColumnFamilyOptions();
|
||||||
|
// Create ColumnFamilyOptions from Options
|
||||||
|
explicit ColumnFamilyOptions(const Options& options);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DBOptions {
|
struct DBOptions {
|
||||||
@ -627,6 +631,8 @@ struct DBOptions {
|
|||||||
|
|
||||||
// Create DBOptions with default values for all fields
|
// Create DBOptions with default values for all fields
|
||||||
DBOptions();
|
DBOptions();
|
||||||
|
// Create DBOptions from Options
|
||||||
|
explicit DBOptions(const Options& options);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Options to control the behavior of a database (passed to DB::Open)
|
// Options to control the behavior of a database (passed to DB::Open)
|
||||||
|
@ -73,6 +73,65 @@ ColumnFamilyOptions::ColumnFamilyOptions()
|
|||||||
assert(memtable_factory.get() != nullptr);
|
assert(memtable_factory.get() != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ColumnFamilyOptions::ColumnFamilyOptions(const Options& options)
|
||||||
|
: comparator(options.comparator),
|
||||||
|
merge_operator(options.merge_operator),
|
||||||
|
compaction_filter(options.compaction_filter),
|
||||||
|
compaction_filter_factory(options.compaction_filter_factory),
|
||||||
|
write_buffer_size(options.write_buffer_size),
|
||||||
|
max_write_buffer_number(options.max_write_buffer_number),
|
||||||
|
min_write_buffer_number_to_merge(
|
||||||
|
options.min_write_buffer_number_to_merge),
|
||||||
|
block_cache(options.block_cache),
|
||||||
|
block_cache_compressed(options.block_cache_compressed),
|
||||||
|
block_size(options.block_size),
|
||||||
|
block_restart_interval(options.block_restart_interval),
|
||||||
|
compression(options.compression),
|
||||||
|
compression_per_level(options.compression_per_level),
|
||||||
|
compression_opts(options.compression_opts),
|
||||||
|
filter_policy(options.filter_policy),
|
||||||
|
prefix_extractor(options.prefix_extractor),
|
||||||
|
whole_key_filtering(options.whole_key_filtering),
|
||||||
|
num_levels(options.num_levels),
|
||||||
|
level0_file_num_compaction_trigger(
|
||||||
|
options.level0_file_num_compaction_trigger),
|
||||||
|
level0_slowdown_writes_trigger(options.level0_slowdown_writes_trigger),
|
||||||
|
level0_stop_writes_trigger(options.level0_stop_writes_trigger),
|
||||||
|
max_mem_compaction_level(options.max_mem_compaction_level),
|
||||||
|
target_file_size_base(options.target_file_size_base),
|
||||||
|
target_file_size_multiplier(options.target_file_size_multiplier),
|
||||||
|
max_bytes_for_level_base(options.max_bytes_for_level_base),
|
||||||
|
max_bytes_for_level_multiplier(options.max_bytes_for_level_multiplier),
|
||||||
|
max_bytes_for_level_multiplier_additional(
|
||||||
|
options.max_bytes_for_level_multiplier_additional),
|
||||||
|
expanded_compaction_factor(options.expanded_compaction_factor),
|
||||||
|
source_compaction_factor(options.source_compaction_factor),
|
||||||
|
max_grandparent_overlap_factor(options.max_grandparent_overlap_factor),
|
||||||
|
disable_seek_compaction(options.disable_seek_compaction),
|
||||||
|
soft_rate_limit(options.soft_rate_limit),
|
||||||
|
hard_rate_limit(options.hard_rate_limit),
|
||||||
|
rate_limit_delay_max_milliseconds(
|
||||||
|
options.rate_limit_delay_max_milliseconds),
|
||||||
|
no_block_cache(options.no_block_cache),
|
||||||
|
table_cache_numshardbits(options.table_cache_numshardbits),
|
||||||
|
table_cache_remove_scan_count_limit(
|
||||||
|
options.table_cache_remove_scan_count_limit),
|
||||||
|
disable_auto_compactions(options.disable_auto_compactions),
|
||||||
|
purge_redundant_kvs_while_flush(options.purge_redundant_kvs_while_flush),
|
||||||
|
block_size_deviation(options.block_size_deviation),
|
||||||
|
compaction_style(options.compaction_style),
|
||||||
|
compaction_options_universal(options.compaction_options_universal),
|
||||||
|
filter_deletes(options.filter_deletes),
|
||||||
|
max_sequential_skip_in_iterations(
|
||||||
|
options.max_sequential_skip_in_iterations),
|
||||||
|
memtable_factory(options.memtable_factory),
|
||||||
|
table_factory(options.table_factory),
|
||||||
|
table_properties_collectors(options.table_properties_collectors),
|
||||||
|
inplace_update_support(options.inplace_update_support),
|
||||||
|
inplace_update_num_locks(options.inplace_update_num_locks) {
|
||||||
|
assert(memtable_factory.get() != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
DBOptions::DBOptions()
|
DBOptions::DBOptions()
|
||||||
: create_if_missing(false),
|
: create_if_missing(false),
|
||||||
error_if_exists(false),
|
error_if_exists(false),
|
||||||
@ -107,6 +166,42 @@ DBOptions::DBOptions()
|
|||||||
use_adaptive_mutex(false),
|
use_adaptive_mutex(false),
|
||||||
bytes_per_sync(0) { }
|
bytes_per_sync(0) { }
|
||||||
|
|
||||||
|
DBOptions::DBOptions(const Options& options)
|
||||||
|
: create_if_missing(options.create_if_missing),
|
||||||
|
error_if_exists(options.error_if_exists),
|
||||||
|
paranoid_checks(options.paranoid_checks),
|
||||||
|
env(options.env),
|
||||||
|
info_log(options.info_log),
|
||||||
|
max_open_files(options.max_open_files),
|
||||||
|
statistics(options.statistics),
|
||||||
|
disableDataSync(options.disableDataSync),
|
||||||
|
use_fsync(options.use_fsync),
|
||||||
|
db_stats_log_interval(options.db_stats_log_interval),
|
||||||
|
db_log_dir(options.db_log_dir),
|
||||||
|
wal_dir(options.wal_dir),
|
||||||
|
delete_obsolete_files_period_micros(
|
||||||
|
options.delete_obsolete_files_period_micros),
|
||||||
|
max_background_compactions(options.max_background_compactions),
|
||||||
|
max_background_flushes(options.max_background_flushes),
|
||||||
|
max_log_file_size(options.max_log_file_size),
|
||||||
|
log_file_time_to_roll(options.log_file_time_to_roll),
|
||||||
|
keep_log_file_num(options.keep_log_file_num),
|
||||||
|
max_manifest_file_size(options.max_manifest_file_size),
|
||||||
|
arena_block_size(options.arena_block_size),
|
||||||
|
WAL_ttl_seconds(options.WAL_ttl_seconds),
|
||||||
|
WAL_size_limit_MB(options.WAL_size_limit_MB),
|
||||||
|
manifest_preallocation_size(options.manifest_preallocation_size),
|
||||||
|
allow_os_buffer(options.allow_os_buffer),
|
||||||
|
allow_mmap_reads(options.allow_mmap_reads),
|
||||||
|
allow_mmap_writes(options.allow_mmap_writes),
|
||||||
|
is_fd_close_on_exec(options.is_fd_close_on_exec),
|
||||||
|
skip_log_error_on_recovery(options.skip_log_error_on_recovery),
|
||||||
|
stats_dump_period_sec(options.stats_dump_period_sec),
|
||||||
|
advise_random_on_open(options.advise_random_on_open),
|
||||||
|
access_hint_on_compaction_start(options.access_hint_on_compaction_start),
|
||||||
|
use_adaptive_mutex(options.use_adaptive_mutex),
|
||||||
|
bytes_per_sync(options.bytes_per_sync) {}
|
||||||
|
|
||||||
static const char* const access_hints[] = {
|
static const char* const access_hints[] = {
|
||||||
"NONE", "NORMAL", "SEQUENTIAL", "WILLNEED"
|
"NONE", "NORMAL", "SEQUENTIAL", "WILLNEED"
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user