提交 f9dc3cb0 编写于 作者: A antirez

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.
上级 261da523
......@@ -1243,6 +1243,41 @@ void pfdebugCommand(redisClient *c) {
HLL_DENSE_GET_REGISTER(val,hdr->registers,j);
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 {
addReplyErrorFormat(c,"Unknown PFDEBUG subcommand '%s'", cmd);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册