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

Function activeDefragSdsDict

src/defrag.cpp:285–312  ·  view source on GitHub ↗

Defrag a dict with sds key and optional value (either ptr, sds or robj string) */

Source from the content-addressed store, hash-verified

283
284/* Defrag a dict with sds key and optional value (either ptr, sds or robj string) */
285long activeDefragSdsDict(dict* d, int val_type) {
286 dictIterator *di;
287 dictEntry *de;
288 long defragged = 0;
289 di = dictGetIterator(d);
290 while((de = dictNext(di)) != NULL) {
291 sds sdsele = (sds)dictGetKey(de), newsds;
292 if ((newsds = activeDefragSds(sdsele)))
293 de->key = newsds, defragged++;
294 /* defrag the value */
295 if (val_type == DEFRAG_SDS_DICT_VAL_IS_SDS) {
296 sdsele = (sds)dictGetVal(de);
297 if ((newsds = activeDefragSds(sdsele)))
298 de->v.val = newsds, defragged++;
299 } else if (val_type == DEFRAG_SDS_DICT_VAL_IS_STROB) {
300 robj *newele, *ele = (robj*)dictGetVal(de);
301 if ((newele = activeDefragStringOb(ele, &defragged)))
302 de->v.val = newele;
303 } else if (val_type == DEFRAG_SDS_DICT_VAL_VOID_PTR) {
304 void *newptr, *ptr = dictGetVal(de);
305 if ((newptr = activeDefragAlloc(ptr)))
306 de->v.val = newptr, defragged++;
307 }
308 defragged += dictIterDefragEntry(di);
309 }
310 dictReleaseIterator(di);
311 return defragged;
312}
313
314/* Defrag a list of ptr, sds or robj string values */
315long activeDefragList(list *l, int val_type) {

Callers 3

defragHashFunction · 0.85
defragSetFunction · 0.85
defragOtherGlobalsFunction · 0.85

Calls 7

activeDefragSdsFunction · 0.85
activeDefragStringObFunction · 0.85
activeDefragAllocFunction · 0.85
dictIterDefragEntryFunction · 0.85
dictGetIteratorFunction · 0.70
dictNextFunction · 0.70
dictReleaseIteratorFunction · 0.70

Tested by

no test coverage detected