Skip to content

Commit 970297c

Browse files
Merge pull request #2548 from sav-norem/patch-3
Update hyperloglogs.md with hugo short codes
2 parents 4c318ff + 93e8a50 commit 970297c

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

docs/data-types/probabilistic/hyperloglogs.md

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
---
22
title: "HyperLogLog"
33
linkTitle: "HyperLogLog"
44
weight: 1
@@ -37,12 +37,20 @@ only contains a state that does not include actual elements, the API is the
3737
same:
3838

3939
* 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.
4141

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 >}}
4654

4755
Some examples of use cases for this data structure is counting unique queries
4856
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
6876

6977
One HyperLogLog is created per page (video/song) per period, and every IP/identifier is added to it on every visit.
7078

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-
9079
## Basic commands
9180

9281
* `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
10897

10998
* [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.
11099
* [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.
100+

0 commit comments

Comments
 (0)