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

Method Insert

be/src/util/cache/rl-cache.cc:381–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379
380template<Cache::EvictionPolicy policy>
381HandleBase* RLCacheShard<policy>::Insert(
382 HandleBase* handle_in,
383 Cache::EvictionCallback* eviction_callback) {
384 DCHECK(initialized_);
385 RLHandle* handle = static_cast<RLHandle*>(handle_in);
386 // Set the remaining RLHandle members which were not already allocated during
387 // Allocate().
388 handle->eviction_callback = eviction_callback;
389 // Two refs for the handle: one from RLCacheShard, one for the returned handle.
390 handle->refs.store(2, std::memory_order_relaxed);
391 UpdateMemTracker(handle->charge());
392
393 RLThreadState tstate;
394 {
395 std::lock_guard<decltype(mutex_)> l(mutex_);
396
397 RL_Append(handle);
398
399 RLHandle* old = static_cast<RLHandle*>(table_.Insert(handle));
400 if (old != nullptr) {
401 RL_Remove(old);
402 if (Unref(old)) {
403 old->next = tstate.to_remove_head;
404 tstate.to_remove_head = old;
405 }
406 }
407
408 // Evict entries as needed to enforce the capacity constraint
409 EnforceCapacity(&tstate);
410 }
411
412 // we free the entries here outside of mutex for
413 // performance reasons
414 CleanupThreadState(&tstate);
415
416 return handle;
417}
418
419template<Cache::EvictionPolicy policy>
420void RLCacheShard<policy>::Erase(const Slice& key, uint32_t hash) {

Callers 1

DoQueriesMethod · 0.45

Calls 2

chargeMethod · 0.80
storeMethod · 0.45

Tested by

no test coverage detected