Lines Matching refs:ht
63 static int _dictExpandIfNeeded(dict *ht);
65 static int _dictKeyIndex(dict *ht, const void *key);
66 static int _dictInit(dict *ht, dictType *type, void *privDataPtr);
159 static void _dictReset(dictht *ht) in _dictReset() argument
161 ht->table = NULL; in _dictReset()
162 ht->size = 0; in _dictReset()
163 ht->sizemask = 0; in _dictReset()
164 ht->used = 0; in _dictReset()
181 _dictReset(&d->ht[0]); in _dictInit()
182 _dictReset(&d->ht[1]); in _dictInit()
197 minimal = d->ht[0].used; in dictResize()
211 if (dictIsRehashing(d) || d->ht[0].used > size) in dictExpand()
215 if (realsize == d->ht[0].size) return DICT_ERR; in dictExpand()
225 if (d->ht[0].table == NULL) { in dictExpand()
226 d->ht[0] = n; in dictExpand()
231 d->ht[1] = n; in dictExpand()
249 while(n-- && d->ht[0].used != 0) { in dictRehash()
254 assert(d->ht[0].size > (unsigned long)d->rehashidx); in dictRehash()
255 while(d->ht[0].table[d->rehashidx] == NULL) { in dictRehash()
259 de = d->ht[0].table[d->rehashidx]; in dictRehash()
266 h = dictHashKey(d, de->key) & d->ht[1].sizemask; in dictRehash()
267 de->next = d->ht[1].table[h]; in dictRehash()
268 d->ht[1].table[h] = de; in dictRehash()
269 d->ht[0].used--; in dictRehash()
270 d->ht[1].used++; in dictRehash()
273 d->ht[0].table[d->rehashidx] = NULL; in dictRehash()
278 if (d->ht[0].used == 0) { in dictRehash()
279 zfree(d->ht[0].table); in dictRehash()
280 d->ht[0] = d->ht[1]; in dictRehash()
281 _dictReset(&d->ht[1]); in dictRehash()
350 dictht *ht; in dictAddRaw() local
363 ht = dictIsRehashing(d) ? &d->ht[1] : &d->ht[0]; in dictAddRaw()
365 entry->next = ht->table[index]; in dictAddRaw()
366 ht->table[index] = entry; in dictAddRaw()
367 ht->used++; in dictAddRaw()
418 if (d->ht[0].size == 0) return DICT_ERR; /* d->ht[0].table is NULL */ in dictGenericDelete()
423 idx = h & d->ht[table].sizemask; in dictGenericDelete()
424 he = d->ht[table].table[idx]; in dictGenericDelete()
432 d->ht[table].table[idx] = he->next; in dictGenericDelete()
438 d->ht[table].used--; in dictGenericDelete()
449 int dictDelete(dict *ht, const void *key) { in dictDelete() argument
450 return dictGenericDelete(ht,key,0); in dictDelete()
453 int dictDeleteNoFree(dict *ht, const void *key) { in dictDeleteNoFree() argument
454 return dictGenericDelete(ht,key,1); in dictDeleteNoFree()
458 int _dictClear(dict *d, dictht *ht, void(callback)(void *)) { in _dictClear() argument
462 for (i = 0; i < ht->size && ht->used > 0; i++) { in _dictClear()
467 if ((he = ht->table[i]) == NULL) continue; in _dictClear()
473 ht->used--; in _dictClear()
478 zfree(ht->table); in _dictClear()
480 _dictReset(ht); in _dictClear()
487 _dictClear(d,&d->ht[0],NULL); in dictRelease()
488 _dictClear(d,&d->ht[1],NULL); in dictRelease()
497 if (d->ht[0].used + d->ht[1].used == 0) return NULL; /* dict is empty */ in dictFind()
501 idx = h & d->ht[table].sizemask; in dictFind()
502 he = d->ht[table].table[idx]; in dictFind()
530 integers[0] = (long) d->ht[0].table; in dictFingerprint()
531 integers[1] = d->ht[0].size; in dictFingerprint()
532 integers[2] = d->ht[0].used; in dictFingerprint()
533 integers[3] = (long) d->ht[1].table; in dictFingerprint()
534 integers[4] = d->ht[1].size; in dictFingerprint()
535 integers[5] = d->ht[1].used; in dictFingerprint()
582 dictht *ht = &iter->d->ht[iter->table]; in dictNext() local
590 if (iter->index >= (long) ht->size) { in dictNext()
594 ht = &iter->d->ht[1]; in dictNext()
599 iter->entry = ht->table[iter->index]; in dictNext()
638 h = d->rehashidx + (random() % (d->ht[0].size + in dictGetRandomKey()
639 d->ht[1].size - in dictGetRandomKey()
641 he = (h >= d->ht[0].size) ? d->ht[1].table[h - d->ht[0].size] : in dictGetRandomKey()
642 d->ht[0].table[h]; in dictGetRandomKey()
646 h = random() & d->ht[0].sizemask; in dictGetRandomKey()
647 he = d->ht[0].table[h]; in dictGetRandomKey()
707 maxsizemask = d->ht[0].sizemask; in dictGetSomeKeys()
708 if (tables > 1 && maxsizemask < d->ht[1].sizemask) in dictGetSomeKeys()
709 maxsizemask = d->ht[1].sizemask; in dictGetSomeKeys()
724 if (i >= d->ht[1].size) i = d->rehashidx; in dictGetSomeKeys()
727 if (i >= d->ht[j].size) continue; /* Out of range for this table. */ in dictGetSomeKeys()
728 dictEntry *he = d->ht[j].table[i]; in dictGetSomeKeys()
864 t0 = &(d->ht[0]); in dictScan()
875 t0 = &d->ht[0]; in dictScan()
876 t1 = &d->ht[1]; in dictScan()
880 t0 = &d->ht[1]; in dictScan()
881 t1 = &d->ht[0]; in dictScan()
932 if (d->ht[0].size == 0) return dictExpand(d, DICT_HT_INITIAL_SIZE); in _dictExpandIfNeeded()
938 if (d->ht[0].used >= d->ht[0].size && in _dictExpandIfNeeded()
940 d->ht[0].used/d->ht[0].size > dict_force_resize_ratio)) in _dictExpandIfNeeded()
942 return dictExpand(d, d->ht[0].used*2); in _dictExpandIfNeeded()
977 idx = h & d->ht[table].sizemask; in _dictKeyIndex()
979 he = d->ht[table].table[idx]; in _dictKeyIndex()
991 _dictClear(d,&d->ht[0],callback); in dictEmpty()
992 _dictClear(d,&d->ht[1],callback); in dictEmpty()
1008 size_t _dictGetStatsHt(char *buf, size_t bufsize, dictht *ht, int tableid) { in _dictGetStatsHt() argument
1014 if (ht->used == 0) { in _dictGetStatsHt()
1021 for (i = 0; i < ht->size; i++) { in _dictGetStatsHt()
1024 if (ht->table[i] == NULL) { in _dictGetStatsHt()
1031 he = ht->table[i]; in _dictGetStatsHt()
1052 ht->size, ht->used, slots, maxchainlen, in _dictGetStatsHt()
1053 (float)totchainlen/slots, (float)ht->used/slots); in _dictGetStatsHt()
1061 i, clvector[i], ((float)clvector[i]/ht->size)*100); in _dictGetStatsHt()
1074 l = _dictGetStatsHt(buf,bufsize,&d->ht[0],0); in dictGetStats()
1078 _dictGetStatsHt(buf,bufsize,&d->ht[1],1); in dictGetStats()