Skip to content

Commit 58ec1f6

Browse files
authored
DEV: add RESP2/3 return information to the Bloom filter commands (#1715)
* DEV: add RESP2/3 return information to the Bloom filter commands * Apply review comments + some other fixes
1 parent 2fdfd25 commit 58ec1f6

File tree

10 files changed

+199
-77
lines changed

10 files changed

+199
-77
lines changed

content/commands/bf.add.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ If `key` does not exist - a new Bloom filter is created with default error rate,
4949
is an item to add.
5050
</details>
5151

52-
## Return value
53-
54-
Returns one of these replies:
55-
56-
- [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) - where "1" means that the item has been added successfully, and "0" means that such item was already added to the filter (which could be wrong)
57-
- [] on error (invalid arguments, wrong key type, etc.) and also when the filter is full
58-
5952
## Examples
6053

6154
{{< highlight bash >}}
@@ -64,3 +57,21 @@ redis> BF.ADD bf item1
6457
redis> BF.ADD bf item1
6558
(integer) 0
6659
{{< / highlight >}}
60+
61+
## Return information
62+
63+
{{< multitabs id="bf-add-return-info"
64+
tab1="RESP2"
65+
tab2="RESP3" >}}
66+
67+
One of the following:
68+
* [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): `1` for successfully adding an item, or `0` if there's a probability that the item was already added to the filter.
69+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments, wrong key type, or when the filter is full.
70+
71+
-tab-sep-
72+
73+
One of the following:
74+
* [Boolean reply]({{< relref "/develop/reference/protocol-spec#booleans" >}}): `true` for successfully adding an item, or `false` if there's a probability that the item was already added to the filter.
75+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments, wrong key type, or when the filter is full.
76+
77+
{{< /multitabs >}}

content/commands/bf.card.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,6 @@ is key name for a Bloom filter.
4141

4242
</details>
4343

44-
## Return value
45-
46-
Returns one of these replies:
47-
48-
- [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) - the number of items that were added to this Bloom filter and detected as unique (items that caused at least one bit to be set in at least one sub-filter), or 0 when `key` does not exist.
49-
- [] on error (invalid arguments, wrong key type, etc.)
50-
51-
Note: when `key` exists - return the same value as `BF.INFO key ITEMS`.
52-
5344
## Examples
5445

5546
{{< highlight bash >}}
@@ -60,3 +51,24 @@ redis> BF.CARD bf1
6051
redis> BF.CARD bf_new
6152
(integer) 0
6253
{{< / highlight >}}
54+
55+
## Return information
56+
57+
{{< multitabs id="bf-card-return-info"
58+
tab1="RESP2"
59+
tab2="RESP3" >}}
60+
61+
One of the following:
62+
* [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): the number of items detected as unique that were added to the Bloom filter (items that caused at least one bit to be set in at least one sub-filter), or `0` when the given `key` does not exist.
63+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments, wrong key type, or when the filter is full.
64+
65+
Note: when `key` exists, `BF.CARD` returns the same value as `BF.INFO key ITEMS`.
66+
67+
-tab-sep-
68+
69+
One of the following:
70+
* [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): the number of items detected as unique that were added to the Bloom filter (items that caused at least one bit to be set in at least one sub-filter), or `0` when the given `key` does not exist.
71+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments, wrong key type, or when the filter is full.
72+
73+
Note: when `key` exists, `BF.CARD` returns the same value as `BF.INFO key ITEMS`.
74+
{{< /multitabs >}}

content/commands/bf.exists.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ is key name for a Bloom filter.
4848
is an item to check.
4949
</details>
5050

51-
## Return value
52-
53-
Returns one of these replies:
54-
55-
- [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}), where `1` means that, with high probability, `item` was already added to the filter, and `0` means that `key` does not exist or that `item` had not been added to the filter.
56-
- [] on error (invalid arguments, wrong key type, etc.)
57-
5851
## Examples
5952

6053
{{< highlight bash >}}
@@ -65,3 +58,21 @@ redis> BF.EXISTS bf item1
6558
redis> BF.EXISTS bf item2
6659
(integer) 0
6760
{{< / highlight >}}
61+
62+
## Return information
63+
64+
{{< multitabs id="bf-exists-return-info"
65+
tab1="RESP2"
66+
tab2="RESP3" >}}
67+
68+
One of the following:
69+
* [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): `1` means that, with high probability, `item` was already added to the filter, and `0` means that either the `key` does not exist or that the `item` had not been added to the filter.
70+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) if invalid arguments are passed.
71+
72+
-tab-sep-
73+
74+
One of the following:
75+
* [Boolean reply]({{< relref "/develop/reference/protocol-spec#booleans" >}}): `true` means that, with high probability, `item` was already added to the filter, and `false` means that either `key` does not exist or that `item` had not been added to the filter.
76+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) if invalid arguments are passed or `key` is not of the correct type.
77+
78+
{{< /multitabs >}}

content/commands/bf.info.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,6 @@ Return the number of items that were added to this Bloom filter and detected as
8484
Return the expansion rate.
8585
</details>
8686

87-
When no optional argument is specified: return all information fields.
88-
89-
## Return value
90-
91-
When no optional argument is specified, returns one of these replies:
92-
93-
- [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) with argument name ([Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}})) and value ([Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}})) pairs
94-
- [] on error (invalid arguments, key does not exist, wrong key type, and so on)
95-
96-
When an optional argument is specified, returns one of these replies:
97-
98-
- [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) - argument value
99-
- [] on error (invalid arguments, key does not exist, wrong key type, and so on)
100-
10187
## Examples
10288

10389
{{< highlight bash >}}
@@ -117,3 +103,21 @@ redis> BF.INFO bf1
117103
redis> BF.INFO bf1 CAPACITY
118104
1) (integer) 100
119105
{{< / highlight >}}
106+
107+
## Return information
108+
109+
{{< multitabs id="bf-info-return-info"
110+
tab1="RESP2"
111+
tab2="RESP3" >}}
112+
113+
One of the following:
114+
* [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) with argument name ([Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}})) and value ([Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}})) pairs.
115+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments, wrong key type, or when the key does not exist.
116+
117+
-tab-sep-
118+
119+
One of the following:
120+
* [Map reply]({{< relref "/develop/reference/protocol-spec#maps" >}}) with argument name ([Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}})) and value ([Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}})) pairs.
121+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments, wrong key type, or when the key does not exist.
122+
123+
{{< /multitabs >}}

content/commands/bf.insert.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,6 @@ If the number of elements to be stored in the filter is unknown, use an `expansi
118118
Otherwise, use an `expansion` of `1` to reduce memory consumption. The default value is `2`.
119119
</details>
120120

121-
## Return value
122-
123-
Returns one of these replies:
124-
125-
- [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) where each element is one of these options:
126-
- [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}), where `1` denotes that the item has been added successfully, and `0` means that such item had already added to the filter (which could be wrong)
127-
- [] when the item cannot be added because the filter is full
128-
- [], for example, when the number of arguments or key type is wrong, and also when `NOCREATE` is specified and `key` does not exist.
129-
130121
## Examples
131122

132123
Add three items to a filter, then create the filter with default parameters if it does not already exist.
@@ -146,3 +137,25 @@ Add two items to a filter, then return error if the filter does not already exis
146137
{{< highlight bash >}}
147138
BF.INSERT filter NOCREATE ITEMS foo bar
148139
{{< / highlight >}}
140+
141+
## Return information
142+
143+
{{< multitabs id="bf-insert-return-info"
144+
tab1="RESP2"
145+
tab2="RESP3" >}}
146+
147+
One of the following: where each element is one of these options:
148+
* [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}), where each element is one of the following options:
149+
* [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) `1` for successfully adding an item, or `0` if there's a probability that the item was already added to the filter.
150+
* [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings">}}) when the item cannot be added because the filter is full.
151+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors">}}) when the number of arguments or key type is wrong, and also when `NOCREATE` is specified and `key` does not exist.
152+
153+
-tab-sep-
154+
155+
One of the following: where each element is one of these options:
156+
* [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}), where each element is one of the following options:
157+
* [Boolean reply]({{< relref "/develop/reference/protocol-spec#booleans" >}}) `true` for successfully adding an item, or `false` if there's a probability that the item was already added to the filter.
158+
* [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings">}}) when the item cannot be added because the filter is full.
159+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors">}}) when the number of arguments or key type is wrong, and also when `NOCREATE` is specified and `key` does not exist.
160+
161+
{{< /multitabs >}}

content/commands/bf.loadchunk.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,24 @@ Iterator value associated with `data` (returned by [`BF.SCANDUMP`]({{< relref "c
6161
Current data chunk (returned by [`BF.SCANDUMP`]({{< relref "commands/bf.scandump/" >}}))
6262
</details>
6363

64-
## Return value
64+
## Examples
6565

66-
Returns one of these replies:
66+
See [`BF.SCANDUMP`]({{< relref "commands/bf.scandump/" >}}) for an example.
6767

68-
- [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}) - `OK` if executed correctly
69-
- [] on error (invalid arguments, wrong key type, wrong data, etc.)
68+
## Return information
7069

71-
## Examples
70+
{{< multitabs id="bf-loadchunk-return-info"
71+
tab1="RESP2"
72+
tab2="RESP3" >}}
7273

73-
See [`BF.SCANDUMP`]({{< relref "commands/bf.scandump/" >}}) for an example.
74+
One of the following:
75+
* [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}): `OK` if executed correctly.
76+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments, wrong key type, or when invalid data was passed.
77+
78+
-tab-sep-
79+
80+
One of the following:
81+
* [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}): `OK` if executed correctly.
82+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments, wrong key type, or when invalid data was passed.
83+
84+
{{< /multitabs >}}

content/commands/bf.madd.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ If `key` does not exist - a new Bloom filter is created with default error rate,
5555
One or more items to add.
5656
</details>
5757

58-
## Return value
58+
## Return information
5959

6060
Returns one of these replies:
6161

@@ -72,3 +72,25 @@ redis> BF.MADD bf item1 item2 item2
7272
2) (integer) 1
7373
3) (integer) 0
7474
{{< / highlight >}}
75+
76+
## Return information
77+
78+
{{< multitabs id="bf-madd-return-info"
79+
tab1="RESP2"
80+
tab2="RESP3" >}}
81+
82+
One of the following:
83+
* [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) where each element is either
84+
* an [integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}), where `1` means that the item has been added successfully, and `0` means there's a probability that the item was already added to the filter.
85+
* a [simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) when the item cannot be added because the filter is full.
86+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments, key not found, wrong key type, or when the filter is full.
87+
88+
-tab-sep-
89+
90+
One of the following:
91+
* [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) where each element is either
92+
* a [boolean reply]({{< relref "/develop/reference/protocol-spec#booleans" >}}), where `true` means that the item has been added successfully, and `false` means there's a probability that the item was already added to the filter.
93+
* a [simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) when the item cannot be added because the filter is full.
94+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments, key not found, wrong key type, or when the filter is full.
95+
96+
{{< /multitabs >}}

content/commands/bf.mexists.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,6 @@ is key name for a Bloom filter.
5050
One or more items to check.
5151
</details>
5252

53-
## Return value
54-
55-
Returns one of these replies:
56-
57-
- [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) - where "1" means that, with high probability, `item` was already added to the filter, and "0" means that `key` does not exist or that `item` was definitely not added to the filter.
58-
- [] on error (invalid arguments, wrong key type, etc.)
59-
6053
## Examples
6154

6255
{{< highlight bash >}}
@@ -68,3 +61,21 @@ redis> BF.MEXISTS bf item1 item2 item3
6861
2) (integer) 1
6962
3) (integer) 0
7063
{{< / highlight >}}
64+
65+
## Return information
66+
67+
{{< multitabs id="bf-mexists-return-info"
68+
tab1="RESP2"
69+
tab2="RESP3" >}}
70+
71+
One of the following:
72+
* [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integer replies]({{< relref "/develop/reference/protocol-spec#integers" >}}), where `1` means that, with high probability, `item` was already added to the filter, and `0` means that `key` does not exist or that `item` was definitely not added to the filter.
73+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: in these cases: invalid arguments, wrong key type, or when the key was not found.
74+
75+
-tab-sep-
76+
77+
One of the following:
78+
* [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [boolean replies]({{< relref "/develop/reference/protocol-spec#booleans" >}}), where `true` means that, with high probability, `item` was already added to the filter, and `false` means that `key` does not exist or that `item` was definitely not added to the filter.
79+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: in these cases: invalid arguments, wrong key type, or when the key was not found.
80+
81+
{{< /multitabs >}}

content/commands/bf.reserve.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,6 @@ If the number of items to be stored in the filter is unknown, you use an `expans
9595
Otherwise, you use an `expansion` of `1` to reduce memory consumption. The default value is `2`.
9696
</details>
9797

98-
## Return value
99-
100-
Returns one of these replies:
101-
102-
- [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}) - `OK` if filter created successfully
103-
- [] on error (invalid arguments, key already exists, etc.)
104-
10598
## Examples
10699

107100
{{< highlight bash >}}
@@ -123,3 +116,21 @@ OK
123116
redis> BF.RESERVE bf_non 0.01 1000 NONSCALING
124117
OK
125118
{{< / highlight >}}
119+
120+
## Return information
121+
122+
{{< multitabs id="bf-reserve-return-info"
123+
tab1="RESP2"
124+
tab2="RESP3" >}}
125+
126+
One of the following:
127+
* [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}): `OK` if the filter was created successfully.
128+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments or the key already exists.
129+
130+
-tab-sep-
131+
132+
One of the following:
133+
* [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}): `OK` if the filter was created successfully.
134+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments or the key already exists.
135+
136+
{{< /multitabs >}}

content/commands/bf.scandump.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,7 @@ is key name for a Bloom filter to save.
5151
Iterator value; either 0 or the iterator from a previous invocation of this command
5252
</details>
5353

54-
## Return value
5554

56-
Returns one of these replies:
57-
58-
- [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) (_Iterator_) and [] (_Data_).
59-
60-
The Iterator is passed as input to the next invocation of `BF.SCANDUMP`. If _Iterator_ is 0, then it means iteration has completed.
61-
62-
The iterator-data pair should also be passed to [`BF.LOADCHUNK`]({{< relref "commands/bf.loadchunk/" >}}) when restoring the filter.
63-
64-
- [] on error (invalid arguments, key not found, wrong key type, etc.)
6555

6656
## Examples
6757

@@ -105,3 +95,29 @@ for chunk in chunks:
10595
iter, data = chunk
10696
BF.LOADCHUNK(key, iter, data)
10797
{{< / highlight >}}
98+
99+
## Return information
100+
101+
{{< multitabs id="bf-scandump-return-info"
102+
tab1="RESP2"
103+
tab2="RESP3" >}}
104+
105+
One of the following:
106+
* [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}): a two-element array of an [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) (_Iterator_) and a [Bulk string reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) (_Data_).
107+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments, the key was not found, or the key is of the wrong type.
108+
109+
The Iterator is passed as input to the next invocation of `BF.SCANDUMP`. If _Iterator_ is 0, then it means iteration has completed.
110+
111+
The iterator-data pair should also be passed to [`BF.LOADCHUNK`]({{< relref "commands/bf.loadchunk/" >}}) when restoring the filter.
112+
113+
-tab-sep-
114+
115+
One of the following:
116+
* [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}): a two-element array of an [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) (_Iterator_) and a [Bulk string reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) (_Data_).
117+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments, the key was not found, or the key is of the wrong type.
118+
119+
The Iterator is passed as input to the next invocation of `BF.SCANDUMP`. If _Iterator_ is 0, then it means iteration has completed.
120+
121+
The iterator-data pair should also be passed to [`BF.LOADCHUNK`]({{< relref "commands/bf.loadchunk/" >}}) when restoring the filter.
122+
123+
{{< /multitabs >}}

0 commit comments

Comments
 (0)