PFDEBUG DECODE added.
Provides a human readable description of the opcodes composing a run-length encoded HLL (sparse encoding). The command is only useful for debugging / development tasks.
This commit is contained in:
parent
261da523e8
commit
f9dc3cb04d
@ -1243,6 +1243,41 @@ void pfdebugCommand(redisClient *c) {
|
|||||||
HLL_DENSE_GET_REGISTER(val,hdr->registers,j);
|
HLL_DENSE_GET_REGISTER(val,hdr->registers,j);
|
||||||
addReplyLongLong(c,val);
|
addReplyLongLong(c,val);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
/* PFDEBUG DECODE <key> */
|
||||||
|
else if (!strcasecmp(cmd,"decode")) {
|
||||||
|
if (c->argc != 3) goto arityerr;
|
||||||
|
|
||||||
|
uint8_t *p = o->ptr, *end = p+sdslen(o->ptr);
|
||||||
|
sds decoded = sdsempty();
|
||||||
|
|
||||||
|
if (hdr->encoding != HLL_SPARSE) {
|
||||||
|
addReplyError(c,"HLL encoding is not sparse");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
p += HLL_HDR_SIZE;
|
||||||
|
while(p < end) {
|
||||||
|
int runlen, regval;
|
||||||
|
|
||||||
|
if (HLL_SPARSE_IS_ZERO(p)) {
|
||||||
|
runlen = HLL_SPARSE_ZERO_LEN(p);
|
||||||
|
p++;
|
||||||
|
decoded = sdscatprintf(decoded,"z:%d ",runlen);
|
||||||
|
} else if (HLL_SPARSE_IS_XZERO(p)) {
|
||||||
|
runlen = HLL_SPARSE_XZERO_LEN(p);
|
||||||
|
p += 2;
|
||||||
|
decoded = sdscatprintf(decoded,"Z:%d ",runlen);
|
||||||
|
} else {
|
||||||
|
runlen = HLL_SPARSE_VAL_LEN(p);
|
||||||
|
regval = HLL_SPARSE_VAL_VALUE(p);
|
||||||
|
p++;
|
||||||
|
decoded = sdscatprintf(decoded,"v:%d,%d ",regval,runlen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
decoded = sdstrim(decoded," ");
|
||||||
|
addReplyBulkCBuffer(c,decoded,sdslen(decoded));
|
||||||
|
sdsfree(decoded);
|
||||||
} else {
|
} else {
|
||||||
addReplyErrorFormat(c,"Unknown PFDEBUG subcommand '%s'", cmd);
|
addReplyErrorFormat(c,"Unknown PFDEBUG subcommand '%s'", cmd);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user