MCPcopy Create free account
hub / github.com/bytedance/terarkdb / TEST_KeyInCache

Method TEST_KeyInCache

table/block_based_table_reader.cc:2696–2726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2694}
2695
2696bool 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
2728BlockBasedTableOptions::IndexType BlockBasedTable::GetIndexType(
2729 const TableProperties* table_properties) {

Callers 2

AssertKeysInCacheFunction · 0.80
TEST_PFunction · 0.80

Calls 7

ReleaseCachedEntryFunction · 0.85
SliceClass · 0.70
SeekMethod · 0.45
ValidMethod · 0.45
valueMethod · 0.45
getMethod · 0.45
okMethod · 0.45

Tested by 2

AssertKeysInCacheFunction · 0.64
TEST_PFunction · 0.64