mirror of https://github.com/facebook/rocksdb.git
Merge branch 'master' into columnfamilies
Conflicts: db/version_set.cc
This commit is contained in:
commit
e25819a185
|
@ -369,12 +369,6 @@ Compaction* LevelCompactionPicker::PickCompaction(Version* version,
|
||||||
Compaction* c = nullptr;
|
Compaction* c = nullptr;
|
||||||
int level = -1;
|
int level = -1;
|
||||||
|
|
||||||
// Compute the compactions needed. It is better to do it here
|
|
||||||
// and also in LogAndApply(), otherwise the values could be stale.
|
|
||||||
std::vector<uint64_t> size_being_compacted(NumberLevels() - 1);
|
|
||||||
SizeBeingCompacted(size_being_compacted);
|
|
||||||
version->Finalize(size_being_compacted);
|
|
||||||
|
|
||||||
// We prefer compactions triggered by too much data in a level over
|
// We prefer compactions triggered by too much data in a level over
|
||||||
// the compactions triggered by seeks.
|
// the compactions triggered by seeks.
|
||||||
//
|
//
|
||||||
|
|
|
@ -469,6 +469,7 @@ Version::Version(ColumnFamilyData* cfd, VersionSet* vset,
|
||||||
refs_(0),
|
refs_(0),
|
||||||
// cfd is nullptr if Version is dummy
|
// cfd is nullptr if Version is dummy
|
||||||
num_levels_(cfd == nullptr ? 0 : cfd->NumberLevels()),
|
num_levels_(cfd == nullptr ? 0 : cfd->NumberLevels()),
|
||||||
|
finalized_(false),
|
||||||
files_(new std::vector<FileMetaData*>[num_levels_]),
|
files_(new std::vector<FileMetaData*>[num_levels_]),
|
||||||
files_by_size_(num_levels_),
|
files_by_size_(num_levels_),
|
||||||
next_file_to_compact_by_size_(num_levels_),
|
next_file_to_compact_by_size_(num_levels_),
|
||||||
|
@ -486,6 +487,7 @@ void Version::Get(const ReadOptions& options,
|
||||||
GetStats* stats,
|
GetStats* stats,
|
||||||
const Options& db_options,
|
const Options& db_options,
|
||||||
bool* value_found) {
|
bool* value_found) {
|
||||||
|
assert(finalized_);
|
||||||
Slice ikey = k.internal_key();
|
Slice ikey = k.internal_key();
|
||||||
Slice user_key = k.user_key();
|
Slice user_key = k.user_key();
|
||||||
const Comparator* ucmp = cfd_->internal_comparator().user_comparator();
|
const Comparator* ucmp = cfd_->internal_comparator().user_comparator();
|
||||||
|
@ -651,6 +653,8 @@ bool Version::UpdateStats(const GetStats& stats) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Version::Finalize(std::vector<uint64_t>& size_being_compacted) {
|
void Version::Finalize(std::vector<uint64_t>& size_being_compacted) {
|
||||||
|
assert(!finalized_);
|
||||||
|
finalized_ = true;
|
||||||
// Pre-sort level0 for Get()
|
// Pre-sort level0 for Get()
|
||||||
if (cfd_->options()->compaction_style == kCompactionStyleUniversal) {
|
if (cfd_->options()->compaction_style == kCompactionStyleUniversal) {
|
||||||
std::sort(files_[0].begin(), files_[0].end(), NewestFirstBySeqNo);
|
std::sort(files_[0].begin(), files_[0].end(), NewestFirstBySeqNo);
|
||||||
|
|
|
@ -234,6 +234,7 @@ class Version {
|
||||||
Version* prev_; // Previous version in linked list
|
Version* prev_; // Previous version in linked list
|
||||||
int refs_; // Number of live refs to this version
|
int refs_; // Number of live refs to this version
|
||||||
int num_levels_; // Number of levels
|
int num_levels_; // Number of levels
|
||||||
|
bool finalized_; // True if Finalized is called
|
||||||
|
|
||||||
// List of files per level, files in each level are arranged
|
// List of files per level, files in each level are arranged
|
||||||
// in increasing order of keys
|
// in increasing order of keys
|
||||||
|
|
Loading…
Reference in New Issue