Skip to content

Commit b808838

Browse files
Update top-k.md
1 parent fd16605 commit b808838

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ds/prob/top-k.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ A Top-K maintains a list of *K* most frequently seen items.
44

55
To get started, initialize a Top-K with a width (the number of counters kept in each array), depth (the number of arrays), and decay (the probability of reducing a counter in an occupied bucket).
66

7-
```redis Initialize a Top-K
7+
```redis:[run_confirmation=true] Initialize a Top-K
88
TOPK.RESERVE bikes:keywords 50 2000 7 0.925 // initializes the Top-K with 50 counters kept in each array, 2000 arrays and 0.925 probability of reducing a counter in an occupied bucket
99
```
1010

1111
Next, add items to the Top-K filter.
1212

1313
Note that if an item enters the Top-K list, the item which is expelled from the list to make room for it is returned.
1414

15-
```redis Add items
15+
```redis:[run_confirmation=true] Add items
1616
TOPK.ADD bikes:keywords store seat handlebars handles pedals tires store seat
1717
```
1818

1919
You can increase the score of an item in the Top-K by a given increment. “nil” is returned if no change to the Top-K list occurred. If the modified item entered the Top-K list as a result of the increment operation, then the item dropped from the list to make room for it is returned.
2020

21-
```redis Increase the score
21+
```redis:[run_confirmation=true] Increase the score
2222
TOPK.INCRBY bikes:keywords store 3 seat 2 handles 30 // increases the score of "store" by 3, "seat" by 2 and "handles" by 30.
2323
```
2424

@@ -38,4 +38,4 @@ You can see the number of required items (k), width, depth, and decay values in
3838

3939
```redis Get information about the Top-K
4040
TOPK.INFO bikes:keywords
41-
```
41+
```

0 commit comments

Comments
 (0)