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

Method Insert

be/src/kudu/util/cache.cc:422–471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420
421template<Cache::EvictionPolicy policy>
422Cache::Handle* CacheShard<policy>::Insert(
423 RLHandle* handle,
424 Cache::EvictionCallback* eviction_callback) {
425 // Set the remaining RLHandle members which were not already allocated during
426 // Allocate().
427 handle->eviction_callback = eviction_callback;
428 // Two refs for the handle: one from CacheShard, one for the returned handle.
429 handle->refs.store(2, std::memory_order_relaxed);
430 UpdateMemTracker(handle->charge);
431 if (PREDICT_TRUE(metrics_)) {
432 metrics_->cache_usage->IncrementBy(handle->charge);
433 metrics_->inserts->Increment();
434 }
435
436 RLHandle* to_remove_head = nullptr;
437 {
438 std::lock_guard<decltype(mutex_)> l(mutex_);
439
440 RL_Append(handle);
441
442 RLHandle* old = table_.Insert(handle);
443 if (old != nullptr) {
444 RL_Remove(old);
445 if (Unref(old)) {
446 old->next = to_remove_head;
447 to_remove_head = old;
448 }
449 }
450
451 while (usage_ > capacity_ && rl_.next != &rl_) {
452 RLHandle* old = rl_.next;
453 RL_Remove(old);
454 table_.Remove(old->key(), old->hash);
455 if (Unref(old)) {
456 old->next = to_remove_head;
457 to_remove_head = old;
458 }
459 }
460 }
461
462 // we free the entries here outside of mutex for
463 // performance reasons
464 while (to_remove_head != nullptr) {
465 RLHandle* next = to_remove_head->next;
466 FreeEntry(to_remove_head);
467 to_remove_head = next;
468 }
469
470 return reinterpret_cast<Cache::Handle*>(handle);
471}
472
473template<Cache::EvictionPolicy policy>
474void CacheShard<policy>::Erase(const Slice& key, uint32_t hash) {

Callers 12

InsertIntoCacheMethod · 0.45
DoQueriesMethod · 0.45
TEST_FFunction · 0.45
InsertMethod · 0.45
PutMethod · 0.45
LookupMethod · 0.45
InsertIntoCacheMethod · 0.45
LoadMetaCacheMethod · 0.45
StoreInternalMethod · 0.45
BenchmarkFunction · 0.45
TestDataMethod · 0.45
BuildFunction · 0.45

Calls 5

storeMethod · 0.45
IncrementByMethod · 0.45
IncrementMethod · 0.45
RemoveMethod · 0.45
keyMethod · 0.45

Tested by 2

TEST_FFunction · 0.36
TestDataMethod · 0.36