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

Method GetOverlappingInputs

src/leveldb/db/version_set.cc:499–539  ·  view source on GitHub ↗

Store in "*inputs" all files in "level" that overlap [begin,end]

Source from the content-addressed store, hash-verified

497
498// Store in "*inputs" all files in "level" that overlap [begin,end]
499void Version::GetOverlappingInputs(int level, const InternalKey* begin,
500 const InternalKey* end,
501 std::vector<FileMetaData*>* inputs) {
502 assert(level >= 0);
503 assert(level < config::kNumLevels);
504 inputs->clear();
505 Slice user_begin, user_end;
506 if (begin != nullptr) {
507 user_begin = begin->user_key();
508 }
509 if (end != nullptr) {
510 user_end = end->user_key();
511 }
512 const Comparator* user_cmp = vset_->icmp_.user_comparator();
513 for (size_t i = 0; i < files_[level].size();) {
514 FileMetaData* f = files_[level][i++];
515 const Slice file_start = f->smallest.user_key();
516 const Slice file_limit = f->largest.user_key();
517 if (begin != nullptr && user_cmp->Compare(file_limit, user_begin) < 0) {
518 // "f" is completely before specified range; skip it
519 } else if (end != nullptr && user_cmp->Compare(file_start, user_end) > 0) {
520 // "f" is completely after specified range; skip it
521 } else {
522 inputs->push_back(f);
523 if (level == 0) {
524 // Level-0 files may overlap each other. So check if the newly
525 // added file has expanded the range. If so, restart search.
526 if (begin != nullptr && user_cmp->Compare(file_start, user_begin) < 0) {
527 user_begin = file_start;
528 inputs->clear();
529 i = 0;
530 } else if (end != nullptr &&
531 user_cmp->Compare(file_limit, user_end) > 0) {
532 user_end = file_limit;
533 inputs->clear();
534 i = 0;
535 }
536 }
537 }
538 }
539}
540
541std::string Version::DebugString() const {
542 std::string r;

Callers 4

PickCompactionMethod · 0.80
SetupOtherInputsMethod · 0.80
CompactRangeMethod · 0.80

Calls 6

clearMethod · 0.45
user_keyMethod · 0.45
user_comparatorMethod · 0.45
sizeMethod · 0.45
CompareMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected