From 6d6fb7096026b246ae9751da08781be1f50e52b6 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Thu, 16 Jan 2014 14:06:53 -0800 Subject: [PATCH] Remove compaction pointers Summary: The only thing we do with compaction pointers is set them to some values, we never actually read them. I don't know what we used them for, but it doesn't look like we use them anymore. Test Plan: make check Reviewers: dhruba, haobo, kailiu, sdong Reviewed By: kailiu CC: leveldb Differential Revision: https://reviews.facebook.net/D15225 --- db/version_edit.cc | 16 +++------------- db/version_edit.h | 4 ---- db/version_edit_test.cc | 1 - db/version_set.cc | 18 ------------------ db/version_set.h | 4 ---- db/version_set_reduce_num_levels.cc | 2 -- 6 files changed, 3 insertions(+), 42 deletions(-) diff --git a/db/version_edit.cc b/db/version_edit.cc index 42c07e7b0..70618c9ce 100644 --- a/db/version_edit.cc +++ b/db/version_edit.cc @@ -69,12 +69,6 @@ void VersionEdit::EncodeTo(std::string* dst) const { PutVarint64(dst, last_sequence_); } - for (size_t i = 0; i < compact_pointers_.size(); i++) { - PutVarint32(dst, kCompactPointer); - PutVarint32(dst, compact_pointers_[i].first); // level - PutLengthPrefixedSlice(dst, compact_pointers_[i].second.Encode()); - } - for (DeletedFileSet::const_iterator iter = deleted_files_.begin(); iter != deleted_files_.end(); ++iter) { @@ -178,7 +172,9 @@ Status VersionEdit::DecodeFrom(const Slice& src) { case kCompactPointer: if (GetLevel(&input, &level, &msg) && GetInternalKey(&input, &key)) { - compact_pointers_.push_back(std::make_pair(level, key)); + // we don't use compact pointers anymore, + // but we should not fail if they are still + // in manifest } else { if (!msg) { msg = "compaction pointer"; @@ -267,12 +263,6 @@ std::string VersionEdit::DebugString(bool hex_key) const { r.append("\n LastSeq: "); AppendNumberTo(&r, last_sequence_); } - for (size_t i = 0; i < compact_pointers_.size(); i++) { - r.append("\n CompactPointer: "); - AppendNumberTo(&r, compact_pointers_[i].first); - r.append(" "); - r.append(compact_pointers_[i].second.DebugString(hex_key)); - } for (DeletedFileSet::const_iterator iter = deleted_files_.begin(); iter != deleted_files_.end(); ++iter) { diff --git a/db/version_edit.h b/db/version_edit.h index a0546c983..e6fe15773 100644 --- a/db/version_edit.h +++ b/db/version_edit.h @@ -59,9 +59,6 @@ class VersionEdit { has_last_sequence_ = true; last_sequence_ = seq; } - void SetCompactPointer(int level, const InternalKey& key) { - compact_pointers_.push_back(std::make_pair(level, key)); - } // Add the specified file at the specified number. // REQUIRES: This version has not been saved (see VersionSet::SaveTo) @@ -117,7 +114,6 @@ class VersionEdit { bool has_next_file_number_; bool has_last_sequence_; - std::vector > compact_pointers_; DeletedFileSet deleted_files_; std::vector > new_files_; }; diff --git a/db/version_edit_test.cc b/db/version_edit_test.cc index 63aa32e8f..110b422f8 100644 --- a/db/version_edit_test.cc +++ b/db/version_edit_test.cc @@ -36,7 +36,6 @@ TEST(VersionEditTest, EncodeDecode) { kBig + 500 + i, kBig + 600 + i); edit.DeleteFile(4, kBig + 700 + i); - edit.SetCompactPointer(i, InternalKey("x", kBig + 900 + i, kTypeValue)); } edit.SetComparatorName("foo"); diff --git a/db/version_set.cc b/db/version_set.cc index af0883d70..ebd2805bc 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -1245,13 +1245,6 @@ class VersionSet::Builder { void Apply(VersionEdit* edit) { CheckConsistency(base_); - // Update compaction pointers - for (size_t i = 0; i < edit->compact_pointers_.size(); i++) { - const int level = edit->compact_pointers_[i].first; - vset_->compact_pointer_[level] = - edit->compact_pointers_[i].second.Encode().ToString(); - } - // Delete files const VersionEdit::DeletedFileSet& del = edit->deleted_files_; for (VersionEdit::DeletedFileSet::const_iterator iter = del.begin(); @@ -1365,7 +1358,6 @@ VersionSet::VersionSet(const std::string& dbname, const Options* options, manifest_file_size_(0), storage_options_(storage_options), storage_options_compactions_(storage_options_) { - compact_pointer_ = new std::string[options_->num_levels]; if (options_->compaction_style == kCompactionStyleUniversal) { compaction_picker_.reset(new UniversalCompactionPicker(options_, &icmp_)); } else { @@ -1381,7 +1373,6 @@ VersionSet::~VersionSet() { delete file; } obsolete_files_.clear(); - delete[] compact_pointer_; } void VersionSet::AppendVersion(Version* v) { @@ -1881,15 +1872,6 @@ Status VersionSet::WriteSnapshot(log::Writer* log) { VersionEdit edit; edit.SetComparatorName(icmp_.user_comparator()->Name()); - // Save compaction pointers - for (int level = 0; level < NumberLevels(); level++) { - if (!compact_pointer_[level].empty()) { - InternalKey key; - key.DecodeFrom(compact_pointer_[level]); - edit.SetCompactPointer(level, key); - } - } - // Save files for (int level = 0; level < current_->NumberLevels(); level++) { const std::vector& files = current_->files_[level]; diff --git a/db/version_set.h b/db/version_set.h index a2a033676..1d92629f1 100644 --- a/db/version_set.h +++ b/db/version_set.h @@ -469,10 +469,6 @@ class VersionSet { // we have too many level 0 files bool need_slowdown_for_num_level0_files_; - // Per-level key at which the next compaction at that level should start. - // Either an empty string, or a valid InternalKey. - std::string* compact_pointer_; - // An object that keeps all the compaction stats // and picks the next compaction std::unique_ptr compaction_picker_; diff --git a/db/version_set_reduce_num_levels.cc b/db/version_set_reduce_num_levels.cc index c081d2c58..68b84dab1 100644 --- a/db/version_set_reduce_num_levels.cc +++ b/db/version_set_reduce_num_levels.cc @@ -67,9 +67,7 @@ Status VersionSet::ReduceNumberOfLevels(int new_levels, port::Mutex* mu) { current_version->files_ = new_files_list; current_version->num_levels_ = new_levels; - delete[] compact_pointer_; num_levels_ = new_levels; - compact_pointer_ = new std::string[new_levels]; compaction_picker_->ReduceNumberOfLevels(new_levels); VersionEdit ve; st = LogAndApply(&ve, mu, true);