summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-04-13 23:01:21 +0200
committerantirez <antirez@gmail.com>2014-04-13 23:01:21 +0200
commit261da523e860146066e052771e2217a84bc8d168 (patch)
tree65bbfcf7a22e4d75667eebd48c03d51b2e07d6bf
parente8e717e1452ecef60590f3d7a2c5dab37b620cfd (diff)
downloadredis-261da523e860146066e052771e2217a84bc8d168.tar.gz
PFDEBUG added, PFGETREG removed.
PFDEBUG will be the interface to do debugging tasks with a key containing an HLL object.
-rw-r--r--src/hyperloglog.c30
-rw-r--r--src/redis.c2
-rw-r--r--src/redis.h2
3 files changed, 25 insertions, 9 deletions
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 <subcommand> <key> ... 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 <key> */
+ 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);
}
+
diff --git a/src/redis.c b/src/redis.c
index da821abf7..0c0106d75 100644
--- a/src/redis.c
+++ b/src/redis.c
@@ -274,7 +274,7 @@ struct redisCommand redisCommandTable[] = {
{"pfadd",pfaddCommand,-2,"wm",0,NULL,1,1,1,0,0},
{"pfcount",pfcountCommand,2,"w",0,NULL,1,1,1,0,0},
{"pfmerge",pfmergeCommand,-2,"wm",0,NULL,1,-1,1,0,0},
- {"pfgetreg",pfgetregCommand,2,"r",0,NULL,0,0,0,0,0}
+ {"pfdebug",pfdebugCommand,-3,"r",0,NULL,0,0,0,0,0}
};
struct evictionPoolEntry *evictionPoolAlloc(void);
diff --git a/src/redis.h b/src/redis.h
index edd37bc18..850ec1684 100644
--- a/src/redis.h
+++ b/src/redis.h
@@ -1460,7 +1460,7 @@ void pfselftestCommand(redisClient *c);
void pfaddCommand(redisClient *c);
void pfcountCommand(redisClient *c);
void pfmergeCommand(redisClient *c);
-void pfgetregCommand(redisClient *c);
+void pfdebugCommand(redisClient *c);
#if defined(__GNUC__)
void *calloc(size_t count, size_t size) __attribute__ ((deprecated));