PFDEBUG ... args ... * Different debugging related operations about the HLL implementation. */
| 1504 | /* PFDEBUG <subcommand> <key> ... args ... |
| 1505 | * Different debugging related operations about the HLL implementation. */ |
| 1506 | void pfdebugCommand(client *c) { |
| 1507 | char *cmd = szFromObj(c->argv[1]); |
| 1508 | struct hllhdr *hdr; |
| 1509 | robj *o; |
| 1510 | int j; |
| 1511 | |
| 1512 | o = lookupKeyWrite(c->db,c->argv[2]); |
| 1513 | if (o == NULL) { |
| 1514 | addReplyError(c,"The specified key does not exist"); |
| 1515 | return; |
| 1516 | } |
| 1517 | if (isHLLObjectOrReply(c,o) != C_OK) return; |
| 1518 | o = dbUnshareStringValue(c->db,c->argv[2],o); |
| 1519 | hdr = (hllhdr*)ptrFromObj(o); |
| 1520 | |
| 1521 | /* PFDEBUG GETREG <key> */ |
| 1522 | if (!strcasecmp(cmd,"getreg")) { |
| 1523 | if (c->argc != 3) goto arityerr; |
| 1524 | |
| 1525 | if (hdr->encoding == HLL_SPARSE) { |
| 1526 | if (hllSparseToDense(o) == C_ERR) { |
| 1527 | addReplyError(c,invalid_hll_err); |
| 1528 | return; |
| 1529 | } |
| 1530 | g_pserver->dirty++; /* Force propagation on encoding change. */ |
| 1531 | } |
| 1532 | |
| 1533 | hdr = (hllhdr*)ptrFromObj(o); |
| 1534 | addReplyArrayLen(c,HLL_REGISTERS); |
| 1535 | for (j = 0; j < HLL_REGISTERS; j++) { |
| 1536 | uint8_t val; |
| 1537 | |
| 1538 | HLL_DENSE_GET_REGISTER(val,hdr->registers(),j); |
| 1539 | addReplyLongLong(c,val); |
| 1540 | } |
| 1541 | } |
| 1542 | /* PFDEBUG DECODE <key> */ |
| 1543 | else if (!strcasecmp(cmd,"decode")) { |
| 1544 | if (c->argc != 3) goto arityerr; |
| 1545 | |
| 1546 | uint8_t *p = (uint8_t*)ptrFromObj(o), *end = p+sdslen(szFromObj(o)); |
| 1547 | sds decoded = sdsempty(); |
| 1548 | |
| 1549 | if (hdr->encoding != HLL_SPARSE) { |
| 1550 | sdsfree(decoded); |
| 1551 | addReplyError(c,"HLL encoding is not sparse"); |
| 1552 | return; |
| 1553 | } |
| 1554 | |
| 1555 | p += HLL_HDR_SIZE; |
| 1556 | while(p < end) { |
| 1557 | int runlen, regval; |
| 1558 | |
| 1559 | if (HLL_SPARSE_IS_ZERO(p)) { |
| 1560 | runlen = HLL_SPARSE_ZERO_LEN(p); |
| 1561 | p++; |
| 1562 | decoded = sdscatprintf(decoded,"z:%d ",runlen); |
| 1563 | } else if (HLL_SPARSE_IS_XZERO(p)) { |
nothing calls this directly
no test coverage detected