Skip to content

Commit 5084029

Browse files
committed
Merge branch 'feat-ros-8.2' of github.com:redis/docs into feat-ros-8.2
2 parents f1d1b24 + 62afd23 commit 5084029

File tree

4 files changed

+215
-24
lines changed

4 files changed

+215
-24
lines changed

content/commands/bitop.md

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ arguments:
2121
name: not
2222
token: NOT
2323
type: pure-token
24+
- display_text: diff
25+
name: diff
26+
token: DIFF
27+
type: pure-token
28+
- display_text: diff1
29+
name: diff1
30+
token: DIFF1
31+
type: pure-token
32+
- display_text: andor
33+
name: andor
34+
token: ANDOR
35+
type: pure-token
36+
- display_text: one
37+
name: one
38+
token: ONE
39+
type: pure-token
2440
name: operation
2541
type: oneof
2642
- display_text: destkey
@@ -78,26 +94,45 @@ key_specs:
7894
linkTitle: BITOP
7995
since: 2.6.0
8096
summary: Performs bitwise operations on multiple strings, and stores the result.
81-
syntax_fmt: BITOP <AND | OR | XOR | NOT> destkey key [key ...]
97+
syntax_fmt: "BITOP <AND | OR | XOR | NOT | DIFF | DIFF1 | ANDOR | ONE> destkey key [key ...]"
8298
syntax_str: destkey key [key ...]
8399
title: BITOP
84100
---
85101
Perform a bitwise operation between multiple keys (containing string values) and
86102
store the result in the destination key.
87103

88-
The `BITOP` command supports four bitwise operations: **AND**, **OR**, **XOR**
89-
and **NOT**, thus the valid forms to call the command are:
104+
The `BITOP` command supports eight bitwise operations: `AND`, `OR`, `XOR`,
105+
`NOT`, `DIFF`, `DIFF1`, `ANDOR`, and `ONE`. The valid forms to call the command are:
90106

91107

92108
* `BITOP AND destkey srckey1 srckey2 srckey3 ... srckeyN`
109+
110+
A bit in `destkey` is set only if it is set in all source bitmaps.
93111
* `BITOP OR destkey srckey1 srckey2 srckey3 ... srckeyN`
112+
113+
A bit in `destkey` is set only if it is set in at least one source bitmap.
94114
* `BITOP XOR destkey srckey1 srckey2 srckey3 ... srckeyN`
115+
116+
Mostly used with two source bitmaps, a bit in `destkey` is set only if its value differs between the two source bitmaps.
95117
* `BITOP NOT destkey srckey`
96118

97-
As you can see **NOT** is special as it only takes an input key, because it
98-
performs inversion of bits so it only makes sense as a unary operator.
119+
`NOT` is a unary operator and only supports a single source bitmap; set the bit to the inverse of its value in the source bitmap.
120+
* `BITOP DIFF destkey X [Y1 Y2 ...]` <sup>[1](#list-note-1)</sup>
121+
122+
A bit in `destkey` is set if it is set in `X`, but not in any of `Y1, Y2, ...` .
123+
* `BITOP DIFF1 destkey X [Y1 Y2 ...]` <sup>[1](#list-note-1)</sup>
99124

100-
The result of the operation is always stored at `destkey`.
125+
A bit in `destkey` is set if it is set in one or more of `Y1, Y2, ...`, but not in `X`.
126+
* `BITOP ANDOR destkey X [Y1 Y2 ...]` <sup>[1](#list-note-1)</sup>
127+
128+
A bit in `destkey` is set if it is set in `X` and also in one or more of `Y1, Y2, ...`.
129+
* `BITOP ONE destkey X1 [X2 X3 ...]` <sup>[1](#list-note-1)</sup>
130+
131+
A bit in `destkey` is set if it is set in exactly one of `X1, X2, ...`.
132+
133+
The result of each operation is always stored at `destkey`.
134+
135+
1. <a name="list-note-1"></a> Added in Redis 8.2.
101136

102137
## Handling of strings with different lengths
103138

@@ -110,13 +145,27 @@ zero bytes up to the length of the longest string.
110145

111146
## Examples
112147

148+
1. Basic usage example using the `AND` operator:
149+
113150
{{% redis-cli %}}
114-
SET key1 "foobar"
115-
SET key2 "abcdef"
151+
BITFIELD key1 SET i8 #0 255
152+
BITFIELD key2 SET i8 #0 85
116153
BITOP AND dest key1 key2
117-
GET dest
154+
BITFIELD dest GET i8 #0
118155
{{% /redis-cli %}}
119156

157+
2. Suppose you want to expose people to a book-related ad. The target audience is people who love to read books and are interested in fantasy, adventure, or science fiction. Assume you have the following bitmaps:
158+
159+
* `LRB` - people who love to read books.
160+
* `B:F` - people interested in fantasy.
161+
* `B:A` - people interested in adventure.
162+
* `B:SF` - people interested in science fiction.
163+
164+
To create a bitmap representing the target audience, use the following command:
165+
166+
```
167+
BITOP ANDOR TA LRB B:F B:A B:SF
168+
```
120169

121170
## Pattern: real time metrics using bitmaps
122171

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
arguments:
3+
- arguments:
4+
- arguments:
5+
- name: start-slot
6+
type: integer
7+
- name: end-slot
8+
type: integer
9+
name: slotsrange
10+
token: SLOTSRANGE
11+
type: block
12+
- arguments:
13+
- name: metric
14+
type: string
15+
- name: limit
16+
optional: true
17+
token: LIMIT
18+
type: integer
19+
- arguments:
20+
- name: asc
21+
token: ASC
22+
type: pure-token
23+
- name: desc
24+
token: DESC
25+
type: pure-token
26+
name: order
27+
optional: true
28+
type: oneof
29+
name: orderby
30+
token: ORDERBY
31+
type: block
32+
name: filter
33+
type: oneof
34+
arity: -4
35+
categories:
36+
- docs
37+
- develop
38+
- stack
39+
- oss
40+
- rs
41+
- rc
42+
- oss
43+
- kubernetes
44+
- clients
45+
command_flags:
46+
- STALE
47+
- LOADING
48+
command_tips:
49+
- NONDETERMINISTIC_OUTPUT
50+
- REQUEST_POLICY:ALL_SHARDS
51+
complexity: O(N) where N is the total number of slots based on arguments. O(N*log(N))
52+
with ORDERBY subcommand.
53+
container: CLUSTER
54+
description: Return an array of slot usage statistics for slots assigned to the current
55+
node.
56+
function: clusterSlotStatsCommand
57+
group: cluster
58+
hidden: false
59+
linkTitle: CLUSTER SLOT-STATS
60+
reply_schema:
61+
description: Array of nested arrays, where the inner array element represents a
62+
slot and its respective usage statistics.
63+
items:
64+
description: Array of size 2, where 0th index represents (int) slot and 1st index
65+
represents (map) usage statistics.
66+
items:
67+
- description: Slot Number.
68+
type: integer
69+
- additionalProperties: false
70+
description: Map of slot usage statistics.
71+
properties:
72+
cpu-usec:
73+
type: integer
74+
key-count:
75+
type: integer
76+
network-bytes-in:
77+
type: integer
78+
network-bytes-out:
79+
type: integer
80+
type: object
81+
maxItems: 2
82+
minItems: 2
83+
type: array
84+
type: array
85+
since: 8.2.0
86+
summary: Return an array of slot usage statistics for slots assigned to the current
87+
node.
88+
syntax_fmt: "CLUSTER SLOT-STATS <SLOTSRANGE\_start-slot end-slot | ORDERBY\_metric\n [LIMIT\_\
89+
limit] [ASC | DESC]>"
90+
syntax_str: ''
91+
title: CLUSTER SLOT-STATS
92+
---
93+
94+
Use this command to get an array of slot usage statistics for the slots assigned to the current shard. If you're working with a Redis cluster, this data helps you understand overall slot usage, spot hot or cold slots, plan slot migrations to balance load, or refine your application logic to better distribute keys.
95+
96+
## Options
97+
98+
`CLUSTER SLOT-STATS` has two mutually exclusive options:
99+
100+
* `ORDERBY`: Sorts the slot statistics by the specified metric. Use ASC or DESC to sort in ascending or descending order. If multiple slots have the same value, the command uses the slot number as a tiebreaker, sorted in ascending order.
101+
102+
* `SLOTSRANGE`: Limits the results to a specific, inclusive range of slots. Results are always sorted by slot number in ascending order.
103+
104+
The command reports on the following statistics:
105+
106+
* `KEY-COUNT`: Number of keys stored in the slot.
107+
* `CPU-USEC`: CPU time (in microseconds) spent handling the slot.
108+
* `NETWORK-BYTES-IN`: Total inbound network traffic (in bytes) received by the slot.
109+
* `NETWORK-BYTES-OUT`: Total outbound network traffic (in bytes) sent from the slot.
110+
111+
## Return information
112+
113+
{{< multitabs id=“cmd-name-return-info"
114+
tab1="RESP2"
115+
tab2="RESP3" >}}
116+
117+
One of the following:
118+
119+
* [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}): a nested list of slot usage statistics.
120+
* [Simple error]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) otherwise.
121+
122+
-tab-sep-
123+
124+
One of the following:
125+
126+
* [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}): a nested list of slot usage statistics.
127+
* [Simple error]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) otherwise.
128+
129+
{{< /multitabs >}}

content/commands/vsim.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ complexity: O(log(N)) where N is the number of elements in the vector set.
1313
description: Return elements by vector similarity.
1414
group: vector_set
1515
hidden: false
16+
history:
17+
- - 8.2.0
18+
- added the WITHATTRIBS option.
1619
linkTitle: VSIM
1720
since: 8.0.0
1821
summary: Return elements by vector similarity.
19-
syntax_fmt: "VSIM key (ELE | FP32 | VALUES num) (vector | element) [WITHSCORES] [COUNT num] [EF search-exploration-factor]\n [FILTER expression] [FILTER-EF max-filtering-effort] [TRUTH] [NOTHREAD]"
22+
syntax_fmt: "VSIM key (ELE | FP32 | VALUES num) (vector | element) [WITHSCORES] [WITHATTRIBS] [COUNT num]\n [EF search-exploration-factor] [FILTER expression] [FILTER-EF max-filtering-effort] [TRUTH] [NOTHREAD]"
2023
title: VSIM
2124
bannerText: Vector set is a new data type that is currently in preview and may be subject to change.
2225
---
@@ -39,16 +42,19 @@ VSIM word_embeddings ELE apple
3942
10) "grape"
4043
```
4144

42-
You can include similarity scores and limit the number of results:
45+
You can include similarity scores, attributes (if any), and limit the number of results:
4346

4447
```shell
45-
VSIM word_embeddings ELE apple WITHSCORES COUNT 3
48+
VSIM word_embeddings ELE apple WITHSCORES WITHATTRIBS COUNT 3
4649
1) "apple"
4750
2) "0.9998867657923256"
48-
3) "apples"
49-
4) "0.8598527610301971"
50-
5) "pear"
51-
6) "0.8226882219314575"
51+
3) "{\"len\": 5}"
52+
4) "apples"
53+
5) "0.859852746129036"
54+
6) "{\"len\": 6}"
55+
7) "pear"
56+
8) "0.8226882070302963"
57+
9) "{\"len\": 4}"
5258
```
5359

5460
Set the `EF` (exploration factor) to improve recall at the cost of performance. Use the `TRUTH` option to perform an exact linear scan, useful for benchmarking. The `NOTHREAD` option runs the search in the main thread and may increase server latency.
@@ -81,6 +87,12 @@ is either the vector data (for `FP32` or `VALUES`) or the name of the element (f
8187
returns the similarity score (from 1 to 0) alongside each result. A score of 1 is identical; 0 is the opposite.
8288
</details>
8389

90+
<details open>
91+
<summary><code>WITHATTRIBS</code></summary>
92+
93+
returns, for each element, the JSON attribute associated with the element or NULL when no attributes are present.
94+
</details>
95+
8496
<details open>
8597
<summary><code>COUNT num</code></summary>
8698

@@ -128,16 +140,19 @@ executes the search in the main thread instead of a background thread. Useful fo
128140
tab2="RESP3" >}}
129141

130142
One of the following:
131-
* [Simple error reply](../../develop/reference/protocol-spec/#simple-errors) for unknown element.
132-
* [Array reply](../../develop/reference/protocol-spec#arrays) (empty array) for unknown key.
133-
* [Array reply](../../develop/reference/protocol-spec#arrays) with matching elements; juxtaposed with scores when used with the WITHSCORES option.
143+
* [Simple error reply](../../develop/reference/protocol-spec/#simple-errors) for an unknown element.
144+
* [Array reply](../../develop/reference/protocol-spec#arrays) (empty array) for an unknown key.
145+
* [Array reply](../../develop/reference/protocol-spec#arrays) with matching elements.
146+
* With the `WITHSCORES` option, an [array reply](../../develop/reference/protocol-spec#arrays) with matching [bulk string]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) elements juxtaposed with [bulk string]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) as floating-point scores.
147+
* With the `WITHSCORES` and `WITHATTRIBS` options, an [array reply](../../develop/reference/protocol-spec#arrays) with matching [bulk string]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) elements, and two additional elements: (1) a [bulk string]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) as floating-point score and (2) a [bulk string]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) representing the JSON attribute associated with the element or [nil (null bulk string)]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) for the elements missing an attribute.
134148

135149
-tab-sep-
136150

137151
One of the following:
138152
* [Simple error reply](../../develop/reference/protocol-spec/#simple-errors) for unknown element.
139153
* [Array reply](../../develop/reference/protocol-spec#arrays) (empty array) for unknown key.
140154
* [Array reply](../../develop/reference/protocol-spec#arrays) with matching elements.
141-
* [Map reply](../../develop/reference/protocol-spec#maps) with matching elements and [double](../../develop/reference/protocol-spec#doubles) scores when used with the WITHSCORES option.
155+
* With the `WITHSCORES` option, a [map reply](../../develop/reference/protocol-spec#maps) with matching [bulk string]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) elements (keys) and [double](../../develop/reference/protocol-spec#doubles) scores (values).
156+
* With the `WITHSCORES` and `WITHATTRIBS` options, a [Map reply](../../develop/reference/protocol-spec#maps) with matching [bulk string]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) elements (keys), and an additional array (values) with the following elements: (1) a [double reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) for the score and (2) a [bulk string]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) representing the JSON attribute associated with the element or [null]({{< relref "/develop/reference/protocol-spec#nulls" >}}) for the elements missing an attribute.
142157

143158
{{< /multitabs >}}

content/develop/data-types/bitmaps.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ categories:
99
- oss
1010
- kubernetes
1111
- clients
12-
description: 'Introduction to Redis bitmaps
13-
14-
'
12+
description: Introduction to Redis bitmaps
1513
linkTitle: Bitmaps
1614
title: Redis bitmaps
1715
weight: 120
@@ -79,7 +77,7 @@ stored into the target key) are always considered to be zero.
7977

8078
There are three commands operating on group of bits:
8179

82-
1. [`BITOP`]({{< relref "/commands/bitop" >}}) performs bit-wise operations between different strings. The provided operations are AND, OR, XOR and NOT.
80+
1. [`BITOP`]({{< relref "/commands/bitop" >}}) performs bit-wise operations between different strings. The provided operators are `AND`, `OR`, `XOR`, `NOT`, `DIFF`, `DIFF1`, `ANDOR`, and `ONE`.
8381
2. [`BITCOUNT`]({{< relref "/commands/bitcount" >}}) performs population counting, reporting the number of bits set to 1.
8482
3. [`BITPOS`]({{< relref "/commands/bitpos" >}}) finds the first bit having the specified value of 0 or 1.
8583

0 commit comments

Comments
 (0)