From 0bbdaca6a0b10de3b8bfdbb57c902975a79c2646 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 16 Apr 2014 09:05:42 +0200 Subject: [PATCH] PFDEBUG TODENSE added. Converts HyperLogLogs from sparse to dense. Used for testing. --- src/hyperloglog.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/hyperloglog.c b/src/hyperloglog.c index bb07aa38..3cb31f29 100644 --- a/src/hyperloglog.c +++ b/src/hyperloglog.c @@ -1427,6 +1427,21 @@ void pfdebugCommand(redisClient *c) { if (c->argc != 3) goto arityerr; addReplyStatus(c,encodingstr[hdr->encoding]); + } + /* PFDEBUG TODENSE */ + else if (!strcasecmp(cmd,"todense")) { + int conv = 0; + if (c->argc != 3) goto arityerr; + + if (hdr->encoding == HLL_SPARSE) { + if (hllSparseToDense(o) == REDIS_ERR) { + addReplyError(c,invalid_hll_err); + return; + } + conv = 1; + server.dirty++; /* Force propagation on encoding change. */ + } + addReply(c,conv ? shared.cone : shared.czero); } else { addReplyErrorFormat(c,"Unknown PFDEBUG subcommand '%s'", cmd); }