diff options
author | antirez <antirez@gmail.com> | 2014-03-31 16:02:36 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-04-16 15:23:21 +0200 |
commit | 1e90c0066cf2bbe2b430b70e0addfb2d408ba29b (patch) | |
tree | d81619870b1ab8f120029d1dc5f1ca4b886ba6d3 | |
parent | be7eef911b42c1f4073e14f0ad68bc7a886a56f6 (diff) | |
download | redis-1e90c0066cf2bbe2b430b70e0addfb2d408ba29b.tar.gz |
HLLMERGE fixed by adding a... missing loop!
-rw-r--r-- | src/hyperloglog.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/hyperloglog.c b/src/hyperloglog.c index 9721205d2..f62a05d1d 100644 --- a/src/hyperloglog.c +++ b/src/hyperloglog.c @@ -544,7 +544,7 @@ void hllCountCommand(redisClient *c) { void hllMergeCommand(redisClient *c) { uint8_t max[REDIS_HLL_REGISTERS]; uint8_t *registers; - int j; + int j, i; /* Compute an HLL with M[i] = MAX(M[i]_j). * We we the maximum into the max array of registers. We'll write @@ -566,11 +566,13 @@ void hllMergeCommand(redisClient *c) { return; } - /* Get the register and set it at max[j] if it's the greatest - * value so far. */ + /* Merge with this HLL with our 'max' HHL by setting max[i] + * to MAX(max[i],hll[i]). */ registers = o->ptr; - HLL_GET_REGISTER(val,registers,j); - if (val > max[j]) max[j] = val; + for (i = 0; i < REDIS_HLL_REGISTERS; i++) { + HLL_GET_REGISTER(val,registers,i); + if (val > max[i]) max[i] = val; + } } /* Create / unshare the destination key's value if needed. */ |