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

Method FinishCompactionOutputFile

src/leveldb/db/db_impl.cc:821–868  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

819}
820
821Status DBImpl::FinishCompactionOutputFile(CompactionState* compact,
822 Iterator* input) {
823 assert(compact != nullptr);
824 assert(compact->outfile != nullptr);
825 assert(compact->builder != nullptr);
826
827 const uint64_t output_number = compact->current_output()->number;
828 assert(output_number != 0);
829
830 // Check for iterator errors
831 Status s = input->status();
832 const uint64_t current_entries = compact->builder->NumEntries();
833 if (s.ok()) {
834 s = compact->builder->Finish();
835 } else {
836 compact->builder->Abandon();
837 }
838 const uint64_t current_bytes = compact->builder->FileSize();
839 compact->current_output()->file_size = current_bytes;
840 compact->total_bytes += current_bytes;
841 delete compact->builder;
842 compact->builder = nullptr;
843
844 // Finish and check for file errors
845 if (s.ok()) {
846 s = compact->outfile->Sync();
847 }
848 if (s.ok()) {
849 s = compact->outfile->Close();
850 }
851 delete compact->outfile;
852 compact->outfile = nullptr;
853
854 if (s.ok() && current_entries > 0) {
855 // Verify that the table is usable
856 Iterator* iter =
857 table_cache_->NewIterator(ReadOptions(), output_number, current_bytes);
858 s = iter->status();
859 delete iter;
860 if (s.ok()) {
861 Log(options_.info_log, "Generated table #%llu@%d: %lld keys, %lld bytes",
862 (unsigned long long)output_number, compact->compaction->level(),
863 (unsigned long long)current_entries,
864 (unsigned long long)current_bytes);
865 }
866 }
867 return s;
868}
869
870Status DBImpl::InstallCompactionResults(CompactionState* compact) {
871 mutex_.AssertHeld();

Callers

nothing calls this directly

Calls 12

LogFunction · 0.85
current_outputMethod · 0.80
NumEntriesMethod · 0.80
AbandonMethod · 0.80
levelMethod · 0.80
ReadOptionsClass · 0.50
statusMethod · 0.45
FinishMethod · 0.45
FileSizeMethod · 0.45
SyncMethod · 0.45
CloseMethod · 0.45
NewIteratorMethod · 0.45

Tested by

no test coverage detected