summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Trinkala <trink@acm.org>2014-05-18 07:26:26 -0700
committerMike Trinkala <trink@acm.org>2014-05-18 07:26:26 -0700
commitba52cd06c87383964a44451f10310f0ea015277e (patch)
treec133330427ac45a3bf3ab2c6655ad6b316b6c4d0
parent67133d2f4882da652fd3e78ba15220bce2488d05 (diff)
downloadredis-ba52cd06c87383964a44451f10310f0ea015277e.tar.gz
Correct the HyperLogLog stale cache flag to prevent unnecessary computations.
Set the MSB as documented.
-rw-r--r--src/hyperloglog.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/hyperloglog.c b/src/hyperloglog.c
index 1c6ed45f3..ecc061c28 100644
--- a/src/hyperloglog.c
+++ b/src/hyperloglog.c
@@ -188,8 +188,8 @@ struct hllhdr {
};
/* The cached cardinality MSB is used to signal validity of the cached value. */
-#define HLL_INVALIDATE_CACHE(hdr) (hdr)->card[0] |= (1<<7)
-#define HLL_VALID_CACHE(hdr) (((hdr)->card[0] & (1<<7)) == 0)
+#define HLL_INVALIDATE_CACHE(hdr) (hdr)->card[7] |= (1<<7)
+#define HLL_VALID_CACHE(hdr) (((hdr)->card[7] & (1<<7)) == 0)
#define HLL_P 14 /* The greater is P, the smaller the error. */
#define HLL_REGISTERS (1<<HLL_P) /* With P=14, 16384 registers. */
@@ -953,7 +953,7 @@ double hllRawSum(uint8_t *registers, double *PE, int *ezp) {
return E;
}
-/* Return the approximated cardinality of the set based on the armonic
+/* Return the approximated cardinality of the set based on the harmonic
* mean of the registers values. 'hdr' points to the start of the SDS
* representing the String object holding the HLL representation.
*
@@ -1385,7 +1385,7 @@ void pfselftestCommand(redisClient *c) {
/* Test 2: approximation error.
* The test adds unique elements and check that the estimated value
* is always reasonable bounds.
- *
+ *
* We check that the error is smaller than 4 times than the expected
* standard error, to make it very unlikely for the test to fail because
* of a "bad" run.