MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pfdebugCommand

Function pfdebugCommand

app/redis-6.2.6/src/hyperloglog.c:1493–1594  ·  view source on GitHub ↗

PFDEBUG ... args ... * Different debugging related operations about the HLL implementation. */

Source from the content-addressed store, hash-verified

1491/* PFDEBUG <subcommand> <key> ... args ...
1492 * Different debugging related operations about the HLL implementation. */
1493void pfdebugCommand(client *c) {
1494 char *cmd = c->argv[1]->ptr;
1495 struct hllhdr *hdr;
1496 robj *o;
1497 int j;
1498
1499 o = lookupKeyWrite(c->db,c->argv[2]);
1500 if (o == NULL) {
1501 addReplyError(c,"The specified key does not exist");
1502 return;
1503 }
1504 if (isHLLObjectOrReply(c,o) != C_OK) return;
1505 o = dbUnshareStringValue(c->db,c->argv[2],o);
1506 hdr = o->ptr;
1507
1508 /* PFDEBUG GETREG <key> */
1509 if (!strcasecmp(cmd,"getreg")) {
1510 if (c->argc != 3) goto arityerr;
1511
1512 if (hdr->encoding == HLL_SPARSE) {
1513 if (hllSparseToDense(o) == C_ERR) {
1514 addReplyError(c,invalid_hll_err);
1515 return;
1516 }
1517 server.dirty++; /* Force propagation on encoding change. */
1518 }
1519
1520 hdr = o->ptr;
1521 addReplyArrayLen(c,HLL_REGISTERS);
1522 for (j = 0; j < HLL_REGISTERS; j++) {
1523 uint8_t val;
1524
1525 HLL_DENSE_GET_REGISTER(val,hdr->registers,j);
1526 addReplyLongLong(c,val);
1527 }
1528 }
1529 /* PFDEBUG DECODE <key> */
1530 else if (!strcasecmp(cmd,"decode")) {
1531 if (c->argc != 3) goto arityerr;
1532
1533 uint8_t *p = o->ptr, *end = p+sdslen(o->ptr);
1534 sds decoded = sdsempty();
1535
1536 if (hdr->encoding != HLL_SPARSE) {
1537 sdsfree(decoded);
1538 addReplyError(c,"HLL encoding is not sparse");
1539 return;
1540 }
1541
1542 p += HLL_HDR_SIZE;
1543 while(p < end) {
1544 int runlen, regval;
1545
1546 if (HLL_SPARSE_IS_ZERO(p)) {
1547 runlen = HLL_SPARSE_ZERO_LEN(p);
1548 p++;
1549 decoded = sdscatprintf(decoded,"z:%d ",runlen);
1550 } else if (HLL_SPARSE_IS_XZERO(p)) {

Callers

nothing calls this directly

Calls 15

lookupKeyWriteFunction · 0.85
addReplyErrorFunction · 0.85
isHLLObjectOrReplyFunction · 0.85
dbUnshareStringValueFunction · 0.85
strcasecmpFunction · 0.85
hllSparseToDenseFunction · 0.85
addReplyArrayLenFunction · 0.85
addReplyLongLongFunction · 0.85
sdslenFunction · 0.85
sdsemptyFunction · 0.85
sdsfreeFunction · 0.85
sdscatprintfFunction · 0.85

Tested by

no test coverage detected