Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hyperloglogs.md with hugo short codes #2548

Merged
merged 3 commits into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 15 additions & 25 deletions docs/data-types/probabilistic/hyperloglogs.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
---
title: "HyperLogLog"
linkTitle: "HyperLogLog"
weight: 1
Expand Down Expand Up @@ -37,12 +37,20 @@ only contains a state that does not include actual elements, the API is the
same:

* Every time you see a new element, you add it to the count with `PFADD`.
* Every time you want to retrieve the current approximation of the unique elements *added* with `PFADD` so far, you use the `PFCOUNT`.
* 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.

> pfadd hll a b c d
(integer) 1
> pfcount hll
(integer) 4
{{< clients-example hll_tutorial pfadd >}}
> PFADD bikes Hyperion Deimos Phoebe Quaoar
sav-norem marked this conversation as resolved.
Show resolved Hide resolved
(integer) 1
> PFCOUNT bikes
(integer) 4
> PFADD commuter_bikes Salacia Mimas Quaoar
(integer) 1
> PFMERGE all_bikes bikes commuter_bikes
OK
> PFCOUNT all_bikes
(integer) 6
{{< /clients-example >}}

Some examples of use cases for this data structure is counting unique queries
performed by users in a search form every day, number of unique visitors to a web page and other similar cases.
Expand All @@ -68,25 +76,6 @@ Storing the IP address or any other kind of personal identifier is against the l

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


## Examples

* Add some items to the HyperLogLog:
```
> PFADD members 123
(integer) 1
> PFADD members 500
(integer) 1
> PFADD members 12
(integer) 1
```

* Estimate the number of members in the set:
```
> PFCOUNT members
(integer) 3
```

## Basic commands

* `PFADD` adds an item to a HyperLogLog.
Expand All @@ -108,3 +97,4 @@ The HyperLogLog can estimate the cardinality of sets with up to 18,446,744,073,7

* [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.
* [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.

Loading