summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-04-12 11:02:14 +0200
committerantirez <antirez@gmail.com>2014-04-16 15:09:46 +0200
commit0b9f09c4e0c5ade77a7bd0c21892c0211705cc81 (patch)
treefe19ba95cc8201b3d6e5e124fb09beae03fca979
parente526d326355943fa31ccdc2361b0734f18dd9aa8 (diff)
downloadredis-0b9f09c4e0c5ade77a7bd0c21892c0211705cc81.tar.gz
Increment pointer while iterating sparse HLL object.
-rw-r--r--src/hyperloglog.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/hyperloglog.c b/src/hyperloglog.c
index 5157cd8ef..969a86599 100644
--- a/src/hyperloglog.c
+++ b/src/hyperloglog.c
@@ -581,9 +581,11 @@ sds hllSparseToDense(sds sparse) {
if (HLL_SPARSE_IS_ZERO(p)) {
runlen = HLL_SPARSE_ZERO_LEN(p);
idx += runlen;
+ p++;
} else if (HLL_SPARSE_IS_XZERO(p)) {
runlen = HLL_SPARSE_XZERO_LEN(p);
idx += runlen;
+ p += 2;
} else {
runlen = HLL_SPARSE_VAL_LEN(p);
regval = HLL_SPARSE_VAL_VALUE(p);
@@ -591,6 +593,7 @@ sds hllSparseToDense(sds sparse) {
HLL_DENSE_SET_REGISTER(hdr->registers,idx,regval);
idx++;
}
+ p++;
}
}
@@ -821,16 +824,19 @@ double hllSparseSum(uint8_t *sparse, int sparselen, double *PE, int *ezp) {
idx += runlen;
ez += runlen;
E += 1; /* 2^(-reg[j]) is 1 when m is 0. */
+ p++;
} else if (HLL_SPARSE_IS_XZERO(p)) {
runlen = HLL_SPARSE_XZERO_LEN(p);
idx += runlen;
ez += runlen;
E += 1; /* 2^(-reg[j]) is 1 when m is 0. */
+ p += 2;
} else {
runlen = HLL_SPARSE_VAL_LEN(p);
regval = HLL_SPARSE_VAL_VALUE(p);
idx += runlen;
E += PE[regval]*runlen;
+ p++;
}
}
redisAssert(idx == HLL_REGISTERS);