hyperloglog.rs
hyperloglog.rs copied to clipboard
enh idea: return the cardinality increase from `insert`
Consider the Redis PFADD API. https://github.com/redis/redis/blob/1aa6c4ab9294af4eef50fbd82079051f4c06dd42/src/hyperloglog.c#L494 https://redis.io/docs/data-types/hyperloglogs/
This behaviour is useful for two reasons: it avoids the race condition for the question 'is this value probably newly seen' that occurs with insert-then-count approaches. Secondly it is cheaper: rather than an estimate of the cardinality, all that is needed is whether a register was changed or not.
For the use case I'm currently implementing this would perhaps be useful, even more so if locking could be deferred to the actual write moment, though thats a different nuance / use case.