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
main
Igor Canadi 11 years ago
parent c699c84af4
commit 6d6fb70960
  1. 16
      db/version_edit.cc
  2. 4
      db/version_edit.h
  3. 1
      db/version_edit_test.cc
  4. 18
      db/version_set.cc
  5. 4
      db/version_set.h
  6. 2
      db/version_set_reduce_num_levels.cc

@ -69,12 +69,6 @@ void VersionEdit::EncodeTo(std::string* dst) const {
PutVarint64(dst, last_sequence_); 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(); for (DeletedFileSet::const_iterator iter = deleted_files_.begin();
iter != deleted_files_.end(); iter != deleted_files_.end();
++iter) { ++iter) {
@ -178,7 +172,9 @@ Status VersionEdit::DecodeFrom(const Slice& src) {
case kCompactPointer: case kCompactPointer:
if (GetLevel(&input, &level, &msg) && if (GetLevel(&input, &level, &msg) &&
GetInternalKey(&input, &key)) { 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 { } else {
if (!msg) { if (!msg) {
msg = "compaction pointer"; msg = "compaction pointer";
@ -267,12 +263,6 @@ std::string VersionEdit::DebugString(bool hex_key) const {
r.append("\n LastSeq: "); r.append("\n LastSeq: ");
AppendNumberTo(&r, last_sequence_); 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(); for (DeletedFileSet::const_iterator iter = deleted_files_.begin();
iter != deleted_files_.end(); iter != deleted_files_.end();
++iter) { ++iter) {

@ -59,9 +59,6 @@ class VersionEdit {
has_last_sequence_ = true; has_last_sequence_ = true;
last_sequence_ = seq; 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. // Add the specified file at the specified number.
// REQUIRES: This version has not been saved (see VersionSet::SaveTo) // REQUIRES: This version has not been saved (see VersionSet::SaveTo)
@ -117,7 +114,6 @@ class VersionEdit {
bool has_next_file_number_; bool has_next_file_number_;
bool has_last_sequence_; bool has_last_sequence_;
std::vector<std::pair<int, InternalKey> > compact_pointers_;
DeletedFileSet deleted_files_; DeletedFileSet deleted_files_;
std::vector<std::pair<int, FileMetaData> > new_files_; std::vector<std::pair<int, FileMetaData> > new_files_;
}; };

@ -36,7 +36,6 @@ TEST(VersionEditTest, EncodeDecode) {
kBig + 500 + i, kBig + 500 + i,
kBig + 600 + i); kBig + 600 + i);
edit.DeleteFile(4, kBig + 700 + i); edit.DeleteFile(4, kBig + 700 + i);
edit.SetCompactPointer(i, InternalKey("x", kBig + 900 + i, kTypeValue));
} }
edit.SetComparatorName("foo"); edit.SetComparatorName("foo");

@ -1245,13 +1245,6 @@ class VersionSet::Builder {
void Apply(VersionEdit* edit) { void Apply(VersionEdit* edit) {
CheckConsistency(base_); 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 // Delete files
const VersionEdit::DeletedFileSet& del = edit->deleted_files_; const VersionEdit::DeletedFileSet& del = edit->deleted_files_;
for (VersionEdit::DeletedFileSet::const_iterator iter = del.begin(); 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), manifest_file_size_(0),
storage_options_(storage_options), storage_options_(storage_options),
storage_options_compactions_(storage_options_) { storage_options_compactions_(storage_options_) {
compact_pointer_ = new std::string[options_->num_levels];
if (options_->compaction_style == kCompactionStyleUniversal) { if (options_->compaction_style == kCompactionStyleUniversal) {
compaction_picker_.reset(new UniversalCompactionPicker(options_, &icmp_)); compaction_picker_.reset(new UniversalCompactionPicker(options_, &icmp_));
} else { } else {
@ -1381,7 +1373,6 @@ VersionSet::~VersionSet() {
delete file; delete file;
} }
obsolete_files_.clear(); obsolete_files_.clear();
delete[] compact_pointer_;
} }
void VersionSet::AppendVersion(Version* v) { void VersionSet::AppendVersion(Version* v) {
@ -1881,15 +1872,6 @@ Status VersionSet::WriteSnapshot(log::Writer* log) {
VersionEdit edit; VersionEdit edit;
edit.SetComparatorName(icmp_.user_comparator()->Name()); 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 // Save files
for (int level = 0; level < current_->NumberLevels(); level++) { for (int level = 0; level < current_->NumberLevels(); level++) {
const std::vector<FileMetaData*>& files = current_->files_[level]; const std::vector<FileMetaData*>& files = current_->files_[level];

@ -469,10 +469,6 @@ class VersionSet {
// we have too many level 0 files // we have too many level 0 files
bool need_slowdown_for_num_level0_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 // An object that keeps all the compaction stats
// and picks the next compaction // and picks the next compaction
std::unique_ptr<CompactionPicker> compaction_picker_; std::unique_ptr<CompactionPicker> compaction_picker_;

@ -67,9 +67,7 @@ Status VersionSet::ReduceNumberOfLevels(int new_levels, port::Mutex* mu) {
current_version->files_ = new_files_list; current_version->files_ = new_files_list;
current_version->num_levels_ = new_levels; current_version->num_levels_ = new_levels;
delete[] compact_pointer_;
num_levels_ = new_levels; num_levels_ = new_levels;
compact_pointer_ = new std::string[new_levels];
compaction_picker_->ReduceNumberOfLevels(new_levels); compaction_picker_->ReduceNumberOfLevels(new_levels);
VersionEdit ve; VersionEdit ve;
st = LogAndApply(&ve, mu, true); st = LogAndApply(&ve, mu, true);

Loading…
Cancel
Save