| 88 | } |
| 89 | |
| 90 | bool FilterBlockReader::KeyMayMatch(uint64_t block_offset, const Slice& key) { |
| 91 | uint64_t index = block_offset >> base_lg_; |
| 92 | if (index < num_) { |
| 93 | uint32_t start = DecodeFixed32(offset_ + index * 4); |
| 94 | uint32_t limit = DecodeFixed32(offset_ + index * 4 + 4); |
| 95 | if (start <= limit && limit <= static_cast<size_t>(offset_ - data_)) { |
| 96 | Slice filter = Slice(data_ + start, limit - start); |
| 97 | return policy_->KeyMayMatch(key, filter); |
| 98 | } else if (start == limit) { |
| 99 | // Empty filters do not match any keys |
| 100 | return false; |
| 101 | } |
| 102 | } |
| 103 | return true; // Errors are treated as potential matches |
| 104 | } |
| 105 | |
| 106 | } // namespace leveldb |
no test coverage detected