Skip to content

Commit 6dc31e7

Browse files
DEV: add RESP2/3 info to the top-k commands (#1747)
* DEV: add RESP2/3 info to the top-k commands * Apply suggestions from code review Co-authored-by: mich-elle-luna <[email protected]> --------- Co-authored-by: mich-elle-luna <[email protected]>
1 parent 82b282a commit 6dc31e7

File tree

7 files changed

+191
-79
lines changed

7 files changed

+191
-79
lines changed

content/commands/topk.add.md

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,41 @@ syntax_str: items [items ...]
3333
title: TOPK.ADD
3434
---
3535

36-
Adds an item to the data structure.
37-
Multiple items can be added at once.
38-
If an item enters the Top-K list, the item which is expelled is returned.
39-
This allows dynamic heavy-hitter detection of items being entered or expelled from Top-K list.
36+
Adds an item to a Top-k sketch.
37+
Multiple items can be added at the same time.
38+
If an item enters the Top-K sketch, the item that is expelled (if any) is returned.
39+
This allows dynamic heavy-hitter detection of items being entered or expelled from Top-K sketch.
4040

41-
### Parameters
41+
## Parameters
4242

43-
* **key**: Name of sketch where item is added.
44-
* **item**: Item/s to be added.
43+
* **key**: the name of the sketch where items are added.
44+
* **item**: the items to be added.
4545

46-
### Return
47-
48-
[Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}) - if an element was dropped from the TopK list, [Nil reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) otherwise..
49-
50-
#### Example
46+
## Example
5147

5248
```
5349
redis> TOPK.ADD topk foo bar 42
5450
1) (nil)
5551
2) baz
5652
3) (nil)
57-
```
53+
```
54+
55+
## Return information
56+
57+
{{< multitabs id=“topk-add-return-info"
58+
tab1="RESP2"
59+
tab2="RESP3" >}}
60+
61+
One of the following:
62+
63+
* [Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) containing either dropped elements or [nil (null bulk string)]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}).
64+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: incorrect number of arguments or non-existant key.
65+
66+
-tab-sep-
67+
68+
One of the following:
69+
70+
* [Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) containing either dropped elements or [null]({{< relref "/develop/reference/protocol-spec#nulls" >}}).
71+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: incorrect number of arguments, non-existant key, or key of the incorrect type.
72+
73+
{{< /multitabs >}}

content/commands/topk.count.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,29 @@ categories:
2121
- clients
2222
complexity: O(n) where n is the number of items
2323
deprecated_since: '2.4'
24-
description: Return the count for one or more items are in a sketch
24+
description: Return the count for one or more items in a sketch
2525
group: topk
2626
hidden: false
2727
linkTitle: TOPK.COUNT
2828
module: Bloom
2929
since: 2.0.0
3030
stack_path: docs/data-types/probabilistic
31-
summary: Return the count for one or more items are in a sketch
31+
summary: Return the count for one or more items in a sketch
3232
syntax_fmt: TOPK.COUNT key item [item ...]
3333
syntax_str: item [item ...]
3434
title: TOPK.COUNT
3535
---
36-
Returns count for an item.
36+
Returns counts for each item present in the sketch.
3737
Multiple items can be requested at once.
38-
Please note this number will never be higher than the real count and likely to be lower.
38+
Please note this number will never be higher than the real count and will likely be lower.
3939

4040
This command has been deprecated. The count value is not a representative of
4141
the number of appearances of an item.
4242

43-
### Parameters
43+
## Parameters
4444

45-
* **key**: Name of sketch where item is counted.
46-
* **item**: Item/s to be counted.
47-
48-
## Return
49-
50-
[Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) - count for responding item.
45+
* **key**: the name of the sketch where items are to be counted.
46+
* **item**: the items to be counted.
5147

5248
## Examples
5349

@@ -57,3 +53,23 @@ redis> TOPK.COUNT topk foo 42 nonexist
5753
2) (integer) 1
5854
3) (integer) 0
5955
```
56+
57+
## Return information
58+
59+
{{< multitabs id=“topk-count-return-info"
60+
tab1="RESP2"
61+
tab2="RESP3" >}}
62+
63+
One of the following:
64+
65+
* [Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integer replies]({{< relref "/develop/reference/protocol-spec#integers" >}}) representing the count of each specified item. For non-existant items, `0` is returned.
66+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: incorrect number of arguments, non-existant key, or key of the incorrect type.
67+
68+
-tab-sep-
69+
70+
One of the following:
71+
72+
* [Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integer replies]({{< relref "/develop/reference/protocol-spec#integers" >}}) representing the count of each specified item. For non-existant items, `0` is returned.
73+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: incorrect number of arguments, non-existant key, or key of the incorrect type.
74+
75+
{{< /multitabs >}}

content/commands/topk.incrby.md

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,45 @@ syntax_fmt: TOPK.INCRBY key item increment [item increment ...]
3838
syntax_str: item increment [item increment ...]
3939
title: TOPK.INCRBY
4040
---
41-
Increase the score of an item in the data structure by increment.
42-
Multiple items' score can be increased at once.
43-
If an item enters the Top-K list, the item which is expelled is returned.
41+
Increase the score of an item in the data structure by `increment`.
42+
Multiple items' scores can be increased at once.
43+
If an item enters the Top-K list, the item that is expelled (if any) is returned.
4444

4545
### Parameters
4646

47-
* **key**: Name of sketch where item is added.
48-
* **item**: Item/s to be added.
49-
* **increment**: increment to current item score. Increment must be greater or equal to 1. Increment is limited to 100,000 to avoid server freeze.
47+
* **key**: the name of the sketch.
48+
* **item**: the items to be incremented.
49+
* **increment**: the value by which items will be incremented. The `increment` must be greater or equal to 1 and less than or equal to 100,000 to avoid server freeze.
5050

5151
## Return
5252

53-
[Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}) - if an element was dropped from the TopK list, [Nil reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) otherwise..
53+
[Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}) - if an element was dropped from the TopK list, [Nil reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) otherwise..
5454

55-
@example
55+
## Example
5656

5757
```
5858
redis> TOPK.INCRBY topk foo 3 bar 2 42 30
5959
1) (nil)
6060
2) (nil)
6161
3) foo
62-
```
62+
```
63+
64+
## Return information
65+
66+
{{< multitabs id=“topk-incrby-return-info"
67+
tab1="RESP2"
68+
tab2="RESP3" >}}
69+
70+
One of the following:
71+
72+
* [Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) containing either dropped elements or [nil (null bulk string)]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}).
73+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: incorrect number of arguments, non-existant key, key of the incorrect type, or an incorrect increment (less than 0 or greater than 100,000).
74+
75+
-tab-sep-
76+
77+
One of the following:
78+
79+
* [Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) containing either dropped elements or [null]({{< relref "/develop/reference/protocol-spec#nulls" >}}).
80+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: incorrect number of arguments, non-existant key, key of the incorrect type, or an incorrect increment (less than 0 or greater than 100,000).
81+
82+
{{< /multitabs >}}

content/commands/topk.info.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,11 @@ syntax_fmt: TOPK.INFO key
2929
syntax_str: ''
3030
title: TOPK.INFO
3131
---
32-
Returns number of required items (k), width, depth and decay values.
32+
Returns number of required items (k), width, depth, and decay values of a given sketch.
3333

34-
### Parameters
34+
## Parameters
3535

36-
* **key**: Name of sketch.
37-
38-
## Return
39-
40-
[Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) with information of the filter.
36+
* **key**: the name of the sketch.
4137

4238
## Examples
4339

@@ -52,3 +48,23 @@ TOPK.INFO topk
5248
7) decay
5349
8) "0.92500000000000004"
5450
```
51+
52+
## Return information
53+
54+
{{< multitabs id=“topk-info-return-info"
55+
tab1="RESP2"
56+
tab2="RESP3" >}}
57+
58+
One of the following:
59+
60+
* [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [simple string]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}) and [integer]({{< relref "/develop/reference/protocol-spec#integers" >}}) pairs. For decay, a [simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}) is used to represent the floating point value.
61+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: incorrect number of arguments, non-existant key, or key of the incorrect type.
62+
63+
-tab-sep-
64+
65+
One of the following:
66+
67+
* [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [simple string]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}) and [integer]({{< relref "/develop/reference/protocol-spec#integers" >}}) pairs. For decay, a [double reply]({{< relref "/develop/reference/protocol-spec#doubles" >}}) is used to represent the floating point value.
68+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: incorrect number of arguments, non-existant key, or key of the incorrect type.
69+
70+
{{< /multitabs >}}

content/commands/topk.list.md

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,24 @@ categories:
2121
- kubernetes
2222
- clients
2323
complexity: O(k*log(k)) where k is the value of top-k
24-
description: Return full list of items in Top K list
24+
description: Return the full list of items in the Top-K sketch
2525
group: topk
2626
hidden: false
2727
linkTitle: TOPK.LIST
2828
module: Bloom
2929
since: 2.0.0
3030
stack_path: docs/data-types/probabilistic
31-
summary: Return full list of items in Top K list
31+
summary: Return the full list of items in the Top-K sketch
3232
syntax_fmt: TOPK.LIST key [WITHCOUNT]
3333
syntax_str: '[WITHCOUNT]'
3434
title: TOPK.LIST
3535
---
36-
Return full list of items in Top K list.
36+
Return the full list of items in Top-K sketch.
3737

38-
### Parameters
38+
## Parameters
3939

40-
* **key**: Name of sketch where item is counted.
41-
* **WITHCOUNT**: Count of each element is returned.
42-
43-
## Return
44-
45-
k (or less) items in Top K list.
46-
47-
The list is sorted by decreased count estimation.
48-
49-
[Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}) - the names of items in the TopK list.
50-
If `WITHCOUNT` is requested, [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}) and
51-
[Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) pairs of the names of items in the TopK list and their count.
40+
* **key**: the name of the sketch.
41+
* **WITHCOUNT**: the count of each element is also returned.
5242

5343
## Examples
5444

@@ -68,3 +58,28 @@ TOPK.LIST topk WITHCOUNT
6858
5) bar
6959
6) (integer) 2
7060
```
61+
62+
63+
## Return information
64+
65+
k (or less) items in the given Top-k sketch. The list is sorted by decreased count estimation.
66+
67+
{{< multitabs id=“topk-info-return-info"
68+
tab1="RESP2"
69+
tab2="RESP3" >}}
70+
71+
One of the following:
72+
73+
* [Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) representing the names of items in the given sketch. If `WITHCOUNT` is requested, an [array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) and
74+
[integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) pairs, representing the names of the items in the sketch together with their counts.
75+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments, non-existant key, or key of the incorrect type.
76+
77+
-tab-sep-
78+
79+
One of the following:
80+
81+
* [Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string replies]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) representing the names of items in the given sketch. If `WITHCOUNT` is requested, an [array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [bulk string reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) and
82+
[integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) pairs, representing the names of the items in the sketch together with their counts.
83+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments, non-existant key, or key of the incorrect type.
84+
85+
{{< /multitabs >}}

content/commands/topk.query.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,35 @@ syntax_fmt: TOPK.QUERY key item [item ...]
3232
syntax_str: item [item ...]
3333
title: TOPK.QUERY
3434
---
35-
Checks whether an item is one of Top-K items.
36-
Multiple items can be checked at once.
35+
Checks whether one or more items are one of the Top-K items.
3736

38-
### Parameters
37+
## Parameters
3938

40-
* **key**: Name of sketch where item is queried.
41-
* **item**: Item/s to be queried.
39+
* **key**: the name of the sketch.
40+
* **item**: the items to be queried.
4241

43-
## Return
44-
45-
[Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}) - "1" if item is in Top-K, otherwise "0".
46-
47-
## Examples
42+
## Example
4843

4944
```
5045
redis> TOPK.QUERY topk 42 nonexist
5146
1) (integer) 1
5247
2) (integer) 0
53-
```
48+
```
49+
50+
## Return information
51+
52+
{{< multitabs id=“topk-query-return-info"
53+
tab1="RESP2"
54+
tab2="RESP3" >}}
55+
56+
One of the following:
57+
58+
* [Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integer replies]({{< relref "/develop/reference/protocol-spec#integers" >}}): `1` if an item is in the Top-K or `0` otherwise.
59+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: non-existant key or key of the incorrect type.
60+
61+
-tab-sep-
62+
63+
* [Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [boolean replies]({{< relref "/develop/reference/protocol-spec#booleans" >}}): `true` if an item is in the Top-K or `false` otherwise.
64+
* [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: non-existant key or key of the incorrect type.
65+
66+
{{< /multitabs >}}

0 commit comments

Comments
 (0)