Saturday 11 April 2015

Redis HyperLogLog

HyperLogLog is a data structure that is used to count number of distinct elements in a set approximately. Calculating the exact number of elements in a set requires an amount of memory proportional to the number of elements, which is impractical for very large data sets. Probabilistic cardinality estimators, such as the HyperLogLog data structure, use significantly less memory than this, at the cost of obtaining only an approximation of the cardinality.

127.0.0.1:6379> pfadd sample 1 2 3 4 5 
(integer) 1 
127.0.0.1:6379> pfadd example 6 7 8 9 
(integer) 1 
127.0.0.1:6379> pfcount sample example 
(integer) 9 
127.0.0.1:6379> pfcount sample 
(integer) 5 
127.0.0.1:6379> pfcount example 
(integer) 4 
127.0.0.1:6379> 

pfadd adds all elements to hyperLogLog data structure. 


 
Prevoius                                                 Next                                                 Home

No comments:

Post a Comment