-
Notifications
You must be signed in to change notification settings - Fork 98
Adding bloom command meta data, bloom group and bloom data type documentaion #233
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
Changes from all commits
6f84713
1f892b9
f062a8a
48d8cd0
0249aec
47332ac
8e1f364
61f03c0
613ed72
8719dad
11c88c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| Adds a single item to a bloom filter. If the specified bloom filter does not exist, a bloom filter is created with the provided name with default properties. | ||
|
|
||
| To add multiple items to a bloom filter, you can use the `BF.MADD` or `BF.INSERT` commands. | ||
|
|
||
| To create a bloom filter with non-default properties, use the `BF.INSERT` or `BF.RESERVE` command. | ||
|
|
||
| ## Examples | ||
|
|
||
| ``` | ||
| 127.0.0.1:6379> BF.ADD key val | ||
| (integer) 1 | ||
| 127.0.0.1:6379> BF.ADD key val | ||
| (integer) 0 | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| Returns the cardinality of a bloom filter which is the number of items that have been successfully added to it. | ||
|
|
||
| ## Examples | ||
|
|
||
| ``` | ||
| 127.0.0.1:6379> BF.ADD key val | ||
| (integer) 1 | ||
| 127.0.0.1:6379> BF.CARD key | ||
| (integer) 1 | ||
| 127.0.0.1:6379> BF.CARD nonexistentkey | ||
| (integer) 0 | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| Determines if an item has been added to the bloom filter previously. | ||
|
|
||
| A bloom filter has two possible responses when you check if an item exists: | ||
|
|
||
| * 0 - The item definitely does not exist since with bloom filters, false negatives are not possible. | ||
|
|
||
| * 1 - The item exists with a given false positive (`fp`) percentage. There is an `fp` rate % chance that the item does not exist. You can create bloom filters with a more strict false positive rate as needed. | ||
|
|
||
| ## Examples | ||
|
|
||
| ``` | ||
| 127.0.0.1:6379> BF.ADD key val | ||
| (integer) 1 | ||
| 127.0.0.1:6379> BF.EXISTS key val | ||
| (integer) 1 | ||
| 127.0.0.1:6379> BF.EXISTS key nonexistent | ||
| (integer) 0 | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| Returns usage information and properties of a specific bloom filter. | ||
|
|
||
| ## Info Fields | ||
|
|
||
| * CAPACITY - The number of unique items that would need to be added before a scale out occurs or (non scaling) before it rejects addition of unique items. | ||
| * SIZE - The number of bytes allocated by this bloom filter. | ||
| * FILTERS - Returns the number of sub filters contained within the bloom filter. | ||
| * ITEMS - The number of unique items that have been added to the bloom filter. | ||
| * ERROR - The false positive rate of the bloom filter. | ||
| * EXPANSION - The expansion rate of the bloom filter. Non scaling filters will have an expansion rate of nil. | ||
| * TIGHTENING - The tightening ratio of the bloom filter. | ||
| * MAXSCALEDCAPACITY - The [maximum capacity](../topics/bloomfilters.md) that a scalable bloom filter can be expand to and reach before a subsequent scale out will fail. | ||
|
|
||
| For non-scaling filters, the `TIGHTENING` and `MAXSCALEDCAPACITY` fields are not applicable and will not be returned. | ||
| When no optional fields are specified, all available fields for the given filter type are returned. | ||
|
|
||
| ## Examples | ||
|
|
||
| ``` | ||
| 127.0.0.1:6379> BF.ADD key val | ||
| (integer) 1 | ||
| 127.0.0.1:6379> BF.INFO key | ||
| 1) Capacity | ||
| 2) (integer) 100 | ||
| 3) Size | ||
| 4) (integer) 384 | ||
| 5) Number of filters | ||
| 6) (integer) 1 | ||
| 7) Number of items inserted | ||
|
Comment on lines
+22
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't match the documentation of the field names above. I would expect the field names to be Btw, why are these uppercase? In the INFO command, the field names are lowercase.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This name convention is following the bloom filter Command Syntax of existing client libraries |
||
| 8) (integer) 2 | ||
| 9) Error rate | ||
| 10) "0.01" | ||
| 11) Expansion rate | ||
| 12) (integer) 2 | ||
| 13) Tightening ratio | ||
| 14) "0.5" | ||
| 15) Max scaled capacity | ||
| 16) (integer) 26214300 | ||
| 127.0.0.1:6379> BF.INFO key CAPACITY | ||
| (integer) 100 | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| If the bloom filter does not exist under the specified name, a bloom filter is created with the specified parameters. Default properties will be used if the options below are not specified. | ||
|
|
||
| When the `ITEMS` option is provided, all items provided will be attempted to be added. | ||
|
|
||
| ## Insert Fields | ||
zuiderkwast marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| * CAPACITY *capacity* - The number of unique items that would need to be added before a scale out occurs or (non scaling) before it rejects addition of unique items. | ||
| * ERROR *fp_error* - The false positive rate of the bloom filter. | ||
| * EXPANSION *expansion* - This option will specify the bloom filter as scaling and controls the size of the sub filter that will be created upon scale out / expansion of the bloom filter. | ||
| * NOCREATE - Will not create the bloom filter and add items if the filter does not exist already. | ||
| * TIGHTENING *tightening_ratio* - The tightening ratio for the bloom filter. | ||
| * SEED *seed* - The 32 byte seed the bloom filter's hash functions will use. | ||
| * NONSCALING - This option will configure the bloom filter as non scaling; it cannot expand / scale beyond its specified capacity. | ||
| * VALIDATESCALETO *validatescaleto* - Validates if the filter can scale out and reach to this capacity based on limits and if not, return an error without creating the bloom filter. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is why you had to add validatescaleto to the spellcheck wordlist. The idea is that keywords like this should be put within backticks. Then it doesn't need to be in the wordlist. It's possible to combine italics + backticks if needed, for example: Rendered as
|
||
| * ITEMS *item* - One or more items to be added to the bloom filter. | ||
|
|
||
| Due to the nature of `NONSCALING` and `VALIDATESCALETO` arguments, specifying `NONSCALING` and `VALIDATESCALETO` together is not allowed. | ||
|
|
||
| ## Examples | ||
|
|
||
| ``` | ||
| 127.0.0.1:6379> BF.INSERT key ITEMS item1 item2 | ||
| 1) (integer) 1 | ||
| 2) (integer) 1 | ||
| # This does not update the capacity since the filter already exists. It only adds the provided items. | ||
| 127.0.0.1:6379> BF.INSERT key CAPACITY 1000 ITEMS item2 item3 | ||
| 1) (integer) 0 | ||
| 2) (integer) 1 | ||
| 127.0.0.1:6379> BF.INSERT key_new CAPACITY 1000 | ||
| [] | ||
| ``` | ||
|
|
||
| ``` | ||
| 127.0.0.1:6379> BF.INSERT key NONSCALING VALIDATESCALETO 100 | ||
| (error) ERR cannot use NONSCALING and VALIDATESCALETO options together | ||
| 127.0.0.1:6379> BF.INSERT key CAPACITY 1000 VALIDATESCALETO 999999999999999999 ITEMS item2 item3 | ||
| (error) ERR provided VALIDATESCALETO causes bloom object to exceed memory limit | ||
| 127.0.0.1:6379> BF.INSERT key VALIDATESCALETO 999999999999999999 EXPANSION 1 ITEMS item2 item3 | ||
| (error) ERR provided VALIDATESCALETO causes false positive to degrade to 0 | ||
| ``` | ||
| ``` | ||
| 127.0.0.1:6379> BF.INSERT key NOCREATE ITEMS item1 item2 | ||
| (error) ERR not found | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a very good error, is it too late to make it better?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This error message is from existing API and error messages from existing client libraries that support bloom filters |
||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Restores a bloom filter from a dump of an existing bloom filter with all of its specific the properties and bit vector dump of sub filter/s. This command is only generated during AOF rewrite to restore a bloom filter in the future. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| Adds one or more items to a bloom filter. If the specified bloom filter does not exist, a bloom filter is created with the provided name with default properties. | ||
|
|
||
| If you want to create a bloom filter with non-default properties, use the `BF.INSERT` or `BF.RESERVE` command. | ||
|
|
||
| ## Examples | ||
|
|
||
| ``` | ||
| 127.0.0.1:6379> BF.MADD key item1 item2 | ||
| 1) (integer) 1 | ||
| 2) (integer) 1 | ||
| 127.0.0.1:6379> BF.MADD key item2 item3 | ||
| 1) (integer) 0 | ||
| 2) (integer) 1 | ||
| 127.0.0.1:6379> BF.MADD key_new item1 | ||
| 1) (integer) 1 | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| Determines if the provided item/s have been added to a bloom filter previously. | ||
|
|
||
| A Bloom filter has two possible responses when you check if an item exists: | ||
|
|
||
| * 0 - The item definitely does not exist since with bloom filters, false negatives are not possible. | ||
|
|
||
| * 1 - The item exists with a given false positive (`fp`) percentage. There is an `fp` rate % chance that the item does not exist. You can create bloom filters with a more strict false positive rate as needed. | ||
|
Comment on lines
+3
to
+7
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skip this. Responses are documented in the response JSON files. (I know, I don't like it. It's unnecessarily complex. I want to move the reply docs into the markdown files some day. But for now, let's just follow the existing structure.)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this was wanted to make it explicit how false positive affects the exist command and determining if an item is present. I could try and reword so it explains false positive not based on response but I think the thinking is that showing the response makes it more understandable
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rendered page is showing the response from (On the generated man pages, the reply section gets inserted before Examples, which I think is a better place.) You can keep this text here if you think it's better, and keep it brief in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that it does have some slight duplication but in my opinion I like having this explained as one of the main behaviours of bloom filters is the false positive rate. But am happy to change if others would rather not have the duplication.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't mind, but feel free to formulate it in a way so that it doesn't look too much like duplication. |
||
|
|
||
| ## Examples | ||
|
|
||
| ``` | ||
| 127.0.0.1:6379> BF.MADD key item1 item2 | ||
| 1) (integer) 1 | ||
| 2) (integer) 1 | ||
| 127.0.0.1:6379> BF.MEXISTS key item1 item2 item3 | ||
| 1) (integer) 1 | ||
| 2) (integer) 1 | ||
| 3) (integer) 0 | ||
| 127.0.0.1:6379> BF.MEXISTS key item1 | ||
| 1) (integer) 1 | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| Creates an empty bloom filter with the specified capacity and false positive rate. By default, a scaling filter is created with the default expansion rate. | ||
|
|
||
| To specify the scaling / non scaling nature of the bloom filter, use the options: `NONSCALING` or `SCALING <expansion rate>`. It is invalid to provide both options together. | ||
|
|
||
| ## Reserve fields | ||
|
|
||
| * error_rate - The false positive rate of the bloom filter | ||
| * capacity - The number of unique items that would need to be added before a scale out occurs or (non scaling) before it rejects addition of unique items. | ||
| * EXPANSION expansion - This option will specify the bloom filter as scaling and controls the size of the sub filter that will be created upon scale out / expansion of the bloom filter. | ||
| * NONSCALING - This option will configure the bloom filter as non scaling; it cannot expand / scale beyond its specified capacity. | ||
|
|
||
| ## Examples | ||
|
|
||
| ``` | ||
| 127.0.0.1:6379> BF.RESERVE key 0.01 1000 | ||
| OK | ||
| 127.0.0.1:6379> BF.RESERVE key 0.1 1000000 | ||
| (error) ERR item exists | ||
| ``` | ||
| ``` | ||
| 127.0.0.1:6379> BF.RESERVE bf_expansion 0.0001 5000 EXPANSION 3 | ||
| OK | ||
| ``` | ||
| ``` | ||
| 127.0.0.1:6379> BF.RESERVE bf_nonscaling 0.0001 5000 NONSCALING | ||
| OK | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "valkey_bloom": { | ||
| "name": "valkey-bloom", | ||
| "repo": "https://github.com/valkey-io/valkey-bloom", | ||
| "description": "Module that allows users to use the bloom filter data type" | ||
| } | ||
| } |
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is more grammatically correct to have the s as it it showing there are multiple commands that can do this not just one