MCPcopy Create free account
hub / github.com/ElementsProject/elements / CompactMemTable

Method CompactMemTable

src/leveldb/db/db_impl.cc:545–576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

543}
544
545void DBImpl::CompactMemTable() {
546 mutex_.AssertHeld();
547 assert(imm_ != nullptr);
548
549 // Save the contents of the memtable as a new Table
550 VersionEdit edit;
551 Version* base = versions_->current();
552 base->Ref();
553 Status s = WriteLevel0Table(imm_, &edit, base);
554 base->Unref();
555
556 if (s.ok() && shutting_down_.load(std::memory_order_acquire)) {
557 s = Status::IOError("Deleting DB during memtable compaction");
558 }
559
560 // Replace immutable memtable with the generated Table
561 if (s.ok()) {
562 edit.SetPrevLogNumber(0);
563 edit.SetLogNumber(logfile_number_); // Earlier logs no longer needed
564 s = versions_->LogAndApply(&edit, &mutex_);
565 }
566
567 if (s.ok()) {
568 // Commit to the new state
569 imm_->Unref();
570 imm_ = nullptr;
571 has_imm_.store(false, std::memory_order_release);
572 DeleteObsoleteFiles();
573 } else {
574 RecordBackgroundError(s);
575 }
576}
577
578void DBImpl::CompactRange(const Slice* begin, const Slice* end) {
579 int max_level_with_files = 1;

Callers

nothing calls this directly

Calls 8

IOErrorFunction · 0.85
currentMethod · 0.80
SetPrevLogNumberMethod · 0.80
SetLogNumberMethod · 0.80
LogAndApplyMethod · 0.80
RefMethod · 0.45
UnrefMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected