| 2694 | } |
| 2695 | |
| 2696 | bool BlockBasedTable::TEST_KeyInCache(const ReadOptions& options, |
| 2697 | const Slice& key) { |
| 2698 | std::unique_ptr<InternalIteratorBase<BlockHandle>> iiter( |
| 2699 | NewIndexIterator(options)); |
| 2700 | iiter->Seek(key); |
| 2701 | assert(iiter->Valid()); |
| 2702 | CachableEntry<Block> block; |
| 2703 | |
| 2704 | BlockHandle handle = iiter->value(); |
| 2705 | Cache* block_cache = rep_->table_options.block_cache.get(); |
| 2706 | assert(block_cache != nullptr); |
| 2707 | |
| 2708 | char cache_key_storage[kMaxCacheKeyPrefixSize + kMaxVarint64Length]; |
| 2709 | Slice cache_key = |
| 2710 | GetCacheKey(rep_->cache_key_prefix, rep_->cache_key_prefix_size, handle, |
| 2711 | cache_key_storage); |
| 2712 | Slice ckey; |
| 2713 | |
| 2714 | Status s; |
| 2715 | s = GetDataBlockFromCache( |
| 2716 | cache_key, ckey, block_cache, nullptr, rep_, options, &block, |
| 2717 | rep_->compression_dict_block ? rep_->compression_dict_block->data |
| 2718 | : Slice(), |
| 2719 | 0 /* read_amp_bytes_per_bit */); |
| 2720 | assert(s.ok()); |
| 2721 | bool in_cache = block.value != nullptr; |
| 2722 | if (in_cache) { |
| 2723 | ReleaseCachedEntry(block_cache, block.cache_handle); |
| 2724 | } |
| 2725 | return in_cache; |
| 2726 | } |
| 2727 | |
| 2728 | BlockBasedTableOptions::IndexType BlockBasedTable::GetIndexType( |
| 2729 | const TableProperties* table_properties) { |