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

Method ShardedCache

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

Source from the content-addressed store, hash-verified

546class ShardedCache : public Cache {
547 public:
548 explicit ShardedCache(size_t capacity, const string& id)
549 : shard_bits_(DetermineShardBits()) {
550 // A cache is often a singleton, so:
551 // 1. We reuse its MemTracker if one already exists, and
552 // 2. It is directly parented to the root MemTracker.
553 mem_tracker_ = MemTracker::FindOrCreateGlobalTracker(
554 -1, strings::Substitute("$0-sharded_$1_cache", id, ToString(policy)));
555
556 int num_shards = 1 << shard_bits_;
557 const size_t per_shard = (capacity + (num_shards - 1)) / num_shards;
558 for (int s = 0; s < num_shards; s++) {
559 unique_ptr<CacheShard<policy>> shard(
560 new CacheShard<policy>(mem_tracker_.get()));
561 shard->SetCapacity(per_shard);
562 shards_.push_back(shard.release());
563 }
564 }
565
566 virtual ~ShardedCache() {
567 STLDeleteElements(&shards_);

Callers

nothing calls this directly

Calls 7

SubstituteFunction · 0.85
push_backMethod · 0.80
DetermineShardBitsFunction · 0.70
ToStringFunction · 0.70
getMethod · 0.65
SetCapacityMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected