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

Function defragStream

src/defrag.cpp:798–819  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

796}
797
798long defragStream(redisDb *db, dictEntry *kde) {
799 long defragged = 0;
800 robj *ob = (robj*)dictGetVal(kde);
801 serverAssert(ob->type == OBJ_STREAM && ob->encoding == OBJ_ENCODING_STREAM);
802 stream *s = (stream*)ptrFromObj(ob), *news;
803
804 /* handle the main struct */
805 if ((news = (stream*)activeDefragAlloc(s)))
806 defragged++, ob->m_ptr = s = news;
807
808 if (raxSize(s->rax) > cserver.active_defrag_max_scan_fields) {
809 rax *newrax = (rax*)activeDefragAlloc(s->rax);
810 if (newrax)
811 defragged++, s->rax = newrax;
812 defragLater(db, kde);
813 } else
814 defragged += defragRadixTree(&s->rax, 1, NULL, NULL);
815
816 if (s->cgroups)
817 defragged += defragRadixTree(&s->cgroups, 1, defragStreamConsumerGroup, NULL);
818 return defragged;
819}
820
821/* Defrag a module key. This is either done immediately or scheduled
822 * for later. Returns then number of pointers defragged.

Callers 1

defragKeyFunction · 0.85

Calls 5

ptrFromObjFunction · 0.85
activeDefragAllocFunction · 0.85
raxSizeFunction · 0.85
defragLaterFunction · 0.85
defragRadixTreeFunction · 0.85

Tested by

no test coverage detected