diff options
author | antirez <antirez@gmail.com> | 2014-04-14 15:55:21 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-04-14 15:55:21 +0200 |
commit | ba0afb45661d1ab4d607782cd8afee0dfa3eb893 (patch) | |
tree | 23e891504733e353bea3402aff6d961fdd0eb772 | |
parent | e9cd51c7ebbe998a79b52b28fde0b31970dcb7a0 (diff) | |
download | redis-ba0afb45661d1ab4d607782cd8afee0dfa3eb893.tar.gz |
Added assertion in hllSparseAdd() when promotion to dense occurs.
If we converted to dense, a register must be updated in the dense
representation.
-rw-r--r-- | src/hyperloglog.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/hyperloglog.c b/src/hyperloglog.c index fe1321513..b7c4b6cfe 100644 --- a/src/hyperloglog.c +++ b/src/hyperloglog.c @@ -865,7 +865,17 @@ updated: promote: /* Promote to dense representation. */ if (hllSparseToDense(o) == REDIS_ERR) return -1; /* Corrupted HLL. */ hdr = o->ptr; - return hllDenseAdd(hdr->registers, ele, elesize); + + /* We need to call hllDenseAdd() to perform the operation after the + * conversion. However the result must be 1, since if we need to + * convert from sparse to dense a register requires to be updated. + * + * Note that this in turn means that PFADD will make sure the command + * is propagated to slaves / AOF, so if there is a sparse -> dense + * convertion, it will be performed in all the slaves as well. */ + int dense_retval = hllDenseAdd(hdr->registers, ele, elesize); + redisAssert(dense_retval == 1); + return dense_retval; } /* Compute SUM(2^-reg) in the sparse representation. |