MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / ckh_try_insert

Function ckh_try_insert

deps/jemalloc/src/ckh.c:204–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204static bool
205ckh_try_insert(ckh_t *ckh, void const**argkey, void const**argdata) {
206 size_t hashes[2], bucket;
207 const void *key = *argkey;
208 const void *data = *argdata;
209
210 ckh->hash(key, hashes);
211
212 /* Try to insert in primary bucket. */
213 bucket = hashes[0] & ((ZU(1) << ckh->lg_curbuckets) - 1);
214 if (!ckh_try_bucket_insert(ckh, bucket, key, data)) {
215 return false;
216 }
217
218 /* Try to insert in secondary bucket. */
219 bucket = hashes[1] & ((ZU(1) << ckh->lg_curbuckets) - 1);
220 if (!ckh_try_bucket_insert(ckh, bucket, key, data)) {
221 return false;
222 }
223
224 /*
225 * Try to find a place for this item via iterative eviction/relocation.
226 */
227 return ckh_evict_reloc_insert(ckh, bucket, argkey, argdata);
228}
229
230/*
231 * Try to rebuild the hash table from scratch by inserting all items from the

Callers 2

ckh_rebuildFunction · 0.70
ckh_insertFunction · 0.70

Calls 3

ckh_try_bucket_insertFunction · 0.70
ckh_evict_reloc_insertFunction · 0.70
hashMethod · 0.45

Tested by

no test coverage detected