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

Function moduleLateDefrag

src/module.cpp:9361–9381  ·  view source on GitHub ↗

Perform a late defrag of a module datatype key. * * Returns a zero value (and initializes the cursor) if no more needs to be done, * or a non-zero value otherwise. */

Source from the content-addressed store, hash-verified

9359 * or a non-zero value otherwise.
9360 */
9361int moduleLateDefrag(robj *key, robj *value, unsigned long *cursor, long long endtime, long long *defragged) {
9362 moduleValue *mv = (moduleValue*)ptrFromObj(value);
9363 moduleType *mt = mv->type;
9364
9365 RedisModuleDefragCtx defrag_ctx = { 0, endtime, cursor };
9366
9367 /* Invoke callback. Note that the callback may be missing if the key has been
9368 * replaced with a different type since our last visit.
9369 */
9370 int ret = 0;
9371 if (mt->defrag)
9372 ret = mt->defrag(&defrag_ctx, key, &mv->value);
9373
9374 *defragged += defrag_ctx.defragged;
9375 if (!ret) {
9376 *cursor = 0; /* No more work to do */
9377 return 0;
9378 }
9379
9380 return 1;
9381}
9382
9383/* Attempt to defrag a module data type value. Depending on complexity,
9384 * the operation may happen immediately or be scheduled for later.

Callers 1

defragLaterItemFunction · 0.85

Calls 1

ptrFromObjFunction · 0.85

Tested by

no test coverage detected