| 86 | } |
| 87 | |
| 88 | int 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 | |
| 108 | static bool AfterFile(const Comparator* ucmp, const Slice* user_key, |
| 109 | const FileMetaData* f) { |