Redis Hyperloglog can accept multiple elements as input and give cardinality estimates of input elements.
Cardinality: The number of different elements in the collection. For example [foo ', ' Bar ', ' foobar ', ' bar ', ' test '}] the cardinality is 4.
Hyperloglog provides only three functions: Pfadd, Pfcount, Pfmerge
Pfadd:
Adds the specified element to the Hyperloglog.
Pfadd (Key, *values)
return value
Integer that returns 0 if at least one element is added to return 1.
Pfcount:
Returns the radix value of the specified hyperloglog.
Pfmerge:
Merges multiple hyperloglog into one hyperloglog.
Instance:
>>>ImportRedis>>> r =Redis. Redis ()>>> R.pfadd ('Hyperlog1', *['Foo','Bar','Foo','Foobar','Test'])1>>> R.pfcount ('Hyperlog1')4>>> R.pfadd ('hyperlog2', *['Foo','Bar','Mans','Xie','Xiemanrui'])1>>> R.pfcount ('hyperlog2')5>>> R.pfmerge ('Hyperlog1','hyperlog2') True>>> R.pfcount ('Hyperlog1')7>>>
Redis in Python:hyperloglog (Pfadd, Pfcount, Pfmerge)