Skip to content

Commit cd80826

Browse files
committed
First round of rewording and changes to documentation. Added ability to generate bloom man pages
Signed-off-by: zackcam <[email protected]>
1 parent 6f84713 commit cd80826

File tree

15 files changed

+117
-95
lines changed

15 files changed

+117
-95
lines changed

Makefile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ DATE ?= 2025-01-08
88

99
# Path to the code repo.
1010
VALKEY_ROOT ?= ../valkey
11-
11+
VALKEY_BLOOM_ROOT ?= ../valkey-bloom
1212
# Where to install man pages
1313
INSTALL_MAN_DIR ?= /usr/local/share/man
1414

@@ -30,6 +30,10 @@ ifeq ("$(wildcard $(VALKEY_ROOT))","")
3030
$(error Please provide the VALKEY_ROOT variable pointing to the Valkey source code)
3131
endif
3232

33+
ifeq ("$(wildcard $(VALKEY_BLOOM_ROOT))","")
34+
$(error Please provide the VALKEY_ROOT variable pointing to the Valkey source code)
35+
endif
36+
3337
ifeq ("$(shell which pandoc)","")
3438
$(error Please install pandoc)
3539
endif
@@ -54,7 +58,9 @@ endif
5458

5559
documented_commands = $(wildcard commands/*.md)
5660
commands_json_files = $(wildcard $(VALKEY_ROOT)/src/commands/*.json)
57-
existing_commands = $(commands_json_files:$(VALKEY_ROOT)/src/commands/%.json=commands/%.md)
61+
bloom_commands_json_files = $(wildcard $(VALKEY_BLOOM_ROOT)/src/commands/*.json)
62+
existing_commands = $(commands_json_files:$(VALKEY_ROOT)/src/commands/%.json=commands/%.md) \
63+
$(bloom_commands_json_files:$(VALKEY_BLOOM_ROOT)/src/commands/%.json=commands/%.md)
5864

5965
topics = $(wildcard topics/*)
6066
commands = $(filter $(existing_commands),$(documented_commands))
@@ -65,7 +71,9 @@ topics_pics = $(filter-out %.md,$(topics))
6571
# ---- Temp files ----
6672

6773
# JSON files for the commands that have a .md file (excluding undocumented commands).
68-
json_for_documented_commands = $(commands:commands/%.md=$(VALKEY_ROOT)/src/commands/%.json)
74+
json_for_documented_commands = \
75+
$(patsubst commands/%.md,$(VALKEY_ROOT)/src/commands/%.json,$(filter $(commands_json_files:$(VALKEY_ROOT)/src/commands/%.json=commands/%.md),$(commands))) \
76+
$(patsubst commands/%.md,$(VALKEY_BLOOM_ROOT)/src/commands/%.json,$(filter $(bloom_commands_json_files:$(VALKEY_BLOOM_ROOT)/src/commands/%.json=commands/%.md),$(commands)))
6977

7078
$(BUILD_DIR)/.commands-per-group.json: $(VALKEY_ROOT)/src/commands/. utils/build-command-groups.py | $(BUILD_DIR)
7179
utils/build-command-groups.py $(json_for_documented_commands) > $@~~
@@ -175,11 +183,14 @@ $(MAN_DIR)/man1/valkey-%.1.gz: topics/%.md $(man_scripts)
175183
utils/preprocess-markdown.py --man --page-type program \
176184
--version $(VERSION) --date $(DATE) \$< \
177185
| utils/links-to-man.py - | $(to_man) > $@
178-
$(MAN_DIR)/man3/%.3valkey.gz: commands/%.md $(VALKEY_ROOT)/src/commands/%.json $(BUILD_DIR)/.commands-per-group.json $(man_scripts)
186+
$(MAN_DIR)/man3/%.3valkey.gz: commands/%.md $(BUILD_DIR)/.commands-per-group.json $(man_scripts)
187+
$(eval VALKEY_ROOTS := $(VALKEY_ROOT) $(VALKEY_BLOOM_ROOT))
188+
$(eval FINAL_ROOT := $(firstword $(foreach root,$(VALKEY_ROOTS),$(if $(wildcard $(root)/src/commands/$*.json),$(root)))))
189+
$(if $(FINAL_ROOT),,$(eval FINAL_ROOT := $(lastword $(VALKEY_ROOTS))))
179190
utils/preprocess-markdown.py --man --page-type command \
180191
--version $(VERSION) --date $(DATE) \
181192
--commands-per-group-json $(BUILD_DIR)/.commands-per-group.json \
182-
--valkey-root $(VALKEY_ROOT) $< \
193+
--valkey-root $(FINAL_ROOT) $< \
183194
| utils/links-to-man.py - | $(to_man) > $@
184195
$(MAN_DIR)/man5/%.5.gz: topics/%.md $(man_scripts)
185196
utils/preprocess-markdown.py --man --page-type config \

commands/bf.add.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
Adds an item to a bloom filter, if the specified filter does not exist creates a default bloom filter with that name.
2-
## Arguments
3-
* key (required) - A Valkey key of Bloom data type
4-
* item (required) - Item to add
1+
Adds an item to a bloom filter, if the specified bloom filter does not exist creates a bloom filter with default configurations with that name.
2+
3+
If you want to create a bloom filter with non-standard options, use the `BF.INSERT` or `BF.RESERVE` command.
54

65
## Examples
6+
77
```
88
127.0.0.1:6379> BF.ADD key val
99
1

commands/bf.card.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
Gets the cardinality of a Bloom filter - number of items that have been successfully added to a Bloom filter.
2-
## Arguments
3-
* key (required) - A Valkey key of Bloom data type
42

53
## Examples
4+
65
```
76
127.0.0.1:6379> BF.ADD key val
87
1

commands/bf.exists.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
Determines if a specified item has been added to the specified bloom filter.
2-
Syntax
1+
Determines if an item has been added to the bloom filter.
2+
3+
A Bloom filter has two possible responses when you check if an item exists:
4+
5+
* "No" (Definite) - If the filter says an item is NOT present, this is 100% certain. The item is definitely not in the set.
6+
7+
* "Maybe" (Probabilistic) - If the filter says an item IS present, this is uncertain. There's a chance it's a false positive. The item might be in the set, but may not be
38

4-
## Arguments
5-
* key (required) - A Valkey key of Bloom data type
6-
* item (required) - The item that we are checking if it exists in the bloom object
79

810
## Examples
11+
912
```
1013
127.0.0.1:6379> BF.ADD key val
1114
1

commands/bf.info.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
Returns information about a bloomfilter
1+
Returns information about a bloom filter
2+
3+
## Info Fields
4+
5+
* CAPACITY - Returns the number of unique items that would need to be added before scaling would happen
6+
* SIZE - Returns the number of bytes allocated
7+
* FILTERS - Returns the number of filters in the specified key
8+
* ITEMS - Returns the number of unique items that have been added the the bloom filter
9+
* ERROR - Returns the false positive rate for the bloom filter
10+
* EXPANSION - Returns the expansion rate
11+
* MAXSCALEDCAPACITY - Returns the maximum capacity that can be reached before an error occurs
212

3-
## Arguments
4-
* key (required) - A valkey key of bloom data type
5-
* CAPACITY (optional) - Returns the number of unique items that would need to be added before scaling would happen
6-
* SIZE (optional) - Returns the memory size which is the number of bytes allocated
7-
* FILTERS (optional) - Returns the number of filters in the specified key
8-
* ITEMS (optional) - Returns the number of unique items that have been added the the Bloom filter
9-
* ERROR (optional) - Returns the false positive rate for the bloom filter
10-
* EXPANSION (optional) - Returns the expansion rate
11-
* MAXSCALEDCAPACITY (optional) - Returns the maximum capacity that can be reached before an error occurs
1213
If none of the optional fields are specified, all the fields will be returned. MAXSCALEDCAPACITY will be an unrecognized argument on non scaling filters
1314

1415
## Examples
16+
1517
```
1618
127.0.0.1:6379> BF.ADD key val
1719
1

commands/bf.insert.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
Creates a bloom object with the specified parameters. If a parameter is not specified then the default value will be used. If ITEMS is specified then it will also attempt to add all items specified after
1+
Creates a bloom filter with the specified parameters. If a parameter is not specified then the default value will be used. If ITEMS is specified then it will also attempt to add all items specified
2+
3+
## Insert Fields
4+
5+
* CAPACITY capacity - capacity for the initial bloom filter
6+
* ERROR `fp_error` - The false positive rate for the bloom filter
7+
* EXPANSION expansion - The expansion rate for a scaling filter
8+
* NOCREATE - Will not create the bloom filter and add items if the filter does not exist already
9+
* TIGHTENING `tightening_ratio` - The tightening ratio for the bloom filter
10+
* SEED seed - The seed the hash functions will use
11+
* NONSCALING - Will make it so the filter can not scale
12+
* VALIDATESCALETO `validatescaleto` - Checks if the filter could scale to this capacity and if not show an error and don’t create the bloom filter
13+
* ITEMS item - One or more items we will add to the bloom filter
214

3-
## Arguments
415
Due to the nature of NONSCALING and VALIDATESCALETO arguments, specifying NONSCALING and VALIDATESCALETO isn't allowed
5-
* key (required) - Is the key name for a Bloom filter to add the item to
6-
* CAPACITY capacity (optional) - capacity for the inital bloom filter
7-
* ERROR fp_error (optional)- The false positive rate for the bloom filter
8-
* EXPANSION expansion(optional) - The expansion rate for a scaling filter
9-
* NOCREATE (optional) - Will not create the bloom filter and add items if the filter does not exist already
10-
* TIGHTENING (optional) - The tightening ratio for the bloom filter
11-
* SEED (optional) - The seed the hash functions will use
12-
* NONSCALING (optional) - Will make it so the filter can not scale
13-
* VALIDATESCALETO validatescaleto (optional) - Checks if the filter could scale to this capacity and if not show an error and don’t create the bloom filter
14-
* ITEMS (optional) - Items we will add to the bloom filter
1516

1617
## Examples
18+
1719
```
1820
127.0.0.1:6379> BF.INSERT key ITEMS item1 item2
1921
1) (integer) 1
@@ -28,13 +30,13 @@ Due to the nature of NONSCALING and VALIDATESCALETO arguments, specifying NONSC
2830

2931
```
3032
127.0.0.1:6379> BF.INSERT key NONSCALING VALIDATESCALETO 100
31-
cannot use NONSCALING and VALIDATESCALETO options together
32-
127.0.0.1:6379> BF.INSERT key CAPACITY 1000 VALIDATESCALETO 999999999999999999999 ITEMS item2 item3
33-
provided VALIDATESCALETO causes bloom object to exceed memory limit
34-
127.0.0.1:6379> BF.INSERT key VALIDATESCALETO 999999999999999999999 EXPANSION 1 ITEMS item2 item3
35-
provided VALIDATESCALETO causes false positive to degrade to 0
33+
(error) ERR cannot use NONSCALING and VALIDATESCALETO options together
34+
127.0.0.1:6379> BF.INSERT key CAPACITY 1000 VALIDATESCALETO 999999999999999999 ITEMS item2 item3
35+
(error) ERR provided VALIDATESCALETO causes bloom object to exceed memory limit
36+
127.0.0.1:6379> BF.INSERT key VALIDATESCALETO 999999999999999999 EXPANSION 1 ITEMS item2 item3
37+
(error) ERR provided VALIDATESCALETO causes false positive to degrade to 0
3638
```
3739
```
3840
127.0.0.1:6379> BF.INSERT key NOCREATE ITEMS item1 item2
39-
not found
41+
(error) ERR not found
4042
```

commands/bf.load.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
Loads a bloom filter from a dump of an existing bloom object with all the properties and bit vector dump.
2-
## Arguments
3-
* key (required) - Is the key name for a Bloom filter to add the item to
4-
* dump (required) - Is the dump we are restoring

commands/bf.madd.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
Adds one or more items to a Bloom Filter, if the specified filter does not exist creates a default bloom filter with that name.
2-
## Arguments
3-
* key (required) - Is the key name for a Bloom filter to add the item to
4-
* item (requires at least 1 item but can add as many as wanted ) - Is the item/s to add
1+
Adds one or more items to a Bloom Filter, if the bloom filter does not exist creates a default bloom filter.
2+
3+
If you want to create a bloom filter with non-standard options, use the `BF.INSERT` or `BF.RESERVE` command.
4+
55
## Examples
6+
67
```
78
127.0.0.1:6379> BF.MADD key item1 item2
89
1) (integer) 1

commands/bf.mexists.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
Determines if one or more items has been added to the specified bloom filter
2-
## Arguments
3-
* key (required) - A Valkey key of Bloom data type
4-
* item (requires at least 1 item but can add as many as desired) - The item/s that we are checking if it exists in the bloom object
1+
Determines if one or more items has been added to a bloom filter.
2+
3+
A Bloom filter has two possible responses when you check if an item exists:
4+
5+
* "No" (Definite) - If the filter says an item is NOT present, this is 100% certain. The item is definitely not in the set.
6+
7+
* "Maybe" (Probabilistic) - If the filter says an item IS present, this is uncertain. There's a chance it's a false positive. The item might be in the set, but may not be
8+
59
## Examples
10+
611
```
712
127.0.0.1:6379> BF.MADD key item1 item2
813
1) (integer) 1

commands/bf.reserve.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
Creates an empty bloom object with the capacity and false positive rate specified
2-
## Arguments
3-
* key (required) - A Valkey key of Bloom data type
4-
* error_rate (required) - The fp rate the bloom filter will be created with
5-
* capacity (required) - The starting capacity the bloom filter will be created with
6-
* EXPANSION expansion(optional)- The rate in which filters will increase by
7-
* NONSCALING (optional) - Setting this will make it so the bloom object can’t expand past its initial capacity
2+
3+
## Reserve fields
4+
5+
* error_rate - The false positive rate the bloom filter will be created with
6+
* capacity - The starting capacity the bloom filter will be created with
7+
* EXPANSION expansion - The rate in which filters will increase by
8+
* NONSCALING - Setting this will make it so the bloom object can’t expand past its initial capacity
89

910
## Examples
11+
1012
```
1113
127.0.0.1:6379> BF.RESERVE key 0.01 1000
1214
OK

0 commit comments

Comments
 (0)