You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/data-types/probabilistic/hyperloglogs.md
+15-25Lines changed: 15 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
---
1
+
---
2
2
title: "HyperLogLog"
3
3
linkTitle: "HyperLogLog"
4
4
weight: 1
@@ -37,12 +37,20 @@ only contains a state that does not include actual elements, the API is the
37
37
same:
38
38
39
39
* Every time you see a new element, you add it to the count with `PFADD`.
40
-
*Every time you want to retrieve the current approximation of the unique elements *added* with `PFADD`so far, you use the `PFCOUNT`.
40
+
*When you want to retrieve the current approximation of unique elements added using the `PFADD`command, you can use the `PFCOUNT` command. If you need to merge two different HLLs, the `PFMERGE` command is available. Since HLLs provide approximate counts of unique elements, the result of the merge will give you an approximation of the number of unique elements across both source HLLs.
41
41
42
-
> pfadd hll a b c d
43
-
(integer) 1
44
-
> pfcount hll
45
-
(integer) 4
42
+
{{< clients-example hll_tutorial pfadd >}}
43
+
> PFADD bikes Hyperion Deimos Phoebe Quaoar
44
+
(integer) 1
45
+
> PFCOUNT bikes
46
+
(integer) 4
47
+
> PFADD commuter_bikes Salacia Mimas Quaoar
48
+
(integer) 1
49
+
> PFMERGE all_bikes bikes commuter_bikes
50
+
OK
51
+
> PFCOUNT all_bikes
52
+
(integer) 6
53
+
{{< /clients-example >}}
46
54
47
55
Some examples of use cases for this data structure is counting unique queries
48
56
performed by users in a search form every day, number of unique visitors to a web page and other similar cases.
@@ -68,25 +76,6 @@ Storing the IP address or any other kind of personal identifier is against the l
68
76
69
77
One HyperLogLog is created per page (video/song) per period, and every IP/identifier is added to it on every visit.
70
78
71
-
72
-
## Examples
73
-
74
-
* Add some items to the HyperLogLog:
75
-
```
76
-
> PFADD members 123
77
-
(integer) 1
78
-
> PFADD members 500
79
-
(integer) 1
80
-
> PFADD members 12
81
-
(integer) 1
82
-
```
83
-
84
-
* Estimate the number of members in the set:
85
-
```
86
-
> PFCOUNT members
87
-
(integer) 3
88
-
```
89
-
90
79
## Basic commands
91
80
92
81
*`PFADD` adds an item to a HyperLogLog.
@@ -108,3 +97,4 @@ The HyperLogLog can estimate the cardinality of sets with up to 18,446,744,073,7
108
97
109
98
*[Redis new data structure: the HyperLogLog](http://antirez.com/news/75) has a lot of details about the data structure and its implementation in Redis.
110
99
*[Redis HyperLogLog Explained](https://www.youtube.com/watch?v=MunL8nnwscQ) shows you how to use Redis HyperLogLog data structures to build a traffic heat map.
0 commit comments