MCPcopy Create free account
hub / github.com/baidu/tera / Find

Method Find

src/leveldb/persistent_cache/hash_table.h:106–122  ·  view source on GitHub ↗

Read hash table Please note that read lock should be held by the caller. This is because the caller owns the data, and should hold the read lock as long as he operates on the data.

Source from the content-addressed store, hash-verified

104 // the caller owns the data, and should hold the read lock as long as he
105 // operates on the data.
106 bool Find(const T& t, T* ret, RWMutex** ret_lock) {
107 const uint64_t h = Hash()(t);
108 const uint32_t bucket_idx = h % nbuckets_;
109 const uint32_t lock_idx = bucket_idx % nlocks_;
110
111 RWMutex& lock = locks_[lock_idx];
112 lock.ReadLock();
113
114 auto& bucket = buckets_[bucket_idx];
115 if (Find(&bucket, t, ret)) {
116 *ret_lock = &lock;
117 return true;
118 }
119
120 lock.ReadUnlock();
121 return false;
122 }
123
124 //
125 // Erase a given key from the hash table

Callers 1

LookupMethod · 0.45

Calls 4

EqualClass · 0.85
HashClass · 0.70
ReadLockMethod · 0.45
ReadUnlockMethod · 0.45

Tested by

no test coverage detected