unfriend ColumnFamilyData from VersionSet

Summary: as title

Test Plan:
make release
will run full test on all stacked diffs before committing

Reviewers: sdong, yhchiang, rven, igor

Reviewed By: igor

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D27591
This commit is contained in:
Lei Jin 2014-10-28 10:04:38 -07:00
parent 834c67d77f
commit f981e08139
3 changed files with 11 additions and 3 deletions

View File

@ -304,8 +304,9 @@ ColumnFamilyData::~ColumnFamilyData() {
if (dummy_versions_ != nullptr) {
// List must be empty
assert(dummy_versions_->next_ == dummy_versions_);
delete dummy_versions_;
assert(dummy_versions_->TEST_Next() == dummy_versions_);
bool deleted __attribute__((unused)) = dummy_versions_->Unref();
assert(deleted);
}
if (mem_ != nullptr) {

View File

@ -2933,6 +2933,9 @@ ColumnFamilyData* VersionSet::CreateColumnFamily(
assert(edit->is_column_family_add_);
Version* dummy_versions = new Version(nullptr, this);
// Ref() dummy version once so that later we can call Unref() to delete it
// by avoiding calling "delete" explicitly (~Version is private)
dummy_versions->Ref();
auto new_cfd = column_family_set_->CreateColumnFamily(
edit->column_family_name_, edit->column_family_, dummy_versions,
cf_options);

View File

@ -292,10 +292,14 @@ class Version {
// seconds/minutes (because of concurrent compactions).
static const size_t kNumberFilesToSort = 50;
// Return the next Version in the linked list. Used for debug only
Version* TEST_Next() const {
return next_;
}
private:
friend class VersionSet;
friend class DBImpl;
friend class ColumnFamilyData;
friend class ForwardIterator;
friend class InternalStats;