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

Function FindFile

src/leveldb/db/version_set.cc:88–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88int FindFile(const InternalKeyComparator& icmp,
89 const std::vector<FileMetaData*>& files, const Slice& key) {
90 uint32_t left = 0;
91 uint32_t right = files.size();
92 while (left < right) {
93 uint32_t mid = (left + right) / 2;
94 const FileMetaData* f = files[mid];
95 if (icmp.InternalKeyComparator::Compare(f->largest.Encode(), key) < 0) {
96 // Key at "mid.largest" is < "target". Therefore all
97 // files at or before "mid" are uninteresting.
98 left = mid + 1;
99 } else {
100 // Key at "mid.largest" is >= "target". Therefore all files
101 // after "mid" are uninteresting.
102 right = mid;
103 }
104 }
105 return right;
106}
107
108static bool AfterFile(const Comparator* ucmp, const Slice* user_key,
109 const FileMetaData* f) {

Callers 4

FindMethod · 0.85
SomeFileOverlapsRangeFunction · 0.85
SeekMethod · 0.85
ForEachOverlappingMethod · 0.85

Calls 2

sizeMethod · 0.45
EncodeMethod · 0.45

Tested by 1

FindMethod · 0.68