MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Lookup

Method Lookup

tensorflow/core/platform/cloud/ram_file_block_cache.cc:33–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31}
32
33std::shared_ptr<RamFileBlockCache::Block> RamFileBlockCache::Lookup(
34 const Key& key) {
35 mutex_lock lock(mu_);
36 auto entry = block_map_.find(key);
37 if (entry != block_map_.end()) {
38 if (BlockNotStale(entry->second)) {
39 return entry->second;
40 } else {
41 // Remove the stale block and continue.
42 RemoveFile_Locked(key.first);
43 }
44 }
45
46 // Insert a new empty block, setting the bookkeeping to sentinel values
47 // in order to update them as appropriate.
48 auto new_entry = std::make_shared<Block>();
49 lru_list_.push_front(key);
50 lra_list_.push_front(key);
51 new_entry->lru_iterator = lru_list_.begin();
52 new_entry->lra_iterator = lra_list_.begin();
53 new_entry->timestamp = env_->NowSeconds();
54 block_map_.emplace(std::make_pair(key, new_entry));
55 return new_entry;
56}
57
58// Remove blocks from the cache until we do not exceed our maximum size.
59void RamFileBlockCache::Trim() {

Callers 2

TESTFunction · 0.45
LoadBufferFromGCSMethod · 0.45

Calls 6

push_frontMethod · 0.80
findMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
NowSecondsMethod · 0.45
emplaceMethod · 0.45

Tested by 1

TESTFunction · 0.36