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

Method PickLevelForMemTableOutput

src/leveldb/db/version_set.cc:471–496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469}
470
471int Version::PickLevelForMemTableOutput(const Slice& smallest_user_key,
472 const Slice& largest_user_key) {
473 int level = 0;
474 if (!OverlapInLevel(0, &smallest_user_key, &largest_user_key)) {
475 // Push to next level if there is no overlap in next level,
476 // and the #bytes overlapping in the level after that are limited.
477 InternalKey start(smallest_user_key, kMaxSequenceNumber, kValueTypeForSeek);
478 InternalKey limit(largest_user_key, 0, static_cast<ValueType>(0));
479 std::vector<FileMetaData*> overlaps;
480 while (level < config::kMaxMemCompactLevel) {
481 if (OverlapInLevel(level + 1, &smallest_user_key, &largest_user_key)) {
482 break;
483 }
484 if (level + 2 < config::kNumLevels) {
485 // Check that file does not overlap too many grandparent bytes.
486 GetOverlappingInputs(level + 2, &start, &limit, &overlaps);
487 const int64_t sum = TotalFileSize(overlaps);
488 if (sum > MaxGrandParentOverlapBytes(vset_->options_)) {
489 break;
490 }
491 }
492 level++;
493 }
494 }
495 return level;
496}
497
498// Store in "*inputs" all files in "level" that overlap [begin,end]
499void Version::GetOverlappingInputs(int level, const InternalKey* begin,

Callers 1

WriteLevel0TableMethod · 0.80

Calls 2

TotalFileSizeFunction · 0.85

Tested by

no test coverage detected