From 422bb09cb01acb35845062906ab8a109860740aa Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Fri, 14 Feb 2014 17:02:10 -0800 Subject: [PATCH] Fix table properties Summary: Adapt table properties to column family world Test Plan: make check Reviewers: kailiu CC: leveldb Differential Revision: https://reviews.facebook.net/D16161 --- db/db_impl.cc | 12 +++++++++--- db/db_impl.h | 4 +++- db/db_test.cc | 4 +++- db/version_set.cc | 12 ++++++------ include/rocksdb/db.h | 6 +++++- include/utilities/stackable_db.h | 6 ++++-- 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/db/db_impl.cc b/db/db_impl.cc index 53fdbef18..91c60ddbb 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -2750,7 +2750,9 @@ Iterator* DBImpl::TEST_NewInternalIterator(ColumnFamilyHandle* column_family) { mutex_.Lock(); SuperVersion* super_version = cfd->GetSuperVersion()->Ref(); mutex_.Unlock(); - return NewInternalIterator(ReadOptions(), cfd, super_version); + ReadOptions roptions; + roptions.prefix_seek = true; + return NewInternalIterator(roptions, cfd, super_version); } std::pair DBImpl::GetTailingIteratorPair( @@ -3604,10 +3606,14 @@ Status DBImpl::MakeRoomForWrite(ColumnFamilyData* cfd, bool force) { return s; } -Status DBImpl::GetPropertiesOfAllTables(TablePropertiesCollection* props) { +Status DBImpl::GetPropertiesOfAllTables(ColumnFamilyHandle* column_family, + TablePropertiesCollection* props) { + auto cfh = reinterpret_cast(column_family); + auto cfd = cfh->cfd(); + // Increment the ref count mutex_.Lock(); - auto version = versions_->current(); + auto version = cfd->current(); version->Ref(); mutex_.Unlock(); diff --git a/db/db_impl.h b/db/db_impl.h index 5292e90cc..62bbe4c76 100644 --- a/db/db_impl.h +++ b/db/db_impl.h @@ -494,7 +494,9 @@ class DBImpl : public DB { void InstallSuperVersion(ColumnFamilyData* cfd, DeletionState& deletion_state); - virtual Status GetPropertiesOfAllTables(TablePropertiesCollection* props) + using DB::GetPropertiesOfAllTables; + virtual Status GetPropertiesOfAllTables(ColumnFamilyHandle* column_family, + TablePropertiesCollection* props) override; // Function that Get and KeyMayExist call with no_io true or false diff --git a/db/db_test.cc b/db/db_test.cc index ee1c4651a..6de4d2d84 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -5133,7 +5133,9 @@ class ModelDB: public DB { return s; } - virtual Status GetPropertiesOfAllTables(TablePropertiesCollection* props) { + using DB::GetPropertiesOfAllTables; + virtual Status GetPropertiesOfAllTables(ColumnFamilyHandle* column_family, + TablePropertiesCollection* props) { return Status(); } diff --git a/db/version_set.cc b/db/version_set.cc index 55ba9fead..5a24aa27a 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -244,8 +244,8 @@ bool Version::PrefixMayMatch(const ReadOptions& options, } Status Version::GetPropertiesOfAllTables(TablePropertiesCollection* props) { - auto table_cache = vset_->table_cache_; - auto options = vset_->options_; + auto table_cache = cfd_->table_cache(); + auto options = cfd_->full_options(); for (int level = 0; level < num_levels_; level++) { for (const auto& file_meta : files_[level]) { auto fname = TableFileName(vset_->dbname_, file_meta->number); @@ -253,8 +253,8 @@ Status Version::GetPropertiesOfAllTables(TablePropertiesCollection* props) { // properties from there. std::shared_ptr table_properties; Status s = table_cache->GetTableProperties( - vset_->storage_options_, vset_->icmp_, *file_meta, &table_properties, - true /* no io */); + vset_->storage_options_, cfd_->internal_comparator(), *file_meta, + &table_properties, true /* no io */); if (s.ok()) { props->insert({fname, table_properties}); continue; @@ -269,8 +269,8 @@ Status Version::GetPropertiesOfAllTables(TablePropertiesCollection* props) { // 2. Table is not present in table cache, we'll read the table properties // directly from the properties block in the file. std::unique_ptr file; - s = vset_->env_->NewRandomAccessFile(fname, &file, - vset_->storage_options_); + s = options->env->NewRandomAccessFile(fname, &file, + vset_->storage_options_); if (!s.ok()) { return s; } diff --git a/include/rocksdb/db.h b/include/rocksdb/db.h index a98172eac..82f69b158 100644 --- a/include/rocksdb/db.h +++ b/include/rocksdb/db.h @@ -435,7 +435,11 @@ class DB { // Returns default column family handle virtual ColumnFamilyHandle* DefaultColumnFamily() const = 0; - virtual Status GetPropertiesOfAllTables(TablePropertiesCollection* props) = 0; + virtual Status GetPropertiesOfAllTables(ColumnFamilyHandle* column_family, + TablePropertiesCollection* props) = 0; + virtual Status GetPropertiesOfAllTables(TablePropertiesCollection* props) { + return GetPropertiesOfAllTables(DefaultColumnFamily(), props); + } private: // No copying allowed diff --git a/include/utilities/stackable_db.h b/include/utilities/stackable_db.h index d859a6a6f..abb2517ce 100644 --- a/include/utilities/stackable_db.h +++ b/include/utilities/stackable_db.h @@ -182,8 +182,10 @@ class StackableDB : public DB { return db_->GetDbIdentity(identity); } - virtual Status GetPropertiesOfAllTables(TablePropertiesCollection* props) { - return db_->GetPropertiesOfAllTables(props); + using DB::GetPropertiesOfAllTables; + virtual Status GetPropertiesOfAllTables(ColumnFamilyHandle* column_family, + TablePropertiesCollection* props) { + return db_->GetPropertiesOfAllTables(column_family, props); } virtual Status GetUpdatesSince(SequenceNumber seq_number,