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

Function dictDefragTables

src/defrag.cpp:187–201  ·  view source on GitHub ↗

Defrag helper for dict main allocations (dict struct, and hash tables). * receives a pointer to the dict* and implicitly updates it when the dict * struct itself was moved. Returns a stat of how many pointers were moved. */

Source from the content-addressed store, hash-verified

185 * receives a pointer to the dict* and implicitly updates it when the dict
186 * struct itself was moved. Returns a stat of how many pointers were moved. */
187long dictDefragTables(dict* d) {
188 dictEntry **newtable;
189 long defragged = 0;
190 /* handle the first hash table */
191 newtable = (dictEntry**)activeDefragAlloc(d->ht[0].table);
192 if (newtable)
193 defragged++, d->ht[0].table = newtable;
194 /* handle the second hash table */
195 if (d->ht[1].table) {
196 newtable = (dictEntry**)activeDefragAlloc(d->ht[1].table);
197 if (newtable)
198 defragged++, d->ht[1].table = newtable;
199 }
200 return defragged;
201}
202
203/* Internal function used by zslDefrag */
204void zslUpdateNode(zskiplist *zsl, zskiplistNode *oldnode, zskiplistNode *newnode, zskiplistNode **update) {

Callers 3

defragZsetSkiplistFunction · 0.85
defragHashFunction · 0.85
defragSetFunction · 0.85

Calls 1

activeDefragAllocFunction · 0.85

Tested by

no test coverage detected