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

Function AddBoundaryInputs

src/leveldb/db/version_set.cc:1355–1378  ·  view source on GitHub ↗

Extracts the largest file b1 from |compaction_files| and then searches for a b2 in |level_files| for which user_key(u1) = user_key(l2). If it finds such a file b2 (known as a boundary file) it adds it to |compaction_files| and then searches again using this new upper bound. If there are two blocks, b1=(l1, u1) and b2=(l2, u2) and user_key(u1) = user_key(l2), and if we compact b1 but not b2 then a

Source from the content-addressed store, hash-verified

1353// in level_files: List of files to search for boundary files.
1354// in/out compaction_files: List of files to extend by adding boundary files.
1355void AddBoundaryInputs(const InternalKeyComparator& icmp,
1356 const std::vector<FileMetaData*>& level_files,
1357 std::vector<FileMetaData*>* compaction_files) {
1358 InternalKey largest_key;
1359
1360 // Quick return if compaction_files is empty.
1361 if (!FindLargestKey(icmp, *compaction_files, &largest_key)) {
1362 return;
1363 }
1364
1365 bool continue_searching = true;
1366 while (continue_searching) {
1367 FileMetaData* smallest_boundary_file =
1368 FindSmallestBoundaryFile(icmp, level_files, largest_key);
1369
1370 // If a boundary file was found advance largest_key, otherwise we're done.
1371 if (smallest_boundary_file != NULL) {
1372 compaction_files->push_back(smallest_boundary_file);
1373 largest_key = smallest_boundary_file->largest;
1374 } else {
1375 continue_searching = false;
1376 }
1377 }
1378}
1379
1380void VersionSet::SetupOtherInputs(Compaction* c) {
1381 const int level = c->level();

Callers 2

TESTFunction · 0.85
SetupOtherInputsMethod · 0.85

Calls 3

FindLargestKeyFunction · 0.85
FindSmallestBoundaryFileFunction · 0.85
push_backMethod · 0.45

Tested by 1

TESTFunction · 0.68