MCPcopy Create free account
hub / github.com/apache/impala / EmplaceAndGet

Method EmplaceAndGet

be/src/util/lru-multi-cache.inline.h:153–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151template <typename KeyType, typename ValueType>
152template <typename... Args>
153auto LruMultiCache<KeyType, ValueType>::EmplaceAndGet(const KeyType& key, Args&&... args)
154 -> Accessor {
155 std::lock_guard<SpinLock> g(lock_);
156
157 // creates default container if there isn't one
158 Container& container = hash_table_[key];
159
160 // Get the reference of the key stored in unordered_map, the parameter could be
161 // temporary object but std::unordered_map has stable references
162 const KeyType& stored_key = hash_table_.find(key)->first;
163
164 // Place it as the last entry for the owning list, as it just got reserved
165 auto container_it = container.emplace(
166 container.end(), (*this), stored_key, container, std::forward<Args>(args)...);
167
168 // Only can set this after emplace
169 container_it->it = container_it;
170
171 size_++;
172
173 // Need to remove the oldest available if the cache is over the capacity
174 EvictOneIfNeeded();
175
176 return Accessor(&(*container_it));
177}
178
179template <typename KeyType, typename ValueType>
180void LruMultiCache<KeyType, ValueType>::Release(ValueType_internal* p_value_internal) {

Callers 2

GetFileHandleMethod · 0.80
TESTFunction · 0.80

Calls 3

AccessorClass · 0.70
findMethod · 0.45
endMethod · 0.45

Tested by 1

TESTFunction · 0.64