MCPcopy Create free account
hub / github.com/baidu/tera / IsBaseLevelForKey

Method IsBaseLevelForKey

src/leveldb/db/version_set.cc:3058–3077  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3056}
3057
3058bool Compaction::IsBaseLevelForKey(const Slice& user_key) {
3059 // Maybe use binary search to find right entry instead of linear search?
3060 const Comparator* user_cmp = input_version_->vset_->icmp_.user_comparator();
3061 for (int lvl = output_level_ + 1; lvl < config::kNumLevels; lvl++) {
3062 const std::vector<FileMetaData*>& files = input_version_->files_[lvl];
3063 for (; level_ptrs_[lvl] < files.size();) {
3064 FileMetaData* f = files[level_ptrs_[lvl]];
3065 if (user_cmp->Compare(user_key, f->largest.user_key()) <= 0) {
3066 // We've advanced far enough
3067 if (user_cmp->Compare(user_key, f->smallest.user_key()) >= 0) {
3068 // Key falls in this file's range, so definitely not base level
3069 return false;
3070 }
3071 break;
3072 }
3073 level_ptrs_[lvl]++;
3074 }
3075 }
3076 return true;
3077}
3078
3079bool Compaction::ShouldStopBefore(const Slice& internal_key) {
3080 // Scan to find earliest grandparent file that contains key.

Callers 1

HandleCompactionWorkMethod · 0.80

Calls 4

user_comparatorMethod · 0.45
sizeMethod · 0.45
CompareMethod · 0.45
user_keyMethod · 0.45

Tested by

no test coverage detected