From 261da523e860146066e052771e2217a84bc8d168 Mon Sep 17 00:00:00 2001 From: antirez Date: Sun, 13 Apr 2014 23:01:21 +0200 Subject: PFDEBUG added, PFGETREG removed. PFDEBUG will be the interface to do debugging tasks with a key containing an HLL object. --- src/hyperloglog.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'src/hyperloglog.c') diff --git a/src/hyperloglog.c b/src/hyperloglog.c index 0f92ff50a..f99d188f8 100644 --- a/src/hyperloglog.c +++ b/src/hyperloglog.c @@ -1214,26 +1214,42 @@ cleanup: sdsfree(bitcounters); } -/* PFGETREG - * Return the registers values of the specified HLL. */ -void pfgetregCommand(redisClient *c) { - robj *o = lookupKeyRead(c->db,c->argv[1]); +/* PFDEBUG ... args ... + * Different debugging related operations about the HLL implementation. */ +void pfdebugCommand(redisClient *c) { + char *cmd = c->argv[1]->ptr; struct hllhdr *hdr; + robj *o; int j; + o = lookupKeyRead(c->db,c->argv[2]); if (o == NULL) { addReplyError(c,"The specified key does not exist"); return; - } else { - if (isHLLObjectOrReply(c,o) != REDIS_OK) return; + } + if (isHLLObjectOrReply(c,o) != REDIS_OK) return; + o = dbUnshareStringValue(c->db,c->argv[2],o); + hdr = o->ptr; + + /* PFDEBUG GETREG */ + if (!strcasecmp(cmd,"getreg")) { + if (c->argc != 3) goto arityerr; - hdr = o->ptr; addReplyMultiBulkLen(c,HLL_REGISTERS); + hllSparseToDense(o); for (j = 0; j < HLL_REGISTERS; j++) { uint8_t val; HLL_DENSE_GET_REGISTER(val,hdr->registers,j); addReplyLongLong(c,val); } + } else { + addReplyErrorFormat(c,"Unknown PFDEBUG subcommand '%s'", cmd); } + return; + +arityerr: + addReplyErrorFormat(c, + "Wrong number of arguments for the '%s' subcommand",cmd); } + -- cgit v1.2.1